use of com.intellij.psi.PsiTypeElement in project smali by JesusFreke.
the class SmaliArrayTypeElement method getType.
@NotNull
@Override
public PsiType getType() {
ASTNode token = findChildByType(SmaliTokens.ARRAY_TYPE_PREFIX);
assert token != null;
PsiTypeElement baseType = findChildByClass(PsiTypeElement.class);
assert baseType != null;
PsiArrayType arrayType = new PsiArrayType(baseType.getType());
int dimensions = token.getTextLength() - 1;
while (dimensions > 0) {
arrayType = new PsiArrayType(arrayType);
dimensions--;
}
return arrayType;
}
use of com.intellij.psi.PsiTypeElement in project smali by JesusFreke.
the class SmaliFieldTest method testBasicField.
public void testBasicField() {
SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + ".field public myField:I");
SmaliClass smaliClass = file.getPsiClass();
Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName());
SmaliField[] fields = smaliClass.getFields();
Assert.assertEquals(1, fields.length);
Assert.assertEquals("myField", fields[0].getName());
Assert.assertTrue(fields[0].getType() instanceof PsiPrimitiveType);
Assert.assertEquals("int", fields[0].getType().getCanonicalText());
PsiTypeElement typeElement = fields[0].getTypeElement();
Assert.assertNotNull("I", typeElement);
Assert.assertEquals("I", typeElement.getText());
SmaliModifierList modifierList = fields[0].getModifierList();
Assert.assertNotNull(modifierList);
Assert.assertEquals(AccessFlags.PUBLIC.getValue(), modifierList.getAccessFlags());
Assert.assertTrue(modifierList.hasExplicitModifier("public"));
Assert.assertTrue(modifierList.hasModifierProperty("public"));
Assert.assertTrue(fields[0].hasModifierProperty("public"));
PsiField[] psifields = smaliClass.getAllFields();
Assert.assertEquals(1, psifields.length);
Assert.assertEquals("myField", psifields[0].getName());
PsiField field = smaliClass.findFieldByName("myField", true);
Assert.assertNotNull(field);
Assert.assertEquals("myField", field.getName());
field = smaliClass.findFieldByName("nonExistantField", true);
Assert.assertNull(field);
field = smaliClass.findFieldByName("nonExistantField", false);
Assert.assertNull(field);
}
use of com.intellij.psi.PsiTypeElement in project smali by JesusFreke.
the class SmaliFieldTest method testFieldAnnotations.
public void testFieldAnnotations() {
SmaliFile file = (SmaliFile) myFixture.addFileToProject("my/pkg/blah.smali", ".class public Lmy/pkg/blah; .super Ljava/lang/Object;\n" + ".field public myField:I");
SmaliClass smaliClass = file.getPsiClass();
Assert.assertEquals("my.pkg.blah", smaliClass.getQualifiedName());
SmaliField[] fields = smaliClass.getFields();
Assert.assertEquals(1, fields.length);
Assert.assertEquals("myField", fields[0].getName());
Assert.assertTrue(fields[0].getType() instanceof PsiPrimitiveType);
Assert.assertEquals("int", fields[0].getType().getCanonicalText());
PsiTypeElement typeElement = fields[0].getTypeElement();
Assert.assertNotNull("I", typeElement);
Assert.assertEquals("I", typeElement.getText());
SmaliModifierList modifierList = fields[0].getModifierList();
Assert.assertNotNull(modifierList);
Assert.assertEquals(AccessFlags.PUBLIC.getValue(), modifierList.getAccessFlags());
Assert.assertTrue(modifierList.hasExplicitModifier("public"));
Assert.assertTrue(modifierList.hasModifierProperty("public"));
Assert.assertTrue(fields[0].hasModifierProperty("public"));
PsiField[] psifields = smaliClass.getAllFields();
Assert.assertEquals(1, psifields.length);
Assert.assertEquals("myField", psifields[0].getName());
PsiField field = smaliClass.findFieldByName("myField", true);
Assert.assertNotNull(field);
Assert.assertEquals("myField", field.getName());
field = smaliClass.findFieldByName("nonExistantField", true);
Assert.assertNull(field);
field = smaliClass.findFieldByName("nonExistantField", false);
Assert.assertNull(field);
}
use of com.intellij.psi.PsiTypeElement in project intellij-community by JetBrains.
the class ChangeReturnType method fixUsage.
@Override
public void fixUsage() throws IncorrectOperationException {
PsiTypeElement returnType = myMethod.getReturnTypeElement();
assert returnType != null : myMethod;
MutationUtils.replaceType(myType, returnType);
}
use of com.intellij.psi.PsiTypeElement in project intellij-community by JetBrains.
the class FunctionalInterfaceTest method testIntersectionTypeWithSameBaseInterfaceInConjuncts.
public void testIntersectionTypeWithSameBaseInterfaceInConjuncts() throws Exception {
String filePath = BASE_PATH + "/" + getTestName(false) + ".java";
configureByFile(filePath);
final PsiTypeCastExpression castExpression = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiTypeCastExpression.class);
assertNotNull(castExpression);
final PsiTypeElement castTypeElement = castExpression.getCastType();
assertNotNull(castTypeElement);
final PsiType type = castTypeElement.getType();
final String errorMessage = LambdaHighlightingUtil.checkInterfaceFunctional(type);
assertEquals(null, errorMessage);
}
Aggregations