goto class/file: support more line number denotations (IDEA-137806, IDEA-111332, IDEA-151405)

This commit is contained in:
peter
2016-02-08 20:51:22 +01:00
parent 278c7a09b3
commit f166e96420
2 changed files with 16 additions and 10 deletions
@@ -215,6 +215,15 @@ class Intf {
assert getPopupElements(new GotoClassModel2(project), 'Bar:[2,3]') == [c]
}
public void "test custom line suffixes"() {
def file = myFixture.addFileToProject("Bar.txt", "")
def model = new GotoFileModel(project)
assert getPopupElements(model, 'Bar:2') == [file]
assert getPopupElements(model, 'Bar(2)') == [file]
assert getPopupElements(model, 'Bar on line 2') == [file]
assert getPopupElements(model, 'Bar at line 2') == [file]
}
public void "test dollar"() {
def bar = myFixture.addClass("package foo; class Bar { class Foo {} }")
def foo = ApplicationManager.application.runReadAction( { bar.innerClasses[0] } as Computable)
@@ -342,11 +342,12 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
return newPopup;
}
private static final Pattern patternToDetectLinesAndColumns = Pattern.compile("(" +
"(?:\\w:)?" + // absolute path start on Windows
"[^:]+" +
")" + // main part before line/column
"(?::|@|,|)\\[?(\\d+)?(?:(?:\\D)(\\d+)?)?\\]?");
private static final Pattern patternToDetectLinesAndColumns = Pattern.compile("(.+?)" + // name, non-greedy matching
"(?::|@|,| on line | at line |)?" + // separator
"[(\\[]?" + // possible opening paren/brace
"(\\d+)?(?:(?:\\D)(\\d+)?)?" + // line + column
"[)\\]]?" // possible closing paren/brace
);
public static final Pattern patternToDetectAnonymousClasses = Pattern.compile("([\\.\\w]+)((\\$[\\d]+)*(\\$)?)");
private static final Pattern patternToDetectMembers = Pattern.compile("(.+)(#)(.*)");
@@ -358,11 +359,7 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
public static String getTransformedPattern(String pattern, ChooseByNameModel model) {
Pattern regex = null;
if (pattern.indexOf(':') != -1 ||
pattern.indexOf(',') != -1 ||
pattern.indexOf(';') != -1 ||
//pattern.indexOf('#') != -1 ||
pattern.indexOf('@') != -1) { // quick test if reg exp should be used
if (StringUtil.containsAnyChar(pattern, ":,;@[(") || pattern.contains(" line ")) { // quick test if reg exp should be used
regex = patternToDetectLinesAndColumns;
}