Skip to content

Commit

Permalink
[usage-view] sensible node name when scope is empty
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 842ef78b9513a07a67ac188e9ea307577f302fbd
  • Loading branch information
BasLeijdekkers authored and intellij-monorepo-bot committed Feb 3, 2024
1 parent 3cb47ac commit 0706bea
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.psi.usages;

import com.intellij.psi.PsiClass;
Expand Down Expand Up @@ -43,7 +43,7 @@ void bar()
assertNotNull(ref);
assertEquals("""
<root> (1)
Usages in (1)
Usages (1)
A (1)
bar() (1)
3{ foo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.usages.impl;

import com.intellij.find.FindManager;
Expand Down Expand Up @@ -230,7 +230,7 @@ public void testExcludeUsageMustExcludeChildrenAndParents() {

String text = new ExporterToTextFile(usageView, UsageViewSettings.getInstance()).getReportText();
assertEquals("""
Usages in (1 usage found)
Usages (1 usage found)
Unclassified (1 usage found)
light_idea_test_case (1 usage found)
(1 usage found)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.usages.impl;

import com.intellij.module.ModuleGroupTestsKt;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void testSimpleModule() throws Exception {
PsiFile file = myFixture.addFileToProject("main/A.txt", "hello");
assertUsageViewStructureEquals(new UsageInfo(file), """
<root> (1)
Non-code usages in (1)
Non-code usages (1)
main (1)
A.txt (1)
1hello
Expand All @@ -75,7 +75,7 @@ public void testModuleWithQualifiedName() throws Exception {
ModuleGroupTestsKt.runWithQualifiedModuleNamesEnabled(() -> {
assertUsageViewStructureEquals(new UsageInfo(file), """
<root> (1)
Non-code usages in (1)
Non-code usages (1)
xxx (1)
main (1)
A.txt (1)
Expand All @@ -93,7 +93,7 @@ public void testGroupByDirectoryStructureMustMaintainNestedDirectories() throws
PsiFile file2 = myFixture.addFileToProject("xxx.main/y/B.txt", "hello");
assertEquals("""
<root> (2)
Non-code usages in (2)
Non-code usages (2)
xxx.main (2)
x (1)
i1 (1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.usages.impl.rules;

import com.intellij.openapi.util.NlsContexts;
import com.intellij.openapi.util.NlsContexts.ListItem;
import com.intellij.openapi.util.NlsSafe;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.usageView.UsageInfo;
import com.intellij.usageView.UsageViewBundle;
Expand Down Expand Up @@ -120,13 +120,7 @@ public boolean isGroupingToggleable() {
}

@Nls
private static String buildText(String usages, String scope) {
@NlsSafe StringBuilder text = new StringBuilder(usages);
text.append(" ").append(UsageViewBundle.message("usage.view.results.node.scope.in"));

if (StringUtil.isNotEmpty(scope)) {
text.append(" ").append(scope);
}
return text.toString();
private static String buildText(@NlsContexts.ListItem String usages, @Nls String scope) {
return StringUtil.isEmpty(scope) ? usages : UsageViewBundle.message("usage.view.results.node.scope.in", usages, scope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ usage.view.results.node.non.code=In Strings, Comments, and Text
usage.view.results.node.dynamic=Dynamic
# 0 - one of usage.view.results.node.* strings; 1 - text obtained from plugins, e.g. "References to be updated"
usage.view.results.node.prefix=[{0}] {1}
usage.view.results.node.scope.in=in
usage.view.results.node.scope.in={0} in {1}
references.to.be.changed=References to be changed {0}
occurrences.found.in.comments.strings.and.non.java.files=Occurrences found in comments, strings and non-code files
occurrences.found.in.comments.strings.non.java.files.and.generated.code=Occurrences found in comments, strings, non-code files and generated code
Expand Down

0 comments on commit 0706bea

Please sign in to comment.