Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java')
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java44
1 files changed, 42 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
index c7f58e771..884b4b370 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.java
@@ -846,6 +846,45 @@ protected void consumeInstanceOfExpression() {
}
}
@Override
+protected Expression consumePatternInsideInstanceof(Pattern pattern) {
+ if(pattern instanceof RecordPattern) {
+ pushLocalVariableFromRecordPatternOnAstStack((RecordPattern)pattern);
+ }
+ return super.consumePatternInsideInstanceof(pattern);
+}
+
+@Override
+protected void consumeCaseLabelElement(CaseLabelKind kind) {
+ super.consumeCaseLabelElement(kind);
+ switch (kind) {
+ case CASE_PATTERN: {
+ ASTNode[] ps = this.patternStack;
+ if (ps[0] instanceof RecordPattern) {
+ pushLocalVariableFromRecordPatternOnAstStack((RecordPattern) ps[0]);
+ }
+ }
+ break;
+ default:
+ break;
+
+ }
+}
+
+private void pushLocalVariableFromRecordPatternOnAstStack(RecordPattern rp) {
+ Pattern[] patterns = rp.patterns;
+ for (Pattern pattern : patterns) {
+ if (pattern instanceof RecordPattern)
+ pushLocalVariableFromRecordPatternOnAstStack((RecordPattern) pattern);
+ else {
+ LocalDeclaration patternVariable = pattern.getPatternVariable();
+ if (patternVariable != null)
+ pushOnAstStack(patternVariable);
+
+ }
+ }
+}
+
+@Override
protected void consumeInstanceOfExpressionWithName() {
int length = this.patternLengthPtr >= 0 ?
this.patternLengthStack[this.patternLengthPtr--] : 0;
@@ -855,12 +894,13 @@ protected void consumeInstanceOfExpressionWithName() {
if (this.expressionStack[this.expressionPtr] != this.assistNode) {
// Push only when the selection node is not the expression of this
// pattern matching instanceof expression
- LocalDeclaration patternVariableIntroduced = pattern.getPatternVariableIntroduced();
+ LocalDeclaration patternVariableIntroduced = pattern.getPatternVariable();
if (patternVariableIntroduced != null) {
// filter out patternVariableIntroduced based on current selection if there is an assist node
if (this.assistNode == null || (this.selectionStart <= patternVariableIntroduced.sourceStart
&& this.selectionEnd >= patternVariableIntroduced.sourceEnd)) {
- pushOnAstStack(patternVariableIntroduced);
+ if(!(pattern instanceof RecordPattern))
+ pushOnAstStack(patternVariableIntroduced);
}
}
if ((this.selectionStart >= pattern.sourceStart)

Back to the top