summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-08-19 22:27:03 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-08-19 21:25:05 +0000
commit4ca751c002784c4bfd349cc5240b045b62277c80 (patch)
treedfc17b31990e2429535609b85f6d080c4fa0d9fe /java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
parent890d9a2952301682ffecaed4495f5f65c84c3642 (diff)
parent060e58b3afea3ea39f5ba1cb5a443ca3ebda28c8 (diff)
downloadidea-4ca751c002784c4bfd349cc5240b045b62277c80.tar.gz
Merge "Merge remote-tracking branch 'aosp/upstream-master' into merge"
Diffstat (limited to 'java/java-tests/testSrc/com/intellij/find/FindManagerTest.java')
-rw-r--r--java/java-tests/testSrc/com/intellij/find/FindManagerTest.java47
1 files changed, 42 insertions, 5 deletions
diff --git a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
index 92caad03d8ef..f83d836bb55a 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindManagerTest.java
@@ -579,7 +579,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String text = "/** done done done */";
- findModel.setInCommentsOnly(true);
+ findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text);
findModel.setRegularExpressions(true);
@@ -592,7 +592,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
String prefix = "/*";
String text = prefix + "done*/";
- findModel.setInCommentsOnly(true);
+ findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
@@ -615,8 +615,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
FindModel findModel = FindManagerTestUtils.configureFindModel("^done$");
findModel.setRegularExpressions(true);
- findModel.setInStringLiteralsOnly(true);
- findModel.setInCommentsOnly(false);
+ findModel.setSearchContext(FindModel.SearchContext.IN_STRING_LITERALS);
String text = "\"done\"; 'done'; 'done' \"done2\"";
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
@@ -633,7 +632,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
String text = "/** do ne do ne do ne */";
- findModel.setInCommentsOnly(true);
+ findModel.setSearchContext(FindModel.SearchContext.IN_COMMENTS);
FindManagerTestUtils.runFindForwardAndBackward(myFindManager, findModel, text, "java");
}
@@ -651,4 +650,42 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
findModel.setWholeWordsOnly(true);
assertSize(1, findUsages(findModel));
}
+
+ public void testFindExceptComments() {
+ FindModel findModel = FindManagerTestUtils.configureFindModel("done");
+
+ String prefix = "/*";
+ String text = prefix + "done*/done";
+
+ findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
+ LightVirtualFile file = new LightVirtualFile("A.java", text);
+
+ FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
+ assertTrue(findResult.isStringFound());
+ assertTrue(findResult.getStartOffset() > prefix.length());
+
+ findModel.setRegularExpressions(true);
+ findResult = myFindManager.findString(text, prefix.length(), findModel, file);
+ assertTrue(findResult.isStringFound());
+ assertTrue(findResult.getStartOffset() > prefix.length());
+ }
+
+ public void testFindExceptLiterals() {
+ FindModel findModel = FindManagerTestUtils.configureFindModel("done");
+
+ String prefix = "\"";
+ String text = prefix + "done\"done";
+
+ findModel.setSearchContext(FindModel.SearchContext.EXCEPT_STRING_LITERALS);
+ LightVirtualFile file = new LightVirtualFile("A.java", text);
+
+ FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
+ assertTrue(findResult.isStringFound());
+ assertTrue(findResult.getStartOffset() > prefix.length());
+
+ findModel.setRegularExpressions(true);
+ findResult = myFindManager.findString(text, prefix.length(), findModel, file);
+ assertTrue(findResult.isStringFound());
+ assertTrue(findResult.getStartOffset() > prefix.length());
+ }
}