diff options
author | Stephan Herrmann | 2022-11-29 00:30:18 +0000 |
---|---|---|
committer | Stephan Herrmann | 2022-11-29 00:30:18 +0000 |
commit | 6b6fd86dd65bf5e200a076d7e307fb015922baa8 (patch) | |
tree | 8cdcf2454a54506767bc5802db3d96d7e0f74b58 | |
parent | 9916f6215475db33ae7706990814c37da3550e11 (diff) | |
download | org.eclipse.objectteams-6b6fd86dd65bf5e200a076d7e307fb015922baa8.tar.gz org.eclipse.objectteams-6b6fd86dd65bf5e200a076d7e307fb015922baa8.tar.xz org.eclipse.objectteams-6b6fd86dd65bf5e200a076d7e307fb015922baa8.zip |
regression fixes:
+ improve resetting of callin/-out flags in the Scanner
+ restore OT variant of Keywords.WHEN for "when ()" proposals
4 files changed, 11 insertions, 8 deletions
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 48d43560a..fed9b0ef8 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 @@ -2413,7 +2413,7 @@ private void classHeaderExtendsOrImplements(boolean isInterface, boolean isRecor // guard predicate? if (type.isRole() || type.isTeam()) { keywords[count++] = Keywords.BASE_WHEN; - keywords[count++] = Keywords.WHEN; + keywords[count++] = Keywords.WHEN_PARENS; } // gbr,SH} @@ -2500,7 +2500,7 @@ private GuardPredicateDeclaration completeGuardKeywords(int ptr, CompilationResu CompletionOnKeyword1 completionOnKeyword = new CompletionOnKeyword1( this.identifierStack[ptr], this.identifierPositionStack[ptr], - new char[][]{ Keywords.BASE_WHEN, Keywords.WHEN}); + new char[][]{ Keywords.BASE_WHEN, Keywords.WHEN_PARENS}); // store this type ref into a faked guard predicate: GuardPredicateDeclaration result = new GuardPredicateDeclaration(cResult, diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java index a42f61e61..c655d2912 100644 --- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java +++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Keywords.java @@ -89,6 +89,7 @@ public interface Keywords { char[] RESULT = "result".toCharArray(); //$NON-NLS-1$ // these are special: include subsequent '()': char[] BASE_WHEN = "base when ()".toCharArray(); //$NON-NLS-1$ + char[] WHEN_PARENS = "when ()".toCharArray(); //$NON-NLS-1$ //gbr} char[] VAR = "var".toCharArray(); //$NON-NLS-1$ // Admittedly not a full blown keyword, just "reserved" char[] WHEN = "when".toCharArray(); //$NON-NLS-1$ // Admittedly not a full blown keyword, just "reserved" diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java index 5716bbc74..c77e9b288 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java @@ -1626,6 +1626,13 @@ public int getNextToken() throws InvalidInputException { this.scanContext = isInModuleDeclaration() ? ScanContext.EXPECTING_KEYWORD : ScanContext.INACTIVE; } token = getNextToken0(); +//{ObjectTeams: expire callin/callout flags: + if (token == TokenNamewith || token == TokenNameSEMICOLON) { + // let method mapping flags last until param mapping (possibly empty = ';') + this._callinSeen = false; + this._calloutSeen = false; + } +// SH} updateCase(token); if (areRestrictedModuleKeywordsActive()) { if (isRestrictedKeyword(token)) @@ -1647,11 +1654,6 @@ public int getNextToken() throws InvalidInputException { token = disambiguateCasePattern(token, this); } addTokenToLookBack(token); - if (token == TokenNamewith || token == TokenNameSEMICOLON) { - // let method mapping flags last until param mapping (possibly empty = ';') - this._callinSeen = false; - this._calloutSeen = false; - } this.multiCaseLabelComma = false; return token; } diff --git a/plugins/org.eclipse.objectteams.otdt.jdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/assist/CompletionAdaptor.java b/plugins/org.eclipse.objectteams.otdt.jdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/assist/CompletionAdaptor.java index 3b966b09a..c28bee012 100644 --- a/plugins/org.eclipse.objectteams.otdt.jdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/assist/CompletionAdaptor.java +++ b/plugins/org.eclipse.objectteams.otdt.jdt.ui/src/org/eclipse/objectteams/otdt/internal/ui/assist/CompletionAdaptor.java @@ -178,7 +178,7 @@ public team class CompletionAdaptor return createRoleProposal(proposal); case CompletionProposal.KEYWORD: IJavaCompletionProposal result = base.createJavaCompletionProposal(proposal); - if (CharOperation.endsWith(proposal.getCompletion(), Keywords.WHEN)) { + if (CharOperation.endsWith(proposal.getCompletion(), Keywords.WHEN_PARENS)) { // move cursor back by one (into '()') by reverse-engineering its current position: JavaCompletionProposal jProposal = (JavaCompletionProposal)result; Point cursor = jProposal.getSelection(null); |