diff --git a/python/openapi/src/com/jetbrains/python/psi/PyStringLiteralFileReferenceSet.java b/python/openapi/src/com/jetbrains/python/psi/PyStringLiteralFileReferenceSet.java index 96a3dcb37e9e..fdd93c3733c1 100644 --- a/python/openapi/src/com/jetbrains/python/psi/PyStringLiteralFileReferenceSet.java +++ b/python/openapi/src/com/jetbrains/python/psi/PyStringLiteralFileReferenceSet.java @@ -40,6 +40,7 @@ public class PyStringLiteralFileReferenceSet extends RootFileReferenceSet { @Override protected void reparse() { + //noinspection ConstantConditions if (myStringLiteralExpression != null) { MyTextRangeConsumer textRangeConsumer = new MyTextRangeConsumer(this); @@ -69,9 +70,7 @@ public class PyStringLiteralFileReferenceSet extends RootFileReferenceSet { @Override public boolean process(int startOffset, int endOffset, String value) { if ("\\".equals(value) || "/".equals(value)) { - if (myStartOffset != -1) { - addReference(startOffset); - } + addReference(startOffset); } else { if (myStartOffset == -1) { @@ -84,15 +83,18 @@ public class PyStringLiteralFileReferenceSet extends RootFileReferenceSet { } private void addReference(int startOffset) { - final FileReference ref = myFileReferenceSet.createFileReference( - new TextRange(myStartOffset, startOffset), - myIndex++, - myItem.toString()); - myReferenceList.add(ref); - myStartOffset = -1; - myItem.setLength(0); + if (myStartOffset != -1) { + final FileReference ref = myFileReferenceSet.createFileReference( + new TextRange(myStartOffset, startOffset), + myIndex++, + myItem.toString()); + myReferenceList.add(ref); + myStartOffset = -1; + myItem.setLength(0); + } } + public void finish() { addReference(myEndOffset); } diff --git a/python/src/com/jetbrains/python/psi/impl/PyPathEvaluator.java b/python/src/com/jetbrains/python/psi/impl/PyPathEvaluator.java index 2adb08df2c81..3b0acc5cd7f2 100644 --- a/python/src/com/jetbrains/python/psi/impl/PyPathEvaluator.java +++ b/python/src/com/jetbrains/python/psi/impl/PyPathEvaluator.java @@ -28,7 +28,7 @@ public class PyPathEvaluator { } @Nullable - public static String evaluate(PyExpression expr, String path) { + public static String evaluate(PyExpression expr, String containingFilePath) { if (expr == null) { return null; } @@ -36,27 +36,15 @@ public class PyPathEvaluator { final PyCallExpression call = (PyCallExpression)expr; final PyExpression[] args = call.getArguments(); if (call.isCalleeText(PyNames.DIRNAME) && args.length == 1) { - String argValue = evaluate(args[0], path); + String argValue = evaluate(args[0], containingFilePath); return argValue == null ? null : new File(argValue).getParent(); } else if (call.isCalleeText(PyNames.JOIN) && args.length >= 1) { - String result = null; - for (int i = 0; i