use of com.intellij.psi.PsiModifierList in project intellij-community by JetBrains.
the class GrMemberSelectionTable method setVisibilityIcon.
@Override
protected void setVisibilityIcon(GrMemberInfo memberInfo, RowIcon icon) {
PsiMember member = memberInfo.getMember();
PsiModifierList modifiers = member != null ? member.getModifierList() : null;
if (modifiers != null) {
VisibilityIcons.setVisibilityIcon(modifiers, icon);
} else {
icon.setIcon(IconUtil.getEmptyIcon(true), VISIBILITY_ICON_POSITION);
}
}
use of com.intellij.psi.PsiModifierList in project kotlin by JetBrains.
the class LightClassAnnotationsTest method doTest.
private void doTest(@NotNull String fqName) {
PsiClass psiClass = finder.findClass(fqName, GlobalSearchScope.allScope(getProject()));
if (!(psiClass instanceof KtLightClass)) {
throw new IllegalStateException("Not a light class: " + psiClass + " (" + fqName + ")");
}
PsiModifierList modifierList = psiClass.getModifierList();
assert modifierList != null : "No modifier list for " + psiClass.getText();
StringBuilder sb = new StringBuilder();
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
sb.append(annotation.getText()).append("\n");
}
KotlinTestUtils.assertEqualsToFile(new File(testDir, getTestName(false) + ".annotations.txt"), sb.toString());
}
use of com.intellij.psi.PsiModifierList in project smali by JesusFreke.
the class SmalideaMethod method getAccessFlags.
@Override
public int getAccessFlags() {
if (psiMethod instanceof SmaliMethod) {
return ((SmaliMethod) psiMethod).getModifierList().getAccessFlags();
} else {
int flags = 0;
PsiModifierList modifierList = psiMethod.getModifierList();
if (modifierList.hasModifierProperty("public")) {
flags |= AccessFlags.PUBLIC.getValue();
} else if (modifierList.hasModifierProperty("protected")) {
flags |= AccessFlags.PROTECTED.getValue();
} else if (modifierList.hasModifierProperty("private")) {
flags |= AccessFlags.PRIVATE.getValue();
}
if (modifierList.hasModifierProperty("static")) {
flags |= AccessFlags.STATIC.getValue();
}
if (modifierList.hasModifierProperty("final")) {
flags |= AccessFlags.FINAL.getValue();
}
boolean isNative = false;
if (modifierList.hasModifierProperty("native")) {
flags |= AccessFlags.NATIVE.getValue();
isNative = true;
}
if (modifierList.hasModifierProperty("synchronized")) {
if (isNative) {
flags |= AccessFlags.SYNCHRONIZED.getValue();
} else {
flags |= AccessFlags.DECLARED_SYNCHRONIZED.getValue();
}
}
if (psiMethod.isVarArgs()) {
flags |= AccessFlags.VARARGS.getValue();
}
if (modifierList.hasModifierProperty("abstract")) {
flags |= AccessFlags.ABSTRACT.getValue();
}
if (modifierList.hasModifierProperty("strictfp")) {
flags |= AccessFlags.STRICTFP.getValue();
}
if (psiMethod.isConstructor()) {
flags |= AccessFlags.CONSTRUCTOR.getValue();
}
return flags;
}
}
use of com.intellij.psi.PsiModifierList in project intellij-community by JetBrains.
the class VisibilityListener method perform.
/**
* to be performed in write action
*/
public void perform(final PsiVariable variable) {
ApplicationManager.getApplication().assertWriteAccessAllowed();
final Document document = myEditor.getDocument();
LOG.assertTrue(variable != null);
final PsiModifierList modifierList = variable.getModifierList();
LOG.assertTrue(modifierList != null);
int textOffset = modifierList.getTextOffset();
final String modifierListText = modifierList.getText();
int length = PsiModifier.PUBLIC.length();
int idx = modifierListText.indexOf(PsiModifier.PUBLIC);
if (idx == -1) {
idx = modifierListText.indexOf(PsiModifier.PROTECTED);
length = PsiModifier.PROTECTED.length();
}
if (idx == -1) {
idx = modifierListText.indexOf(PsiModifier.PRIVATE);
length = PsiModifier.PRIVATE.length();
}
String visibility = getVisibility();
if (visibility == PsiModifier.PACKAGE_LOCAL) {
visibility = "";
}
final boolean wasPackageLocal = idx == -1;
final boolean isPackageLocal = visibility.isEmpty();
final int startOffset = textOffset + (wasPackageLocal ? 0 : idx);
final int endOffset;
if (wasPackageLocal) {
endOffset = startOffset;
} else {
endOffset = textOffset + length + (isPackageLocal ? 1 : 0);
}
final String finalVisibility = visibility + (wasPackageLocal ? " " : "");
Runnable runnable = () -> document.replaceString(startOffset, endOffset, finalVisibility);
final LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myEditor);
if (lookup != null) {
lookup.performGuardedChange(runnable);
} else {
runnable.run();
}
}
use of com.intellij.psi.PsiModifierList in project intellij-community by JetBrains.
the class FieldAnnotationChecker method checkApplicability.
@Override
public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
final String qname = annotation.getQualifiedName();
if (!GroovyCommonClassNames.GROOVY_TRANSFORM_FIELD.equals(qname))
return false;
checkScriptField(holder, annotation);
PsiElement annoParent = annotation.getParent();
PsiElement ownerToUse = annoParent instanceof PsiModifierList ? annoParent.getParent() : annoParent;
if (!(ownerToUse instanceof GrVariableDeclaration)) {
return false;
} else {
GrVariableDeclaration declaration = (GrVariableDeclaration) ownerToUse;
if (declaration.getVariables().length != 1 || !PsiUtil.isLocalVariable(declaration.getVariables()[0])) {
return false;
}
}
if (!GrAnnotationImpl.isAnnotationApplicableTo(annotation, PsiAnnotation.TargetType.LOCAL_VARIABLE)) {
GrCodeReferenceElement ref = annotation.getClassReference();
String target = JavaErrorMessages.message("annotation.target.LOCAL_VARIABLE");
String description = JavaErrorMessages.message("annotation.not.applicable", ref.getText(), target);
holder.createErrorAnnotation(ref, description);
}
return true;
}
Aggregations