Skip to content

Commit 0ab6235

Browse files
committed
Merged PR 454133: Add more visitor target into ReferencesVisitor
Add SimpleType, SingleVariableDeclaration, VariableDeclarationFragment and MethodInvocation into ReferencesVisitor
1 parent d123f86 commit 0ab6235

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

66
## 0.1.3
7+
### Added
8+
- Add SimpleType, SingleVariableDeclaration, VariableDeclarationFragment and MethodInvocation into ReferencesVisitor
9+
710
### Fixed
811
- Stop enlisting the vertices and edges if the element does not have hover information
912

com.microsoft.java.lsif.core/src/com/microsoft/java/lsif/core/internal/visitors/ReferencesVisitor.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
import org.eclipse.core.runtime.CoreException;
1212
import org.eclipse.core.runtime.NullProgressMonitor;
1313
import org.eclipse.jdt.core.dom.MethodDeclaration;
14+
import org.eclipse.jdt.core.dom.MethodInvocation;
15+
import org.eclipse.jdt.core.dom.SimpleType;
16+
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
1417
import org.eclipse.jdt.core.dom.TypeDeclaration;
18+
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
1519
import org.eclipse.jdt.ls.core.internal.JDTUtils;
1620
import org.eclipse.lsp4j.Location;
1721
import org.eclipse.lsp4j.Position;
@@ -32,10 +36,37 @@ public class ReferencesVisitor extends ProtocolVisitor {
3236
public ReferencesVisitor() {
3337
}
3438

39+
@Override
40+
public boolean visit(SimpleType type) {
41+
emitReferences(type.getStartPosition(), type.getLength());
42+
return super.visit(type);
43+
}
44+
45+
@Override
46+
public boolean visit(SingleVariableDeclaration node) {
47+
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
48+
return super.visit(node);
49+
}
50+
51+
@Override
52+
public boolean visit(VariableDeclarationFragment node) {
53+
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
54+
return super.visit(node);
55+
}
56+
57+
@Override
58+
public boolean visit(MethodInvocation node) {
59+
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
60+
if (node.getExpression() != null) {
61+
emitReferences(node.getExpression().getStartPosition(), node.getExpression().getLength());
62+
}
63+
return super.visit(node);
64+
}
65+
3566
@Override
3667
public boolean visit(MethodDeclaration node) {
3768
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
38-
return false;
69+
return super.visit(node);
3970
}
4071

4172
@Override

0 commit comments

Comments
 (0)