Skip to content

Commit

Permalink
Merge pull request #54 from davidmichaelkarr/RenameSupport-fix-for-pr…
Browse files Browse the repository at this point in the history
…efix-checking

Fix for #48 .
  • Loading branch information
haiodo committed Nov 25, 2015
2 parents 76ef998 + e242c46 commit 7b7ca40
Showing 1 changed file with 8 additions and 1 deletion.
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 @@ -181,6 +182,7 @@ 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 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 7b7ca40

Please sign in to comment.