Skip to content

Commit

Permalink
Fix for xored#48 .
Browse files Browse the repository at this point in the history
Changed "findLocalReferences()" to check for prefix match in addition to
name match.  There may be other types besides UsesNode that will require
similar treatment.
  • Loading branch information
davidmichaelkarr committed Nov 22, 2015
1 parent 76ef998 commit fd0f66c
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.cisco.yangide.core.dom.IdentitySchemaNode;
import com.cisco.yangide.core.dom.Module;
import com.cisco.yangide.core.dom.ModuleImport;
import com.cisco.yangide.core.dom.SimpleNode;
import com.cisco.yangide.core.dom.SubModule;
import com.cisco.yangide.core.dom.SubModuleInclude;
import com.cisco.yangide.core.dom.TypeDefinition;
Expand Down Expand Up @@ -180,7 +181,8 @@ public static boolean isIndirectRename(ASTNode node) {
*/
public static ASTNamedNode[] findLocalReferences(Module module, final ASTNamedNode node) {
final List<ASTNamedNode> nodes = new ArrayList<>();
final String name = node.getName();
final String name = node.getName();
final SimpleNode<String> modulePrefix = module.getPrefix();
module.accept(new ASTVisitor() {
@Override
public void preVisit(ASTNode n) {
Expand All @@ -193,7 +195,12 @@ public void preVisit(ASTNode n) {
} else if (nn instanceof TypeReference && ((TypeReference) nn).getType().getName().equals(name)) {
nodes.add(nn);
} else if (nn instanceof UsesNode && ((UsesNode) nn).getGrouping().getName().equals(name)) {
nodes.add(nn);
// We add the node if the prefix on the UsesNode matches the module prefix, either
// implicitly or explicitly.
if (((UsesNode) nn).getGrouping().getPrefix() != null && modulePrefix != null &&
((UsesNode) nn).getGrouping().getPrefix().equals(modulePrefix.getValue())) {
nodes.add(nn);
}
} else if (nn instanceof BaseReference && ((BaseReference) nn).getType().getName().equals(name)) {
nodes.add(nn);
} else if (nn instanceof ModuleImport && ((ModuleImport) nn).getName().equals(name)) {
Expand Down

0 comments on commit fd0f66c

Please sign in to comment.