use of com.intellij.psi.PsiModifierList in project android by JetBrains.
the class AndroidLayoutXmlTagNameProvider method isDeclarationDeprecated.
private static boolean isDeclarationDeprecated(@Nullable PsiElement declaration) {
if (!(declaration instanceof PsiClass)) {
return false;
}
final PsiClass aClass = (PsiClass) declaration;
final PsiModifierList modifierList = aClass.getModifierList();
if (modifierList == null) {
return false;
}
return modifierList.findAnnotation("java.lang.Deprecated") != null;
}
use of com.intellij.psi.PsiModifierList in project android by JetBrains.
the class AndroidActivityAliasCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
if (parameters.getCompletionType() != CompletionType.BASIC) {
return;
}
final Editor editor = parameters.getEditor();
LaunchOptionConfigurableContext context = editor.getUserData(LaunchOptionConfigurableContext.KEY);
if (context == null) {
return;
}
final Module module = context.getModule();
if (module == null) {
return;
}
final AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null) {
return;
}
final String prefix = parameters.getEditor().getDocument().getText().substring(0, parameters.getOffset());
result = result.withPrefixMatcher(prefix);
final PsiClass activityClass = JavaPsiFacade.getInstance(module.getProject()).findClass(AndroidUtils.ACTIVITY_BASE_CLASS_NAME, module.getModuleWithDependenciesAndLibrariesScope(false));
if (activityClass != null) {
final CompletionResultSet finalResult = result;
ClassInheritorsSearch.search(activityClass, module.getModuleWithDependenciesScope(), true, true, false).forEach(new Processor<PsiClass>() {
@Override
public boolean process(PsiClass psiClass) {
final PsiModifierList modifierList = psiClass.getModifierList();
if (modifierList != null && modifierList.hasModifierProperty(PsiModifier.PUBLIC) && !modifierList.hasModifierProperty(PsiModifier.ABSTRACT)) {
final String qName = psiClass.getQualifiedName();
if (qName != null && qName.length() > 0) {
finalResult.addElement(JavaLookupElementBuilder.forClass(psiClass, qName));
}
}
return true;
}
});
}
final Set<String> aliases = collectActivityAliases(facet);
if (aliases.size() > 0) {
for (String alias : aliases) {
LookupElementBuilder element = LookupElementBuilder.create(alias);
final String shortName = StringUtilRt.getShortName(alias);
if (!shortName.equals(alias)) {
element = element.withLookupString(shortName);
}
result.addElement(element);
}
}
result.stopHere();
}
use of com.intellij.psi.PsiModifierList in project android by JetBrains.
the class AndroidClassBrowserBase method showDialog.
@Override
protected String showDialog() {
Project project = getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
Module module = myModuleSelector.getModule();
if (module == null) {
Messages.showErrorDialog(project, ExecutionBundle.message("module.not.specified.error.text"), CommonBundle.getErrorTitle());
return null;
}
GlobalSearchScope scope = myIncludeLibraryClasses ? module.getModuleWithDependenciesAndLibrariesScope(true) : module.getModuleWithDependenciesScope();
PsiClass initialSelection = facade.findClass(getText(), scope);
TreeClassChooser chooser = createTreeClassChooser(project, scope, initialSelection, new ClassFilter() {
@Override
public boolean isAccepted(PsiClass aClass) {
if (aClass.isInterface())
return false;
final PsiModifierList modifierList = aClass.getModifierList();
return modifierList == null || !modifierList.hasModifierProperty(PsiModifier.ABSTRACT);
}
});
if (chooser == null)
return null;
chooser.showDialog();
PsiClass selClass = chooser.getSelected();
return selClass != null ? selClass.getQualifiedName() : null;
}
use of com.intellij.psi.PsiModifierList in project intellij-community by JetBrains.
the class ChangeModifierFix method doFix.
@Override
public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
final PsiElement element = descriptor.getPsiElement();
final PsiModifierListOwner modifierListOwner = PsiTreeUtil.getParentOfType(element, PsiModifierListOwner.class);
if (modifierListOwner == null) {
return;
}
final PsiModifierList modifiers = modifierListOwner.getModifierList();
if (modifiers == null) {
return;
}
modifiers.setModifierProperty(modifierText, true);
}
use of com.intellij.psi.PsiModifierList in project intellij-community by JetBrains.
the class SuperTypeGroup method getAccessLevel.
@Override
public int getAccessLevel() {
final PsiClass superClass = getSuperClass();
PsiModifierList modifierList = superClass == null ? null : superClass.getModifierList();
return modifierList == null ? PsiUtil.ACCESS_LEVEL_PUBLIC : PsiUtil.getAccessLevel(modifierList);
}
Aggregations