private void insideCatch(Env env) throws IOException { TreePath path = env.getPath(); CatchTree ct = (CatchTree) path.getLeaf(); CompilationController controller = env.getController(); TokenSequence<JavaTokenId> last = findLastNonWhitespaceToken(env, ct, env.getOffset()); if (last != null && last.token().id() == JavaTokenId.LPAREN) { addKeyword(env, FINAL_KEYWORD, SPACE, false); if (!options.contains(Options.ALL_COMPLETION)) { TreeUtilities tu = controller.getTreeUtilities(); TreePath tryPath = tu.getPathElementOfKind(Tree.Kind.TRY, path); Set<TypeMirror> exs = tu.getUncaughtExceptions(tryPath != null ? tryPath : path.getParentPath()); Elements elements = controller.getElements(); for (TypeMirror ex : exs) { if (ex.getKind() == TypeKind.DECLARED && startsWith(env, ((DeclaredType) ex).asElement().getSimpleName().toString()) && (Utilities.isShowDeprecatedMembers() || !elements.isDeprecated(((DeclaredType) ex).asElement())) && !Utilities.isExcluded(((TypeElement)((DeclaredType) ex).asElement()).getQualifiedName())) { env.addToExcludes(((DeclaredType) ex).asElement()); results.add(itemFactory.createTypeItem(env.getController(), (TypeElement) ((DeclaredType) ex).asElement(), (DeclaredType) ex, anchorOffset, env.getReferencesCount(), elements.isDeprecated(((DeclaredType) ex).asElement()), false, false, false, true, false)); } } } TypeElement te = controller.getElements().getTypeElement("java.lang.Throwable"); //NOI18N if (te != null) { addTypes(env, EnumSet.of(CLASS, INTERFACE, TYPE_PARAMETER), controller.getTypes().getDeclaredType(te)); } } }
TreeUtilities tu = controller.getTreeUtilities(); TreePath tryPath = tu.getPathElementOfKind(Tree.Kind.TRY, path); Set<TypeMirror> exs = tu.getUncaughtExceptions(tryPath); if (!exs.isEmpty()) { Trees trees = controller.getTrees();
if (!options.contains(Options.ALL_COMPLETION) && mth.getBody() != null) { controller.toPhase(Phase.RESOLVED); Set<TypeMirror> exs = controller.getTreeUtilities().getUncaughtExceptions(new TreePath(path, mth.getBody())); Elements elements = controller.getElements(); for (TypeMirror ex : exs) { if (!options.contains(Options.ALL_COMPLETION) && mth.getBody() != null) { controller.toPhase(Phase.RESOLVED); Set<TypeMirror> exs = controller.getTreeUtilities().getUncaughtExceptions(new TreePath(path, mth.getBody())); Trees trees = controller.getTrees(); Types types = controller.getTypes();
TreeUtilities tu = controller.getTreeUtilities(); TreePath tryPath = tu.getPathElementOfKind(Tree.Kind.TRY, path); Set<TypeMirror> exs = tu.getUncaughtExceptions(tryPath); Elements elements = controller.getElements(); for (TypeMirror ex : exs) {
kinds = EnumSet.of(CLASS, INTERFACE); if (!options.contains(Options.ALL_COMPLETION)) { exs = controller.getTreeUtilities().getUncaughtExceptions(grandParentPath.getParentPath()); if (!options.contains(Options.ALL_COMPLETION) && ((MethodTree) parent).getBody() != null) { controller.toPhase(Phase.RESOLVED); exs = controller.getTreeUtilities().getUncaughtExceptions(new TreePath(path, ((MethodTree) parent).getBody())); Trees trees = controller.getTrees(); for (ExpressionTree thr : ((MethodTree) parent).getThrows()) {