use of com.intellij.psi.PsiClass in project GsonFormat by zzz40500.
the class DataWriter method run.
@Override
protected void run() {
if (targetClass == null) {
return;
}
generateClassList.clear();
new ClassProcessor(factory, cls).generate(targetClass, new IProcessor() {
@Override
public void onStarProcess(ClassEntity classEntity, PsiElementFactory factory, PsiClass cls) {
generateClassList.add(cls.getQualifiedName());
}
@Override
public void onEndProcess(ClassEntity classEntity, PsiElementFactory factory, PsiClass cls) {
}
@Override
public void onStartGenerateClass(PsiElementFactory factory, ClassEntity classEntity, PsiClass parentClass) {
}
@Override
public void onEndGenerateClass(PsiElementFactory factory, ClassEntity classEntity, PsiClass parentClass, PsiClass generateClass) {
generateClassList.add(generateClass.getQualifiedName());
}
});
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class GutterIconTooltipHelper method composeText.
public static String composeText(@NotNull Iterable<? extends PsiElement> elements, @NotNull String start, @NotNull String pattern, @NotNull String postfix) {
@NonNls StringBuilder result = new StringBuilder();
result.append("<html><body>");
result.append(start);
Set<String> names = new LinkedHashSet<>();
for (PsiElement element : elements) {
String descr = "";
if (element instanceof PsiClass) {
String className = ClassPresentationUtil.getNameForClass((PsiClass) element, true);
descr = MessageFormat.format(pattern, className);
} else if (element instanceof PsiMethod) {
String methodName = ((PsiMethod) element).getName();
PsiClass aClass = ((PsiMethod) element).getContainingClass();
String className = aClass == null ? "" : ClassPresentationUtil.getNameForClass(aClass, true);
descr = MessageFormat.format(pattern, methodName, className);
} else if (element instanceof PsiFile) {
descr = MessageFormat.format(pattern, ((PsiFile) element).getName());
}
names.add(descr);
}
@NonNls String sep = "";
for (String name : names) {
result.append(sep);
sep = "<br>";
result.append(name);
}
result.append(postfix);
result.append("</body></html>");
return result.toString();
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class FQNameCellRenderer method getListCellRendererComponent.
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
clear();
if (value instanceof PsiClass) {
PsiClass aClass = (PsiClass) value;
setIcon(aClass.getIcon(0));
if (aClass.getQualifiedName() != null) {
SimpleTextAttributes attributes;
if (aClass.isDeprecated()) {
attributes = new SimpleTextAttributes(SimpleTextAttributes.STYLE_STRIKEOUT, null);
} else {
attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
append(aClass.getQualifiedName(), attributes);
}
} else {
LOG.assertTrue(value instanceof String);
String qName = (String) value;
append(qName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
setIcon(AllIcons.Nodes.Static);
}
setFont(FONT);
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
return this;
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class SuperMethodWarningUtil method checkSuperMethod.
public static void checkSuperMethod(@NotNull PsiMethod method, @NotNull String actionString, @NotNull final PsiElementProcessor<PsiMethod> processor, @NotNull Editor editor) {
PsiClass aClass = method.getContainingClass();
if (aClass == null) {
processor.execute(method);
return;
}
PsiMethod superMethod = method.findDeepestSuperMethod();
if (superMethod == null) {
processor.execute(method);
return;
}
final PsiClass containingClass = superMethod.getContainingClass();
if (containingClass == null) {
processor.execute(method);
return;
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
processor.execute(superMethod);
return;
}
final PsiMethod[] methods = { superMethod, method };
final String renameBase = actionString + " base method";
final String renameCurrent = actionString + " only current method";
final JBList list = new JBList(renameBase, renameCurrent);
JBPopupFactory.getInstance().createListPopupBuilder(list).setTitle(method.getName() + (containingClass.isInterface() && !aClass.isInterface() ? " implements" : " overrides") + " method of " + SymbolPresentationUtil.getSymbolPresentableText(containingClass)).setMovable(false).setResizable(false).setRequestFocus(true).setItemChoosenCallback(() -> {
final Object value = list.getSelectedValue();
if (value instanceof String) {
processor.execute(methods[value.equals(renameBase) ? 0 : 1]);
}
}).createPopup().showInBestPositionFor(editor);
}
use of com.intellij.psi.PsiClass in project intellij-community by JetBrains.
the class SuperMethodWarningUtil method checkSuperMethods.
@NotNull
public static PsiMethod[] checkSuperMethods(@NotNull PsiMethod method, @NotNull String actionString, @NotNull Collection<PsiElement> ignore) {
PsiClass aClass = method.getContainingClass();
if (aClass == null)
return new PsiMethod[] { method };
final Collection<PsiMethod> superMethods = getSuperMethods(method, aClass, ignore);
if (superMethods.isEmpty())
return new PsiMethod[] { method };
Set<String> superClasses = new HashSet<>();
boolean superAbstract = false;
boolean parentInterface = false;
for (final PsiMethod superMethod : superMethods) {
final PsiClass containingClass = superMethod.getContainingClass();
superClasses.add(containingClass.getQualifiedName());
final boolean isInterface = containingClass.isInterface();
superAbstract |= isInterface || superMethod.hasModifierProperty(PsiModifier.ABSTRACT);
parentInterface |= isInterface;
}
SuperMethodWarningDialog dialog = new SuperMethodWarningDialog(method.getProject(), DescriptiveNameUtil.getDescriptiveName(method), actionString, superAbstract, parentInterface, aClass.isInterface(), ArrayUtil.toStringArray(superClasses));
dialog.show();
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
return superMethods.toArray(new PsiMethod[superMethods.size()]);
}
if (dialog.getExitCode() == SuperMethodWarningDialog.NO_EXIT_CODE) {
return new PsiMethod[] { method };
}
return PsiMethod.EMPTY_ARRAY;
}
Aggregations