use of com.intellij.psi.PsiModifierListOwner in project kotlin by JetBrains.
the class PsiBasedExternalAnnotationResolver method findExternalAnnotation.
@Nullable
@Override
public JavaAnnotation findExternalAnnotation(@NotNull JavaAnnotationOwner owner, @NotNull FqName fqName) {
if (owner instanceof JavaModifierListOwnerImpl) {
PsiModifierListOwner psiOwner = ((JavaModifierListOwnerImpl) owner).getPsi();
PsiAnnotation psiAnnotation = ExternalAnnotationsManager.getInstance(psiOwner.getProject()).findExternalAnnotation(psiOwner, fqName.asString());
return psiAnnotation == null ? null : new JavaAnnotationImpl(psiAnnotation);
}
return null;
}
use of com.intellij.psi.PsiModifierListOwner in project smali by JesusFreke.
the class SmaliClassModifierListTest method testNoAnnotation.
public void testNoAnnotation() {
final SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", ".class public final Lmy/pkg/blah;\n" + ".super Ljava/lang/Object;");
SmaliClass smaliClass = file.getPsiClass();
SmaliModifierList modifierList = smaliClass.getModifierList();
// Ensures that the parent of the modifier list is a PsiModifierListOwner
// e.g. for code like JavaSuppressionUtil.getInspectionIdsSuppressedInAnnotation,
// which assumes the parent is a PsiModifierListOwner
Assert.assertTrue(modifierList.getParent() instanceof PsiModifierListOwner);
Assert.assertEquals(0, modifierList.getAnnotations().length);
Assert.assertEquals(0, modifierList.getApplicableAnnotations().length);
}
use of com.intellij.psi.PsiModifierListOwner in project intellij-community by JetBrains.
the class CompilerIconLayerProvider method getLayerIcon.
@Override
public Icon getLayerIcon(@NotNull Iconable element, boolean isLocked) {
VirtualFile vFile = null;
Project project = null;
if (element instanceof PsiModifierListOwner) {
project = ((PsiModifierListOwner) element).getProject();
final PsiFile containingFile = ((PsiModifierListOwner) element).getContainingFile();
vFile = containingFile == null ? null : containingFile.getVirtualFile();
} else if (element instanceof PsiDirectory) {
project = ((PsiDirectory) element).getProject();
vFile = ((PsiDirectory) element).getVirtualFile();
}
if (vFile != null && isExcluded(vFile, project)) {
return PlatformIcons.EXCLUDED_FROM_COMPILE_ICON;
}
return null;
}
use of com.intellij.psi.PsiModifierListOwner in project intellij-community by JetBrains.
the class LiteralExpressionTokenizer method tokenize.
@Override
public void tokenize(@NotNull PsiLiteralExpression element, TokenConsumer consumer) {
PsiLiteralExpressionImpl literalExpression = (PsiLiteralExpressionImpl) element;
// not a string literal
if (literalExpression.getLiteralElementType() != JavaTokenType.STRING_LITERAL)
return;
String text = literalExpression.getInnerText();
if (StringUtil.isEmpty(text) || text.length() <= 2) {
// optimisation to avoid expensive injection check
return;
}
if (InjectedLanguageUtil.hasInjections(literalExpression))
return;
final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
if (listOwner != null && AnnotationUtil.isAnnotated(listOwner, Collections.singleton(AnnotationUtil.NON_NLS), false, false)) {
return;
}
if (!text.contains("\\")) {
consumer.consumeToken(element, PlainTextSplitter.getInstance());
} else {
processTextWithEscapeSequences(element, text, consumer);
}
}
use of com.intellij.psi.PsiModifierListOwner in project intellij-community by JetBrains.
the class SuppressParameterFix method createSuppression.
@Override
protected void createSuppression(@NotNull Project project, @NotNull PsiElement element, @NotNull PsiElement cont) throws IncorrectOperationException {
PsiModifierListOwner container = (PsiModifierListOwner) cont;
final PsiModifierList modifierList = container.getModifierList();
if (modifierList != null) {
final String id = SuppressFix.getID(container, myAlternativeID);
JavaSuppressionUtil.addSuppressAnnotation(project, container, container, id != null ? id : myID);
}
}
Aggregations