mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
i18n: ensure external annotations on packages are supported (IDEA-239099)
GitOrigin-RevId: 1bd86ebf08223e9ae8b91f72ea32c91f64e18a41
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1efacbe394
commit
6e7b5fd2d8
+5
@@ -0,0 +1,5 @@
|
||||
<root>
|
||||
<item name='i18n'>
|
||||
<annotation name='org.jetbrains.annotations.Nls'/>
|
||||
</item>
|
||||
</root>
|
||||
@@ -0,0 +1,9 @@
|
||||
package i18n;
|
||||
public class Foo {
|
||||
public Foo(String s) {
|
||||
}
|
||||
|
||||
{
|
||||
new Foo(<warning descr="Hardcoded string literal: \"abc de\"">"abc de"</warning>);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.intellij.java.codeInsight;
|
||||
|
||||
import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInspection.i18n.I18nInspection;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -78,6 +79,15 @@ public class ExternalAnnotationsTest extends UsefulTestCase {
|
||||
true);
|
||||
}
|
||||
|
||||
public void testHardcodedStringLiteralWithExternalPackageAnnotation() {
|
||||
myFixture.configureByFiles("src/i18n/Foo.java", "content/anno/i18n/annotations.xml");
|
||||
I18nInspection inspection = new I18nInspection();
|
||||
inspection.setIgnoreForAllButNls(true);
|
||||
myFixture.enableInspections(inspection);
|
||||
|
||||
myFixture.testHighlighting(true, false, false, "src/i18n/Foo.java");
|
||||
}
|
||||
|
||||
public void testBringToSrc() {
|
||||
myFixture.configureByFiles("src/toSrc/Foo.java", "content/anno/toSrc/annotations.xml");
|
||||
|
||||
|
||||
@@ -486,7 +486,15 @@ public abstract class NlsInfo {
|
||||
String packageName = ((PsiClassOwner)containingFile).getPackageName();
|
||||
PsiPackage aPackage = JavaPsiFacade.getInstance(method.getProject()).findPackage(packageName);
|
||||
if (aPackage != null) {
|
||||
return fromAnnotationOwner(aPackage.getAnnotationList());
|
||||
NlsInfo info = fromAnnotationOwner(aPackage.getAnnotationList());
|
||||
if (info != Unspecified.UNKNOWN) {
|
||||
return info;
|
||||
}
|
||||
|
||||
PsiAnnotation annotation = AnnotationUtil.findAnnotation(aPackage, ANNOTATION_NAMES, false);
|
||||
if (annotation != null) {
|
||||
return fromAnnotation(annotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Unspecified.UNKNOWN;
|
||||
|
||||
Reference in New Issue
Block a user