use of com.intellij.psi.PsiTypeParameter 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;
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class ReturnValueBeanBuilder method buildBeanClass.
public String buildBeanClass() throws IOException {
final StringBuilder out = new StringBuilder(1024);
if (myPackageName.length() > 0) {
out.append("package ").append(myPackageName).append(";\n\n");
}
out.append("public ");
if (myStatic)
out.append("static ");
out.append("class ").append(myClassName);
if (!myTypeParams.isEmpty()) {
out.append('<');
boolean first = true;
for (PsiTypeParameter typeParam : myTypeParams) {
if (!first) {
out.append(',');
}
final String parameterText = typeParam.getText();
out.append(parameterText);
first = false;
}
out.append('>');
}
out.append(" {\n");
outputField(out);
out.append("\n\n");
outputConstructor(out);
out.append("\n\n");
outputGetter(out);
out.append("\n}\n");
return out.toString();
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class MissingClassBodyFixer method apply.
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
if (!(psiElement instanceof PsiClass) || psiElement instanceof PsiTypeParameter)
return;
PsiClass psiClass = (PsiClass) psiElement;
if (psiClass.getLBrace() == null) {
int offset = psiClass.getTextRange().getEndOffset();
editor.getDocument().insertString(offset, "{\n}");
editor.getCaretModel().moveToOffset(offset);
}
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class PsiUtilTest method testTypeParameterIterator1.
public void testTypeParameterIterator1() throws Exception {
final PsiClass classA = createClass("class A<T> { class B<X> {}}");
final Iterator<PsiTypeParameter> iterator = PsiUtil.typeParametersIterator(classA.getInnerClasses()[0]);
compareIterator(new String[] { "X", "T" }, iterator);
}
use of com.intellij.psi.PsiTypeParameter in project intellij-community by JetBrains.
the class PsiUtilTest method compareIterator.
private static void compareIterator(String[] expected, Iterator<PsiTypeParameter> it) {
final ArrayList<String> actual = new ArrayList<>();
while (it.hasNext()) {
PsiTypeParameter typeParameter = it.next();
actual.add(typeParameter.getName());
}
assertEquals(Arrays.asList(expected).toString(), actual.toString());
}
Aggregations