Finding usages (which have references) in text when plaint text occurrences are not searched.
This commit is contained in:
@@ -55,7 +55,7 @@ public data class UsagesSearchLocation(
|
|||||||
val inCode: Boolean = true,
|
val inCode: Boolean = true,
|
||||||
val inComments: Boolean = false,
|
val inComments: Boolean = false,
|
||||||
val inStrings: Boolean = false,
|
val inStrings: Boolean = false,
|
||||||
val inPlainText: Boolean = false
|
val inPlainText: Boolean = true
|
||||||
) {
|
) {
|
||||||
class object {
|
class object {
|
||||||
public val DEFAULT: UsagesSearchLocation = UsagesSearchLocation()
|
public val DEFAULT: UsagesSearchLocation = UsagesSearchLocation()
|
||||||
@@ -156,7 +156,7 @@ public class KotlinPsiSearchHelper(private val project: Project): PsiSearchHelpe
|
|||||||
public fun processFilesWithText(item: UsagesSearchRequestItem, consumer: Processor<PsiReference>): Boolean {
|
public fun processFilesWithText(item: UsagesSearchRequestItem, consumer: Processor<PsiReference>): Boolean {
|
||||||
return item.words.all { word ->
|
return item.words.all { word ->
|
||||||
val textProcessor = ResultTextProcessorImpl(item, consumer)
|
val textProcessor = ResultTextProcessorImpl(item, consumer)
|
||||||
processElementsWithWord(textProcessor, item.target.effectiveScope, word, UsageSearchContext.IN_CODE, true)
|
processElementsWithWord(textProcessor, item.target.effectiveScope, word, item.target.location.searchContext, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// PSI_ELEMENT: org.jetbrains.jet.lang.psi.JetClass
|
||||||
|
// OPTIONS: usages
|
||||||
|
package server
|
||||||
|
|
||||||
|
open class <caret>Server {
|
||||||
|
class object {
|
||||||
|
val NAME = "Server"
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun work() {
|
||||||
|
println("Server")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<foo bar="server.Server"></foo>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Unclassified usage (1: 18) <foo bar="server.Server"></foo>
|
||||||
@@ -75,6 +75,7 @@ public abstract class AbstractJetFindUsagesTest extends JetLightCodeInsightFixtu
|
|||||||
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
public FindUsagesOptions parse(@NotNull String text, @NotNull Project project) {
|
||||||
KotlinClassFindUsagesOptions options = new KotlinClassFindUsagesOptions(project);
|
KotlinClassFindUsagesOptions options = new KotlinClassFindUsagesOptions(project);
|
||||||
options.isUsages = false;
|
options.isUsages = false;
|
||||||
|
options.isSearchForTextOccurrences = false;
|
||||||
options.setSearchConstructorUsages(false);
|
options.setSearchConstructorUsages(false);
|
||||||
for (String s : InTextDirectivesUtils.findListWithPrefixes(text, "// OPTIONS: ")) {
|
for (String s : InTextDirectivesUtils.findListWithPrefixes(text, "// OPTIONS: ")) {
|
||||||
if (parseCommonOptions(options, s)) continue;
|
if (parseCommonOptions(options, s)) continue;
|
||||||
@@ -303,7 +304,7 @@ public abstract class AbstractJetFindUsagesTest extends JetLightCodeInsightFixtu
|
|||||||
if (!name.startsWith(prefix) || name.equals(mainFileName)) return false;
|
if (!name.startsWith(prefix) || name.equals(mainFileName)) return false;
|
||||||
|
|
||||||
String ext = name.substring(name.lastIndexOf('.') + 1);
|
String ext = name.substring(name.lastIndexOf('.') + 1);
|
||||||
return ext.equals("kt") || ext.equals("java");
|
return ext.equals("kt") || ext.equals("java") || ext.equals("xml");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -141,6 +141,12 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/findUsages/kotlin/findClassUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/findUsages/kotlin/findClassUsages"), Pattern.compile("^(.+)\\.0\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("classUsedInTextAsRef.0.kt")
|
||||||
|
public void testClassUsedInTextAsRef() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findClassUsages/classUsedInTextAsRef.0.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("javaClassAllUsages.0.kt")
|
@TestMetadata("javaClassAllUsages.0.kt")
|
||||||
public void testJavaClassAllUsages() throws Exception {
|
public void testJavaClassAllUsages() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findClassUsages/javaClassAllUsages.0.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/findClassUsages/javaClassAllUsages.0.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user