diff --git a/src/main/java/org/raml/parser/tagresolver/ContextPath.java b/src/main/java/org/raml/parser/tagresolver/ContextPath.java index 211536bc..67fd2269 100644 --- a/src/main/java/org/raml/parser/tagresolver/ContextPath.java +++ b/src/main/java/org/raml/parser/tagresolver/ContextPath.java @@ -17,6 +17,7 @@ import static org.raml.parser.tagresolver.IncludeResolver.INCLUDE_APPLIED_TAG; +import java.io.File; import java.util.ArrayDeque; import java.util.Deque; @@ -70,7 +71,7 @@ public static String resolveAbsolutePath(String relativeFile, String parentPath) public String resolveAbsolutePath(String relativeFile) { - return resolveAbsolutePath(relativeFile, getPartentPath()); + return resolveAbsolutePath(relativeFile, getParentPath()); } /** @@ -91,25 +92,25 @@ public String resolveRelativePath(Tag tag) { throw new IllegalArgumentException("Tag must be an include applied"); } - String partentPath = getPartentPath(); + String parentPath = getParentPath(); String includePath = new IncludeInfo(tag).getIncludeName(); - if (includePath.startsWith(partentPath)) + if (includePath.startsWith(parentPath)) { - includePath = includePath.substring(partentPath.length()); + includePath = includePath.substring(parentPath.length()); } return includePath; } - public static String getPartentPath(String path) + public static String getParentPath(String path) { - int idx = path.lastIndexOf("/") + 1; + int idx = path.lastIndexOf(File.separatorChar) + 1; return path.substring(0, idx); } - private String getPartentPath() + private String getParentPath() { - return getPartentPath(includeStack.peek().getIncludeName()); + return getParentPath(includeStack.peek().getIncludeName()); } public IncludeInfo peek() @@ -129,7 +130,7 @@ public void push(IncludeInfo includeInfo) public void push(ScalarNode node) { - push(new IncludeInfo(node, getPartentPath())); + push(new IncludeInfo(node, getParentPath())); } public void push(Tag tag) diff --git a/src/main/java/org/raml/parser/visitor/TemplateResolver.java b/src/main/java/org/raml/parser/visitor/TemplateResolver.java index b2b1d58b..5855ce20 100644 --- a/src/main/java/org/raml/parser/visitor/TemplateResolver.java +++ b/src/main/java/org/raml/parser/visitor/TemplateResolver.java @@ -214,7 +214,7 @@ private Node resolveInclude(Node node, Tag tag) // parent include applied tag path ScalarNode scalarNode = (ScalarNode) node; String parentPath = includeResolver.getContextPath().resolveRelativePath(tag); - String includePathRecalculated = ContextPath.getPartentPath(parentPath) + scalarNode.getValue(); + String includePathRecalculated = ContextPath.getParentPath(parentPath) + scalarNode.getValue(); node = new ScalarNode(scalarNode.getTag(), includePathRecalculated, node.getStartMark(), node.getEndMark(), scalarNode.getStyle()); } return includeResolver.resolve(node, resourceLoader, nodeNandler);