use of com.intellij.psi.PsiClass in project android-parcelable-intellij-plugin by mcharmas.
the class ParcelableAction method update.
@Override
public void update(AnActionEvent e) {
PsiClass psiClass = getPsiClassFromContext(e);
e.getPresentation().setEnabled(psiClass != null && !psiClass.isEnum() && !psiClass.isInterface());
}
use of com.intellij.psi.PsiClass in project Main by SpartanRefactoring.
the class SpartanizerAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
PsiClass psiClass = getPsiClassFromContext(e);
if (psiClass == null)
logger.warn("Spartanization action retrieved null PSI class");
else {
logger.info("Spartanization action on\nPSI class '" + psiClass.getQualifiedName() + "'");
Spartanizer.spartanizeFileOnePass(psiClass.getContainingFile());
}
}
use of com.intellij.psi.PsiClass in project Main by SpartanRefactoring.
the class Class method replaceByRange.
@Override
public List<PsiElement> replaceByRange(List<PsiElement> elements, Map<Integer, List<PsiElement>> map, PsiRewrite r) {
PsiClass psiClass = az.classDeclaration(elements.get(0));
PsiClass innerAsClass = az.classDeclaration(inner);
innerAsClass.setName(psiClass.getName());
List<Encapsulator> methods = Arrays.stream(innerAsClass.getMethods()).map(m -> Pruning.prune(Encapsulator.buildTreeFromPsi(m), null)).collect(Collectors.toList());
List<Encapsulator> fields = Arrays.stream(innerAsClass.getFields()).map(f -> Pruning.prune(Encapsulator.buildTreeFromPsi(f), null)).collect(Collectors.toList());
List<Encapsulator> innerClasses = Arrays.stream(innerAsClass.getInnerClasses()).map(m -> Pruning.prune(Encapsulator.buildTreeFromPsi(m), null)).collect(Collectors.toList());
List<Encapsulator> prunedChildren = new LinkedList<>();
prunedChildren.addAll(methods);
prunedChildren.addAll(fields);
prunedChildren.addAll(innerClasses);
prunedChildren.forEach(c -> c.accept(n -> {
if (!n.isGeneric())
return;
GenericEncapsulator ge = az.generic(n);
ge.replaceByRange(map.get(ge.getId()), map, r);
}));
return Utils.wrapWithList(inner);
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class GroovyEditorTextProvider method getEditorText.
@Override
public TextWithImports getEditorText(PsiElement elementAtCaret) {
String result = "";
PsiElement element = findExpressionInner(elementAtCaret, true);
if (element != null) {
if (element instanceof GrReferenceExpression) {
final GrReferenceExpression reference = (GrReferenceExpression) element;
if (reference.getQualifier() == null) {
final PsiElement resolved = reference.resolve();
if (resolved instanceof PsiEnumConstant) {
final PsiEnumConstant enumConstant = (PsiEnumConstant) resolved;
final PsiClass enumClass = enumConstant.getContainingClass();
if (enumClass != null) {
result = enumClass.getName() + "." + enumConstant.getName();
}
}
}
}
if (result.isEmpty()) {
result = element.getText();
}
}
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, result);
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class GroovyScriptClassSearcher method findClass.
@Nullable
@Override
public PsiClass findClass(@NotNull PsiElement place) {
if (place.getLanguage() == GroovyLanguage.INSTANCE) {
PsiClass containingClass = PsiTreeUtil.getParentOfType(place, PsiClass.class, false);
while (containingClass instanceof PsiTypeParameter) {
containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class);
}
if (containingClass != null)
return containingClass;
PsiFile file = place.getContainingFile();
if (file instanceof GroovyFile && ((GroovyFile) file).isScript()) {
return ((GroovyFile) file).getScriptClass();
}
}
return null;
}
Aggregations