Skip to content

Commit

Permalink
Merged PR 454133: Add more visitor target into ReferencesVisitor
Browse files Browse the repository at this point in the history
Add SimpleType, SingleVariableDeclaration, VariableDeclarationFragment and MethodInvocation into ReferencesVisitor
  • Loading branch information
jdneo committed Apr 8, 2019
1 parent d123f86 commit 0ab6235
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.1.3
### Added
- Add SimpleType, SingleVariableDeclaration, VariableDeclarationFragment and MethodInvocation into ReferencesVisitor

### Fixed
- Stop enlisting the vertices and edges if the element does not have hover information

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.SimpleType;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.Position;
Expand All @@ -32,10 +36,37 @@ public class ReferencesVisitor extends ProtocolVisitor {
public ReferencesVisitor() {
}

@Override
public boolean visit(SimpleType type) {
emitReferences(type.getStartPosition(), type.getLength());
return super.visit(type);
}

@Override
public boolean visit(SingleVariableDeclaration node) {
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
return super.visit(node);
}

@Override
public boolean visit(VariableDeclarationFragment node) {
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
return super.visit(node);
}

@Override
public boolean visit(MethodInvocation node) {
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
if (node.getExpression() != null) {
emitReferences(node.getExpression().getStartPosition(), node.getExpression().getLength());
}
return super.visit(node);
}

@Override
public boolean visit(MethodDeclaration node) {
emitReferences(node.getName().getStartPosition(), node.getName().getLength());
return false;
return super.visit(node);
}

@Override
Expand Down

0 comments on commit 0ab6235

Please sign in to comment.