419 else
420 importAll(tree, p, env);
421 } else {
422 // Named type import.
423 if (tree.staticImport) {
424 importNamedStatic(tree, p, name, localEnv);
425 chk.checkCanonical(imp.selected);
426 } else {
427 Type importedType = attribImportType(imp, localEnv);
428 Type originalType = importedType.getOriginalType();
429 TypeSymbol c = originalType.hasTag(CLASS) ? originalType.tsym : importedType.tsym;
430 chk.checkCanonical(imp);
431 importNamed(tree.pos(), c, env, tree);
432 }
433 }
434 }
435
436 Type attribImportType(JCTree tree, Env<AttrContext> env) {
437 Assert.check(completionEnabled);
438 Lint prevLint = chk.setLint(allowDeprecationOnImport ?
439 lint : lint.suppress(LintCategory.DEPRECATION, LintCategory.REMOVAL));
440 try {
441 // To prevent deep recursion, suppress completion of some
442 // types.
443 completionEnabled = false;
444 return attr.attribType(tree, env);
445 } finally {
446 completionEnabled = true;
447 chk.setLint(prevLint);
448 }
449 }
450
451 /** Import all classes of a class or package on demand.
452 * @param imp The import that is being handled.
453 * @param tsym The class or package the members of which are imported.
454 * @param env The env in which the imported classes will be entered.
455 */
456 private void importAll(JCImport imp,
457 final TypeSymbol tsym,
458 Env<AttrContext> env) {
459 env.toplevel.starImportScope.importAll(types, tsym.members(), typeImportFilter, imp, cfHandler);
|
419 else
420 importAll(tree, p, env);
421 } else {
422 // Named type import.
423 if (tree.staticImport) {
424 importNamedStatic(tree, p, name, localEnv);
425 chk.checkCanonical(imp.selected);
426 } else {
427 Type importedType = attribImportType(imp, localEnv);
428 Type originalType = importedType.getOriginalType();
429 TypeSymbol c = originalType.hasTag(CLASS) ? originalType.tsym : importedType.tsym;
430 chk.checkCanonical(imp);
431 importNamed(tree.pos(), c, env, tree);
432 }
433 }
434 }
435
436 Type attribImportType(JCTree tree, Env<AttrContext> env) {
437 Assert.check(completionEnabled);
438 Lint prevLint = chk.setLint(allowDeprecationOnImport ?
439 lint : lint.suppress(LintCategory.DEPRECATION, LintCategory.REMOVAL, LintCategory.PREVIEW));
440 try {
441 // To prevent deep recursion, suppress completion of some
442 // types.
443 completionEnabled = false;
444 return attr.attribType(tree, env);
445 } finally {
446 completionEnabled = true;
447 chk.setLint(prevLint);
448 }
449 }
450
451 /** Import all classes of a class or package on demand.
452 * @param imp The import that is being handled.
453 * @param tsym The class or package the members of which are imported.
454 * @param env The env in which the imported classes will be entered.
455 */
456 private void importAll(JCImport imp,
457 final TypeSymbol tsym,
458 Env<AttrContext> env) {
459 env.toplevel.starImportScope.importAll(types, tsym.members(), typeImportFilter, imp, cfHandler);
|