diff options
| author | Jay Arthanareeswaran | 2016-04-21 10:37:30 +0000 |
|---|---|---|
| committer | Jay Arthanareeswaran | 2016-04-21 10:37:30 +0000 |
| commit | 3f07cee03bf21eb29e60cb096a0f462d3c1d5779 (patch) | |
| tree | f6d0ea110dcf3b299f4d1dd2f2ca9b998d51afbe | |
| parent | a0bfdfdbf59cd7fb40f1be01d38b4125d846bba4 (diff) | |
| download | eclipse.jdt.core-3f07cee03bf21eb29e60cb096a0f462d3c1d5779.tar.gz eclipse.jdt.core-3f07cee03bf21eb29e60cb096a0f462d3c1d5779.tar.xz eclipse.jdt.core-3f07cee03bf21eb29e60cb096a0f462d3c1d5779.zip | |
Bug 466252 - [templates] new 'finally' template does not appear when
there's no catch block
Change-Id: I5ac5ddd0edbf9f529fb25c8d8ef3a332665d88f2
3 files changed, 13 insertions, 6 deletions
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java index 73907c84c4..15e63a9db1 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java @@ -1633,6 +1633,8 @@ public final class CompletionEngine if (completionOnQualifiedTypeReference.isConstructorType){ context.setTokenLocation(CompletionContext.TL_CONSTRUCTOR_START); } + } else if (astNode instanceof CompletionOnKeyword3 && ((CompletionOnKeyword3) astNode).afterTryOrCatch()) { + context.setTokenLocation(CompletionContext.TL_STATEMENT_START); } else { ReferenceContext referenceContext = scope.referenceContext(); if (referenceContext instanceof AbstractMethodDeclaration) { diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java index eea71b51b6..bd91db2b58 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnKeyword3.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,15 +14,17 @@ import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; -public class CompletionOnKeyword3 extends SingleNameReference implements CompletionOnKeyword{ +public class CompletionOnKeyword3 extends SingleNameReference implements CompletionOnKeyword { private char[][] possibleKeywords; + private boolean tryOrCatch; public CompletionOnKeyword3(char[] token, long pos, char[] possibleKeyword) { - this(token, pos, new char[][]{possibleKeyword}); + this(token, pos, new char[][]{possibleKeyword}, false); } - public CompletionOnKeyword3(char[] token, long pos, char[][] possibleKeywords) { + public CompletionOnKeyword3(char[] token, long pos, char[][] possibleKeywords, boolean afterTryOrCatch) { super(token, pos); this.token = token; this.possibleKeywords = possibleKeywords; + this.tryOrCatch = afterTryOrCatch; } public char[] getToken() { return this.token; @@ -30,6 +32,9 @@ public class CompletionOnKeyword3 extends SingleNameReference implements Complet public char[][] getPossibleKeywords() { return this.possibleKeywords; } + public boolean afterTryOrCatch() { + return this.tryOrCatch; + } public StringBuffer printExpression(int indent, StringBuffer output) { return output.append("<CompleteOnKeyword:").append(this.token).append('>'); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java index 7f846af4de..27547b9921 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java @@ -4419,10 +4419,10 @@ public NameReference createSingleAssistNameReference(char[] assistName, long pos } else if((kind == K_BLOCK_DELIMITER || kind == K_LAMBDA_EXPRESSION_DELIMITER) && this.previousKind == K_BLOCK_DELIMITER && this.previousInfo == TRY) { - return new CompletionOnKeyword3(assistName, position, new char[][]{Keywords.CATCH, Keywords.FINALLY}); + return new CompletionOnKeyword3(assistName, position, new char[][]{Keywords.CATCH, Keywords.FINALLY}, true); } else if(kind == K_BLOCK_DELIMITER && topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == SWITCH) { - return new CompletionOnKeyword3(assistName, position, new char[][]{Keywords.CASE, Keywords.DEFAULT}); + return new CompletionOnKeyword3(assistName, position, new char[][]{Keywords.CASE, Keywords.DEFAULT}, false); } else { char[][] keywords = new char[Keywords.COUNT][]; int count = 0; |
