mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEADEV-15674: honor '$' escapes in ant script
This commit is contained in:
@@ -64,6 +64,11 @@ public class AntHighlightingTest extends DaemonAnalyzerTestCase {
|
||||
doDoTest(true, false);
|
||||
}
|
||||
|
||||
public void testEscapedProperties() throws Exception {
|
||||
configureByFiles(null, new VirtualFile[]{getVirtualFile(BASE_PATH + "/" + getTestName(false) + ".xml")});
|
||||
doDoTest(true, false);
|
||||
}
|
||||
|
||||
public void testPropertiesFromFile() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@@ -238,12 +238,15 @@ public class AntProjectImpl extends AntStructuredElementImpl implements AntProje
|
||||
private void registerImportsDependentProperties(final String fileName) {
|
||||
int startProp = 0;
|
||||
while ((startProp = fileName.indexOf("${", startProp)) >= 0) {
|
||||
final int endProp = fileName.indexOf('}', startProp + 2);
|
||||
if (endProp > startProp + 2) {
|
||||
if (myImportsDependentProperties == null) {
|
||||
myImportsDependentProperties = new HashSet<String>();
|
||||
if (startProp == 0 || fileName.charAt(startProp - 1) != '$') {
|
||||
// if the '$' is not escaped
|
||||
final int endProp = fileName.indexOf('}', startProp + 2);
|
||||
if (endProp > startProp + 2) {
|
||||
if (myImportsDependentProperties == null) {
|
||||
myImportsDependentProperties = new HashSet<String>();
|
||||
}
|
||||
myImportsDependentProperties.add(fileName.substring(startProp + 2, endProp));
|
||||
}
|
||||
myImportsDependentProperties.add(fileName.substring(startProp + 2, endProp));
|
||||
}
|
||||
startProp += 2;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class AntStructuredElementImpl extends AntElementImpl implements AntStructuredElement {
|
||||
|
||||
@@ -45,6 +46,7 @@ public class AntStructuredElementImpl extends AntElementImpl implements AntStruc
|
||||
protected volatile boolean myInGettingChildren;
|
||||
@NonNls private static final String ANTLIB_NS_PREFIX = "antlib:";
|
||||
@NonNls private static final String ANTLIB_XML = "antlib.xml";
|
||||
private static final Pattern $$_PATTERN = Pattern.compile("\\$\\$");
|
||||
|
||||
public AntStructuredElementImpl(final AntElement parent, final XmlTag sourceElement, @NonNls final String nameElementAttribute) {
|
||||
super(parent, sourceElement);
|
||||
@@ -261,7 +263,7 @@ public class AntStructuredElementImpl extends AntElementImpl implements AntStruc
|
||||
}
|
||||
}
|
||||
else if (value.indexOf('$') < 0){
|
||||
return value;
|
||||
return value; // heuristics
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -409,6 +411,11 @@ public class AntStructuredElementImpl extends AntElementImpl implements AntStruc
|
||||
elementStack.add(this);
|
||||
int startProp = 0;
|
||||
while ((startProp = value.indexOf("${", startProp)) >= 0) {
|
||||
if (startProp > 0 && value.charAt(startProp - 1) == '$') {
|
||||
// the '$' is escaped
|
||||
startProp += 2;
|
||||
continue;
|
||||
}
|
||||
final int endProp = value.indexOf('}', startProp + 2);
|
||||
if (endProp <= startProp + 2) {
|
||||
startProp += 2;
|
||||
@@ -448,6 +455,9 @@ public class AntStructuredElementImpl extends AntElementImpl implements AntStruc
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value.indexOf("$$") >= 0) {
|
||||
return $$_PATTERN.matcher(value).replaceAll("\\$");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -73,6 +73,11 @@ public class AntPropertyReferenceProvider extends GenericReferenceProvider {
|
||||
int startIndex;
|
||||
int endIndex = -1;
|
||||
while ((startIndex = value.indexOf("${", endIndex + 1)) > endIndex) {
|
||||
if (startIndex > 0 && value.charAt(startIndex - 1) == '$') {
|
||||
// the '$' is escaped
|
||||
endIndex = startIndex + 1;
|
||||
continue;
|
||||
}
|
||||
startIndex += 2;
|
||||
endIndex = startIndex;
|
||||
int nestedBrackets = 0;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<project default="xxx" basedir=".">
|
||||
<property name="prop1" value="${<error>aaa</error>}"/>
|
||||
<property name="prop2" value="$${bbb}"/>
|
||||
<target name="xxx" />
|
||||
</project>
|
||||
Reference in New Issue
Block a user