mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
If SOE encountered when do reg exp matching then ignore the exception and return result (temp fix for IDEA-150928)
This commit is contained in:
@@ -909,6 +909,18 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
|
||||
assertTrue(condition.value("makefile"));
|
||||
}
|
||||
|
||||
public void testRegExpSOEWhenMatch() throws InterruptedException {
|
||||
String text = "package com.intellij.demo;\n" +
|
||||
"\n";
|
||||
for(int i = 0; i < 10; ++i) text += text;
|
||||
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel(";((?:\\n|.)*export default )(?:DS.Model)(.extend((?:\\n|.)*assets: DS.attr(?:\\n|.)*});)");
|
||||
findModel.setRegularExpressions(true);
|
||||
|
||||
FindResult findResult = myFindManager.findString(text, 0, findModel, null);
|
||||
assertTrue(!findResult.isStringFound());
|
||||
}
|
||||
|
||||
public void testRegExpSearchDoesCheckCancelled() throws InterruptedException {
|
||||
String text = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
FindModel findModel = FindManagerTestUtils.configureFindModel("(x+x+)+y");
|
||||
|
||||
@@ -777,25 +777,29 @@ public class FindManagerImpl extends FindManager {
|
||||
if (matcher == null) {
|
||||
return NOT_FOUND_RESULT;
|
||||
}
|
||||
if (model.isForward()){
|
||||
if (matcher.find(startOffset)) {
|
||||
if (matcher.end() <= text.length()) {
|
||||
return new FindResultImpl(matcher.start(), matcher.end());
|
||||
try {
|
||||
if (model.isForward()) {
|
||||
if (matcher.find(startOffset)) {
|
||||
if (matcher.end() <= text.length()) {
|
||||
return new FindResultImpl(matcher.start(), matcher.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
return NOT_FOUND_RESULT;
|
||||
}
|
||||
else {
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
while(matcher.find() && matcher.end() < startOffset){
|
||||
start = matcher.start();
|
||||
end = matcher.end();
|
||||
}
|
||||
if (start < 0){
|
||||
return NOT_FOUND_RESULT;
|
||||
}
|
||||
return new FindResultImpl(start, end);
|
||||
else {
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
while (matcher.find() && matcher.end() < startOffset) {
|
||||
start = matcher.start();
|
||||
end = matcher.end();
|
||||
}
|
||||
if (start < 0) {
|
||||
return NOT_FOUND_RESULT;
|
||||
}
|
||||
return new FindResultImpl(start, end);
|
||||
}
|
||||
} catch (StackOverflowError soe) {
|
||||
return NOT_FOUND_RESULT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user