use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class CreateFieldFromParameterAction method isAvailable.
@Override
protected boolean isAvailable(PsiParameter psiParameter) {
final PsiType type = getSubstitutedType(psiParameter);
final PsiClass targetClass = PsiTreeUtil.getParentOfType(psiParameter, PsiClass.class);
return FieldFromParameterUtils.isAvailable(psiParameter, type, targetClass) && psiParameter.getLanguage().isKindOf(JavaLanguage.INSTANCE);
}
use of com.intellij.psi.PsiType in project intellij-plugins by JetBrains.
the class CfmlExpressionTypeCalculator method checkAndReturnNumeric.
@Nullable
private static PsiType checkAndReturnNumeric(@NotNull CfmlExpression leftOperand, @NotNull CfmlExpression rightOperand) {
PsiType rightType = rightOperand.getPsiType();
if (rightType == null) {
return null;
}
PsiType leftType = leftOperand.getPsiType();
if (leftType == null) {
return null;
}
if (isNumericType(leftType) && isNumericType(rightType)) {
PsiClassType boxedType = ((PsiPrimitiveType) unboxAndBalanceTypes(leftType, rightType)).getBoxedType(leftOperand.getManager(), leftOperand.getResolveScope());
return boxedType;
}
return null;
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class GradleUnresolvedReferenceFilter method isReject.
@Override
public boolean isReject(@NotNull GrReferenceExpression expression) {
final PsiType psiType = GradleResolverUtil.getTypeOf(expression);
if (psiType == null) {
PsiElement child = expression.getFirstChild();
if (child == null)
return false;
PsiReference reference = child.getReference();
if (reference instanceof GrReferenceExpression) {
PsiType type = ((GrReferenceExpression) reference).getType();
if (type != null) {
PsiClassType extType = createGenericType(GRADLE_API_EXTRA_PROPERTIES_EXTENSION, expression, null);
return TypeConversionUtil.areTypesConvertible(type, extType);
}
}
return false;
}
Set<String> toIgnore = new HashSet<>(IGNORE_SET);
GradleExtensionsSettings.GradleExtensionsData extensionsData = GradleExtensionsContributor.Companion.getExtensionsFor(expression);
if (extensionsData != null) {
for (GradleExtensionsSettings.GradleExtension extension : extensionsData.extensions) {
if (StringUtil.isNotEmpty(extension.namedObjectTypeFqn)) {
toIgnore.add(extension.namedObjectTypeFqn);
}
}
}
return toIgnore.contains(TypesUtil.getQualifiedName(psiType));
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class BaseScriptAnnotationChecker method checkApplicability.
@Override
public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
if (GroovyCommonClassNames.GROOVY_TRANSFORM_BASE_SCRIPT.equals(annotation.getQualifiedName())) {
PsiFile file = annotation.getContainingFile();
if (file instanceof GroovyFile && !(((GroovyFile) file).isScript())) {
holder.createErrorAnnotation(annotation, GroovyBundle.message("base.script.annotation.is.allowed.only.inside.scripts"));
return true;
}
PsiElement pparent = annotation.getParent().getParent();
if (pparent instanceof GrVariableDeclaration) {
GrTypeElement typeElement = ((GrVariableDeclaration) pparent).getTypeElementGroovy();
PsiType type = typeElement != null ? typeElement.getType() : null;
if (!InheritanceUtil.isInheritor(type, GroovyCommonClassNames.GROOVY_LANG_SCRIPT)) {
String typeText = type != null ? type.getCanonicalText() : CommonClassNames.JAVA_LANG_OBJECT;
holder.createErrorAnnotation(annotation, GroovyBundle.message("declared.type.0.have.to.extend.script", typeText));
return true;
}
}
}
return false;
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class GrReassignedInClosureLocalVarInspection method buildVisitor.
@NotNull
@Override
protected BaseInspectionVisitor buildVisitor() {
return new BaseInspectionVisitor() {
@Override
public void visitReferenceExpression(@NotNull GrReferenceExpression referenceExpression) {
super.visitReferenceExpression(referenceExpression);
if (!PsiUtil.isLValue(referenceExpression))
return;
final PsiElement resolved = referenceExpression.resolve();
if (!PsiUtil.isLocalVariable(resolved))
return;
final PsiType checked = GrReassignedLocalVarsChecker.getReassignedVarType(referenceExpression, false);
if (checked == null)
return;
final GrControlFlowOwner varFlowOwner = ControlFlowUtils.findControlFlowOwner(resolved);
final GrControlFlowOwner refFlorOwner = ControlFlowUtils.findControlFlowOwner(referenceExpression);
if (isOtherScopeAndType(referenceExpression, checked, varFlowOwner, refFlorOwner)) {
String flowDescription = getFlowDescription(refFlorOwner);
final String message = GroovyInspectionBundle.message("local.var.0.is.reassigned", ((GrNamedElement) resolved).getName(), flowDescription);
registerError(referenceExpression, message, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
};
}
Aggregations