Skip to content

Commit 989d758

Browse files
Rob Strykerrgrunber
authored andcommitted
Undo some changes in jdt.core that are no longer relevant
Signed-off-by: Rob Stryker <[email protected]>
1 parent bb1f6a9 commit 989d758

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

org.eclipse.jdt.core.javac/src/org/eclipse/jdt/internal/core/search/matching/DOMLocalVariableLocator.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.eclipse.jdt.core.dom.QualifiedName;
2121
import org.eclipse.jdt.core.dom.SimpleName;
2222
import org.eclipse.jdt.core.dom.VariableDeclaration;
23+
import org.eclipse.jdt.internal.core.LocalVariable;
2324
import org.eclipse.jdt.internal.core.search.LocatorResponse;
2425

2526
public class DOMLocalVariableLocator extends DOMPatternLocator {
@@ -31,6 +32,12 @@ public DOMLocalVariableLocator(LocalVariableLocator lcl) {
3132
this.locator = lcl;
3233
}
3334

35+
private LocalVariable getLocalVariable() {
36+
if( this.locator.pattern instanceof LocalVariablePattern lvp )
37+
return lvp.localVariable;
38+
return null;
39+
}
40+
3441
@Override
3542
public LocatorResponse match(Name node, NodeSetWrapper nodeSet, MatchLocator locator) {
3643
if (node.getLocationInParent() instanceof ChildPropertyDescriptor descriptor
@@ -40,7 +47,7 @@ public LocatorResponse match(Name node, NodeSetWrapper nodeSet, MatchLocator loc
4047
|| descriptor == QualifiedName.QUALIFIER_PROPERTY)
4148
// local variables cannot be qualified
4249
&& node instanceof SimpleName simple
43-
&& this.locator.getLocalVariable().getElementName().equals(simple.getIdentifier())) {
50+
&& Objects.equals(getLocalVariable() == null ? null : getLocalVariable().getElementName(), simple.getIdentifier())) {
4451
return toResponse(POSSIBLE_MATCH);
4552
}
4653
return toResponse(IMPOSSIBLE_MATCH);
@@ -51,7 +58,7 @@ public LocatorResponse resolveLevel(org.eclipse.jdt.core.dom.ASTNode node, IBind
5158
if (!(binding instanceof IVariableBinding)) {
5259
return toResponse(IMPOSSIBLE_MATCH);
5360
}
54-
if (Objects.equals(binding.getJavaElement(), this.locator.getLocalVariable())) {
61+
if (Objects.equals(binding.getJavaElement(), getLocalVariable())) {
5562
return toResponse(ACCURATE_MATCH);
5663
}
5764
return toResponse(INACCURATE_MATCH);
@@ -69,7 +76,7 @@ public LocatorResponse match(VariableDeclaration node, NodeSetWrapper nodeSet, M
6976
int declarationsLevel = IMPOSSIBLE_MATCH;
7077
if (this.locator.pattern.findDeclarations)
7178
if (this.locator.matchesName(this.locator.pattern.name, node.getName().getIdentifier().toCharArray()))
72-
if (node.getStartPosition() == this.locator.getLocalVariable().declarationSourceStart)
79+
if (getLocalVariable() != null && node.getStartPosition() == getLocalVariable().declarationSourceStart)
7380
declarationsLevel = this.locator.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH;
7481

7582
// Use the stronger match

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchPattern.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ final void setTypeArguments(char[][][] typeArguments) {
401401
*/
402402
void storeTypeSignaturesAndArguments(IType type) {
403403
if (type.isResolved()) {
404-
String k = type.getKey();
405404
BindingKey bindingKey = new BindingKey(type.getKey());
406405
if (bindingKey.isParameterizedType() || bindingKey.isRawType()) {
407406
String signature = bindingKey.toSignature();

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/LocalVariableLocator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public int match(LocalDeclaration node, MatchingNodeSet nodeSet) {
5050

5151
return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match
5252
}
53-
protected LocalVariable getLocalVariable() {
53+
private LocalVariable getLocalVariable() {
5454
return ((LocalVariablePattern) this.pattern).localVariable;
5555
}
5656
@Override

org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/PossibleMatch.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,11 @@ public PossibleMatch(MatchLocator locator, IResource resource, Openable openable
5656
this.resource = resource;
5757
this.openable = openable;
5858
this.document = document;
59-
this.nodeSet = createMatchingNodeSet(mustResolve);
59+
this.nodeSet = new MatchingNodeSet(mustResolve);
6060
char[] qualifiedName = getQualifiedName();
6161
if (qualifiedName != null)
6262
this.compoundName = CharOperation.splitOn('.', qualifiedName);
6363
}
64-
65-
protected MatchingNodeSet createMatchingNodeSet(boolean mustResolve) {
66-
return new MatchingNodeSet(mustResolve);
67-
}
68-
6964
public void cleanUp() {
7065
this.source = null;
7166
if (this.parsedUnit != null) {

0 commit comments

Comments
 (0)