use of com.intellij.psi.PsiParameter in project intellij-community by JetBrains.
the class RemoveUnusedParameterFix method getNewParametersInfo.
@NotNull
public static ParameterInfoImpl[] getNewParametersInfo(PsiMethod method, PsiParameter parameterToRemove) {
List<ParameterInfoImpl> result = new ArrayList<>();
PsiParameter[] parameters = method.getParameterList().getParameters();
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
if (!Comparing.equal(parameter, parameterToRemove)) {
result.add(new ParameterInfoImpl(i, parameter.getName(), parameter.getType()));
}
}
return result.toArray(new ParameterInfoImpl[result.size()]);
}
use of com.intellij.psi.PsiParameter in project intellij-community by JetBrains.
the class UnassignedVariableAccessInspection method check.
@Override
protected void check(@NotNull GrControlFlowOwner owner, @NotNull ProblemsHolder problemsHolder) {
Instruction[] flow = owner.getControlFlow();
ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow, true);
for (ReadWriteVariableInstruction read : reads) {
PsiElement element = read.getElement();
if (element instanceof GroovyPsiElement && !(element instanceof GrClosableBlock)) {
String name = read.getVariableName();
GroovyPsiElement property = ResolveUtil.resolveProperty((GroovyPsiElement) element, name);
if (property != null && !(property instanceof PsiParameter) && !(property instanceof PsiField) && PsiTreeUtil.isAncestor(owner, property, false) && !(myIgnoreBooleanExpressions && isBooleanCheck(element))) {
problemsHolder.registerProblem(element, GroovyInspectionBundle.message("unassigned.access.tooltip", name));
}
}
}
}
use of com.intellij.psi.PsiParameter in project qi4j-sdk by Qi4j.
the class AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection method checkMethod.
@Override
public final ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
PsiParameterList parameterList = method.getParameterList();
PsiParameter[] parameters = parameterList.getParameters();
if (method.isConstructor()) {
List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
for (PsiParameter parameter : parameters) {
PsiAnnotation annotation = getAnnotationToCheck(parameter);
if (annotation != null) {
ProblemDescriptor[] descriptors = verifyAnnotationDeclaredCorrectly(parameter, annotation, manager);
if (descriptors != null) {
problems.addAll(asList(descriptors));
}
}
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
} else {
List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
for (PsiParameter parameter : parameters) {
PsiAnnotation annotationToCheck = getAnnotationToCheck(parameter);
if (annotationToCheck != null) {
String message = getInjectionAnnotationValidDeclarationMessage();
AbstractFix removeAnnotationFix = createRemoveAnnotationFix(annotationToCheck);
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(annotationToCheck, message, removeAnnotationFix, GENERIC_ERROR_OR_WARNING);
problems.add(problemDescriptor);
}
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
}
}
use of com.intellij.psi.PsiParameter in project intellij-community by JetBrains.
the class ParametersMatcher method matchParameters.
private static MatchResult matchParameters(final PsiMethod method, final ChainCompletionContext context, final Set<String> additionalExcludedNames) {
int matched = 0;
int unMatched = 0;
boolean hasTarget = false;
for (final PsiParameter parameter : method.getParameterList().getParameters()) {
final PsiType type = parameter.getType();
final String canonicalText = type.getCanonicalText();
if (context.contains(canonicalText) || type instanceof PsiPrimitiveType) {
matched++;
} else {
unMatched++;
}
if (context.getTarget().getClassQName().equals(canonicalText) || additionalExcludedNames.contains(canonicalText)) {
hasTarget = true;
}
}
return new MatchResult(matched, unMatched, hasTarget);
}
use of com.intellij.psi.PsiParameter in project intellij-community by JetBrains.
the class JavaMethodDescriptor method getParameters.
@Override
public List<ParameterInfoImpl> getParameters() {
final ArrayList<ParameterInfoImpl> result = new ArrayList<>();
final PsiParameter[] parameters = myMethod.getParameterList().getParameters();
for (int i = 0; i < parameters.length; i++) {
PsiParameter parameter = parameters[i];
ParameterInfoImpl info = new ParameterInfoImpl(i, parameter.getName(), parameter.getType());
info.defaultValue = "";
result.add(info);
}
return result;
}
Aggregations