mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] add and use separate GrLightMethodBuilder#addOptionalParameter method
This commit is contained in:
@@ -102,7 +102,7 @@ class GradleExtensionsContributor : GradleMethodContextContributor {
|
||||
containingClass = taskContainerClass
|
||||
returnType = returnClass
|
||||
}
|
||||
methodBuilder.addParameter("task", GRADLE_API_TASK, true)
|
||||
methodBuilder.addOptionalParameter("task", GRADLE_API_TASK)
|
||||
place.putUserData(RESOLVED_CODE, true)
|
||||
if (!processor.execute(methodBuilder, state)) return false
|
||||
}
|
||||
@@ -138,7 +138,7 @@ class GradleExtensionsContributor : GradleMethodContextContributor {
|
||||
containingClass = projectClass
|
||||
returnType = returnClass
|
||||
if (parent is GrMethodCallExpressionImpl && parent.argumentList.namedArguments.isNotEmpty()) {
|
||||
addParameter("args", JAVA_UTIL_MAP, true)
|
||||
addOptionalParameter("args", JAVA_UTIL_MAP)
|
||||
}
|
||||
val closureParam = addAndGetParameter("configuration", GROOVY_LANG_CLOSURE, true)
|
||||
closureParam.putUserData(DELEGATES_TO_KEY, gradleTask.typeFqn)
|
||||
@@ -201,7 +201,7 @@ class GradleExtensionsContributor : GradleMethodContextContributor {
|
||||
val returnClass = groovyPsiManager.createTypeByFQClassName(GROOVY_LANG_CLOSURE, resolveScope) ?: return true
|
||||
val methodBuilder = GrLightMethodBuilder(place.manager, name).apply {
|
||||
returnType = returnClass
|
||||
addParameter("args", JAVA_LANG_OBJECT, true)
|
||||
addOptionalParameter("args", JAVA_LANG_OBJECT)
|
||||
}
|
||||
return processor.execute(methodBuilder, state)
|
||||
}
|
||||
@@ -302,7 +302,7 @@ fun processExtension(processor: PsiScopeProcessor,
|
||||
returnType = returnClass
|
||||
}
|
||||
if (shouldProcessMethods) {
|
||||
methodBuilder.addParameter("configuration", GROOVY_LANG_CLOSURE, true)
|
||||
methodBuilder.addOptionalParameter("configuration", GROOVY_LANG_CLOSURE)
|
||||
}
|
||||
place.putUserData(RESOLVED_CODE, true)
|
||||
if (!processor.execute(methodBuilder, state)) return false
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ public class XmlMarkupBuilderNonCodeMemberContributor extends BuilderMethodsCont
|
||||
// (Map, Object, Closure)
|
||||
res = createMethod(name, clazz, place);
|
||||
res.addParameter("attributes", JAVA_UTIL_MAP);
|
||||
res.addParameter("value", JAVA_LANG_OBJECT, true);
|
||||
res.addOptionalParameter("value", JAVA_LANG_OBJECT);
|
||||
res.addAndGetParameter("body", GROOVY_LANG_CLOSURE, true).putUserData(DELEGATES_TO_KEY, FQN);
|
||||
for (GrReflectedMethod method : res.getReflectedMethods()) {
|
||||
if (!processor.process(method)) return false;
|
||||
@@ -70,7 +70,7 @@ public class XmlMarkupBuilderNonCodeMemberContributor extends BuilderMethodsCont
|
||||
// (Object, Map, Closure)
|
||||
res = createMethod(name, clazz, place);
|
||||
res.addParameter("value", JAVA_LANG_OBJECT);
|
||||
res.addParameter("attributes", JAVA_UTIL_MAP, true);
|
||||
res.addOptionalParameter("attributes", JAVA_UTIL_MAP);
|
||||
res.addAndGetParameter("body", GROOVY_LANG_CLOSURE, true).putUserData(DELEGATES_TO_KEY, FQN);
|
||||
for (GrReflectedMethod method : res.getReflectedMethods()) {
|
||||
if (!processor.process(method)) return false;
|
||||
|
||||
+6
-1
@@ -249,7 +249,12 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod, Orig
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GrLightMethodBuilder addParameter(@NotNull String name, @NotNull String type, boolean isOptional) {
|
||||
public GrLightMethodBuilder addOptionalParameter(@NotNull String name, @NotNull String type) {
|
||||
return addParameter(name, type, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private GrLightMethodBuilder addParameter(@NotNull String name, @NotNull String type, boolean isOptional) {
|
||||
return addParameter(name, JavaPsiFacade.getElementFactory(getProject()).createTypeFromText(type, this), isOptional);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ class LogbackDelegateMemberContributor : NonCodeMembersContributor() {
|
||||
wrappedBase.copy().apply {
|
||||
addParameter("name", JAVA_LANG_STRING)
|
||||
addParameter("clazz", classType)
|
||||
addParameter("configuration", GROOVY_LANG_CLOSURE, true)
|
||||
addOptionalParameter("configuration", GROOVY_LANG_CLOSURE)
|
||||
}.let {
|
||||
if (!delegate.execute(it, state)) return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user