use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.
the class QuickfixUtil method createSettings.
public static DynamicElementSettings createSettings(GrArgumentLabel label, PsiClass targetClass) {
DynamicElementSettings settings = new DynamicElementSettings();
assert targetClass != null;
String className = targetClass.getQualifiedName();
className = className == null ? targetClass.getContainingFile().getName() : className;
settings.setContainingClassName(className);
settings.setName(label.getName());
return settings;
}
use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.
the class QuickfixUtil method createSettings.
public static DynamicElementSettings createSettings(GrReferenceExpression referenceExpression) {
DynamicElementSettings settings = new DynamicElementSettings();
final PsiClass containingClass = findTargetClass(referenceExpression, false);
assert containingClass != null;
String className = containingClass.getQualifiedName();
className = className == null ? containingClass.getContainingFile().getName() : className;
if (isStaticCall(referenceExpression)) {
settings.setStatic(true);
}
settings.setContainingClassName(className);
settings.setName(referenceExpression.getReferenceName());
if (PsiUtil.isCall(referenceExpression)) {
List<PsiType> unboxedTypes = new ArrayList<>();
for (PsiType type : PsiUtil.getArgumentTypes(referenceExpression, false)) {
unboxedTypes.add(TypesUtil.unboxPrimitiveTypeWrapperAndEraseGenerics(type));
}
final PsiType[] types = unboxedTypes.toArray(PsiType.createArray(unboxedTypes.size()));
final String[] names = GroovyNamesUtil.getMethodArgumentsNames(referenceExpression.getProject(), types);
final List<ParamInfo> infos = swapArgumentsAndTypes(names, types);
settings.setMethod(true);
settings.setParams(infos);
} else {
settings.setMethod(false);
}
return settings;
}
use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.
the class DynamicMethodFix method invoke.
public void invoke(Project project) throws IncorrectOperationException {
final DynamicElementSettings settings = QuickfixUtil.createSettings(myReferenceExpression);
DynamicManager.getInstance(project).addMethod(settings);
}
use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.
the class DynamicPropertyFix method invoke.
/**
* for tests
*/
public void invoke(Project project) throws IncorrectOperationException {
final DynamicElementSettings settings;
if (myReferenceExpression != null) {
settings = QuickfixUtil.createSettings(myReferenceExpression);
} else {
settings = QuickfixUtil.createSettings(myArgumentLabel, myTargetClass);
}
DynamicManager.getInstance(project).addProperty(settings);
}
Aggregations