Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
3079b60a
Commit
3079b60a
authored
6 years ago
by
Daniil Ovchinnikov
Browse files
Options
Download
Email Patches
Plain Diff
[groovy] get rid of GrMultiSignature and visitors, use GrSignature and List<GrSignature> instead
parent
05a20f1f
Changes
43
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/GroovyTypeCheckVisitorHelper.java
+2
-3
...ovy/codeInspection/type/GroovyTypeCheckVisitorHelper.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/gpp/GppClosureParameterTypeProvider.java
+7
-2
...s/plugins/groovy/gpp/GppClosureParameterTypeProvider.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java
+4
-16
...rc/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/completion/closureParameters/ClosureDescriptor.java
+4
-18
.../lang/completion/closureParameters/ClosureDescriptor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
+3
-18
...ains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrClosureSignature.java
+0
-43
...ns/groovy/lang/psi/api/signatures/GrClosureSignature.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrMultiSignature.java
+0
-7
...gins/groovy/lang/psi/api/signatures/GrMultiSignature.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrRecursiveSignatureVisitor.java
+0
-30
.../lang/psi/api/signatures/GrRecursiveSignatureVisitor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignature.java
+16
-21
...s/plugins/groovy/lang/psi/api/signatures/GrSignature.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignatureVisitor.java
+0
-31
...ns/groovy/lang/psi/api/signatures/GrSignatureVisitor.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java
+3
-17
...groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java
+28
-29
...jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
+2
-2
...ins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosableSignatureImpl.java
+3
-31
...ovy/lang/psi/impl/signatures/GrClosableSignatureImpl.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java
+139
-196
...oovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureWithNewParameters.java
+5
-32
.../impl/signatures/GrClosureSignatureWithNewParameters.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java
+9
-35
.../psi/impl/signatures/GrImmediateClosureSignatureImpl.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMethodSignatureImpl.java
+5
-16
...roovy/lang/psi/impl/signatures/GrMethodSignatureImpl.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java
+0
-73
...groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/curry.kt
+12
-0
...etbrains/plugins/groovy/lang/psi/impl/signatures/curry.kt
with
242 additions
and
620 deletions
+242
-620
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/type/GroovyTypeCheckVisitorHelper.java
+
2
-
3
View file @
3079b60a
...
...
@@ -20,7 +20,6 @@ import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
import
org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement
;
import
org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList
;
...
...
@@ -116,8 +115,8 @@ public class GroovyTypeCheckVisitorHelper {
if
(
args
==
null
)
return
LocalQuickFix
.
EMPTY_ARRAY
;
final
List
<
Pair
<
Integer
,
PsiType
>>
allErrors
=
new
ArrayList
<>();
final
List
<
Gr
Closure
Signature
>
signatures
=
GrClosureSignatureUtil
.
generateSimpleSignatures
(
signature
);
for
(
Gr
Closure
Signature
closureSignature
:
signatures
)
{
final
List
<
GrSignature
>
signatures
=
GrClosureSignatureUtil
.
generateSimpleSignatures
(
Collections
.
singletonList
(
signature
)
)
;
for
(
GrSignature
closureSignature
:
signatures
)
{
final
GrClosureSignatureUtil
.
MapResultWithError
map
=
GrClosureSignatureUtil
.
mapSimpleSignatureWithErrors
(
closureSignature
,
argumentTypes
,
id
,
argumentList
,
255
);
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/gpp/GppClosureParameterTypeProvider.java
+
7
-
2
View file @
3079b60a
...
...
@@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock
;
...
...
@@ -113,8 +114,12 @@ public class GppClosureParameterTypeProvider extends AbstractClosureParameterEnh
@Nullable
public
static
PsiType
getSingleMethodParameterType
(
@Nullable
PsiType
type
,
int
index
,
GrClosableBlock
closure
)
{
final
PsiType
[]
signature
=
findSingleAbstractMethodSignature
(
type
);
if
(
signature
!=
null
&&
GrClosureSignatureUtil
.
isSignatureApplicable
(
GrClosureSignatureUtil
.
createSignature
(
closure
),
signature
,
closure
))
{
return
signature
.
length
>
index
?
signature
[
index
]
:
PsiType
.
NULL
;
if
(
signature
==
null
)
{
return
null
;
}
final
GrSignature
closureSignature
=
GrClosureSignatureUtil
.
createSignature
(
closure
);
if
(
GrClosureSignatureUtil
.
isSignatureApplicable
(
Collections
.
singletonList
(
closureSignature
),
signature
,
closure
))
{
return
signature
.
length
>
index
?
signature
[
index
]
:
PsiType
.
NULL
;
}
return
null
;
}
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java
+
4
-
16
View file @
3079b60a
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.gpp
;
import
com.intellij.psi.PsiClass
;
...
...
@@ -30,6 +16,8 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureU
import
org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.ConversionResult
;
import
org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrTypeConverter
;
import
java.util.List
;
import
static
org
.
jetbrains
.
plugins
.
groovy
.
lang
.
psi
.
impl
.
statements
.
expressions
.
TypesUtil
.
canAssign
;
/**
...
...
@@ -73,7 +61,7 @@ public class GppTypeConverter extends GrTypeConverter {
}
public
static
boolean
isClosureOverride
(
PsiType
[]
methodParameters
,
GrClosureType
closureType
,
GroovyPsiElement
context
)
{
final
GrSignature
signature
=
closureType
.
getSignature
();
final
List
<
GrSignature
>
signature
=
closureType
.
getSignature
s
();
if
(
methodParameters
!=
null
&&
GrClosureSignatureUtil
.
isSignatureApplicable
(
signature
,
methodParameters
,
context
))
{
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/completion/closureParameters/ClosureDescriptor.java
+
4
-
18
View file @
3079b60a
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.completion.closureParameters
;
import
com.intellij.psi.*
;
...
...
@@ -25,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.GroovyLanguage
;
import
org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.Gr
Closure
Signature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil
;
import
java.util.ArrayList
;
...
...
@@ -87,13 +73,13 @@ public class ClosureDescriptor extends LightElement implements PsiElement {
final
boolean
isConstructor
=
Boolean
.
TRUE
.
equals
(
myMethod
.
get
(
"constructor"
));
final
MethodSignature
signature
=
MethodSignatureUtil
.
createMethodSignature
(
name
,
types
.
toArray
(
PsiType
.
createArray
(
types
.
size
())),
method
.
getTypeParameters
(),
PsiSubstitutor
.
EMPTY
,
isConstructor
);
final
Gr
Closure
Signature
closureSignature
=
GrClosureSignatureUtil
.
createSignature
(
signature
);
final
GrSignature
closureSignature
=
GrClosureSignatureUtil
.
createSignature
(
signature
);
if
(
method
instanceof
ClsMethodImpl
)
method
=
((
ClsMethodImpl
)
method
).
getSourceMirrorMethod
();
final
PsiParameter
[]
parameters
=
method
.
getParameterList
().
getParameters
();
final
PsiType
[]
typeArray
=
ContainerUtil
.
map
(
parameters
,
parameter
->
parameter
.
getType
(),
PsiType
.
createArray
(
parameters
.
length
));
return
GrClosureSignatureUtil
.
isSignatureApplicable
(
closureSignature
,
typeArray
,
place
);
return
GrClosureSignatureUtil
.
isSignatureApplicable
(
Collections
.
singletonList
(
closureSignature
)
,
typeArray
,
place
);
}
private
static
PsiType
convertToPsiType
(
String
type
,
@NotNull
PsiElement
place
)
{
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
+
3
-
18
View file @
3079b60a
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi
;
import
com.intellij.openapi.components.ServiceManager
;
...
...
@@ -28,7 +13,7 @@ import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMemberReference;
import
org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement
;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList
;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.Gr
Closure
Signature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.*
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument
;
...
...
@@ -260,7 +245,7 @@ public abstract class GroovyPsiElementFactory implements JVMElementFactory {
public
abstract
GrAnnotation
createAnnotationFromText
(
@NotNull
@NonNls
String
annotationText
,
@Nullable
PsiElement
context
)
throws
IncorrectOperationException
;
@NotNull
public
abstract
GrMethod
createMethodFromSignature
(
@NotNull
String
name
,
@NotNull
Gr
Closure
Signature
signature
);
public
abstract
GrMethod
createMethodFromSignature
(
@NotNull
String
name
,
@NotNull
GrSignature
signature
);
@NotNull
public
GrMethod
createMethodFromText
(
@NotNull
CharSequence
methodText
)
{
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrClosureSignature.java
deleted
100644 → 0
+
0
-
43
View file @
05a20f1f
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.plugins.groovy.lang.psi.api.signatures
;
import
com.intellij.psi.PsiSubstitutor
;
import
com.intellij.psi.PsiType
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter
;
/**
* @author Maxim.Medvedev
*/
public
interface
GrClosureSignature
extends
GrSignature
{
GrClosureSignature
[]
EMPTY_ARRAY
=
new
GrClosureSignature
[
0
];
@NotNull
PsiSubstitutor
getSubstitutor
();
@NotNull
GrClosureParameter
[]
getParameters
();
int
getParameterCount
();
boolean
isVarargs
();
@Nullable
PsiType
getReturnType
();
boolean
isCurried
();
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrMultiSignature.java
deleted
100644 → 0
+
0
-
7
View file @
05a20f1f
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.api.signatures
;
public
interface
GrMultiSignature
extends
GrSignature
{
GrClosureSignature
[]
getAllSignatures
();
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrRecursiveSignatureVisitor.java
deleted
100644 → 0
+
0
-
30
View file @
05a20f1f
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.plugins.groovy.lang.psi.api.signatures
;
/**
* @author Max Medvedev
*/
public
abstract
class
GrRecursiveSignatureVisitor
extends
GrSignatureVisitor
{
@Override
public
void
visitMultiSignature
(
GrMultiSignature
signature
)
{
super
.
visitMultiSignature
(
signature
);
for
(
GrClosureSignature
s
:
signature
.
getAllSignatures
())
{
s
.
accept
(
this
);
}
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignature.java
+
16
-
21
View file @
3079b60a
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.api.signatures
;
import
com.intellij.psi.Psi
Element
;
import
com.intellij.psi.Psi
Substitutor
;
import
com.intellij.psi.PsiType
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter
;
/**
* @author Max Medvedev
*/
public
interface
GrSignature
{
boolean
isValid
();
@NotNull
PsiSubstitutor
getSubstitutor
();
@NotNull
GrClosureParameter
[]
getParameters
();
int
getParameterCount
();
boolean
isVarargs
();
@Nullable
GrSignature
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
PsiElement
context
);
PsiType
getReturnType
(
);
void
accept
(
@NotNull
GrSignatureVisitor
visitor
);
boolean
isCurried
(
);
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignatureVisitor.java
deleted
100644 → 0
+
0
-
31
View file @
05a20f1f
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.plugins.groovy.lang.psi.api.signatures
;
/**
* @author Max Medvedev
*/
public
abstract
class
GrSignatureVisitor
{
public
void
visitClosureSignature
(
GrClosureSignature
signature
){
visitSignature
(
signature
);
}
public
void
visitSignature
(
GrSignature
signature
){}
public
void
visitMultiSignature
(
GrMultiSignature
signature
){
visitSignature
(
signature
);
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ArgumentInstruction.java
+
3
-
17
View file @
3079b60a
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl
;
import
com.intellij.openapi.diagnostic.Logger
;
...
...
@@ -23,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils
;
import
org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.Gr
Closure
Signature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
;
...
...
@@ -60,7 +46,7 @@ public class ArgumentInstruction extends InstructionImpl implements MixinTypeIns
PsiType
result
=
null
;
for
(
GroovyResolveResult
variant
:
variants
)
{
Gr
Closure
Signature
signature
=
GrClosureSignatureUtil
.
createSignature
(
variant
);
GrSignature
signature
=
GrClosureSignatureUtil
.
createSignature
(
variant
);
if
(
signature
==
null
)
continue
;
if
(
GrClosureSignatureUtil
.
mapParametersToArguments
(
signature
,
call
)
!=
null
&&
!
haveNullParameters
(
call
))
{
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java
+
28
-
29
View file @
3079b60a
...
...
@@ -5,47 +5,49 @@ import com.intellij.openapi.util.Comparing;
import
com.intellij.pom.java.LanguageLevel
;
import
com.intellij.psi.*
;
import
com.intellij.psi.search.GlobalSearchScope
;
import
com.intellij.util.containers.ContainerUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.annotations.TestOnly
;
import
org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement
;
import
org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock
;
import
org.jetbrains.plugins.groovy.lang.psi.impl.signatures.CurryKt
;
import
org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil
;
import
org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil
;
import
org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* @author ven
*/
public
class
GrClosureType
extends
GrLiteralClassType
{
private
final
GrSignature
mySignature
;
private
final
List
<
GrSignature
>
mySignatures
;
private
volatile
PsiType
[]
myTypeArgs
;
private
GrClosableBlock
myClosure
;
private
GrClosureType
(
@NotNull
LanguageLevel
languageLevel
,
@NotNull
GlobalSearchScope
scope
,
@NotNull
JavaPsiFacade
facade
,
@NotNull
GrSignature
closureS
ignature
,
@NotNull
List
<
GrSignature
>
s
ignature
s
,
boolean
shouldInferTypeParameters
)
{
super
(
languageLevel
,
scope
,
facade
);
mySignature
=
closureS
ignature
;
mySignature
s
=
s
ignature
s
;
if
(!
shouldInferTypeParameters
)
myTypeArgs
=
PsiType
.
EMPTY_ARRAY
;
}
private
GrClosureType
(
@NotNull
LanguageLevel
level
,
@NotNull
GlobalSearchScope
scope
,
@NotNull
JavaPsiFacade
facade
,
@NotNull
GrSignature
signature
,
@NotNull
List
<
GrSignature
>
signature
s
,
@Nullable
PsiType
[]
typeArgs
)
{
super
(
level
,
scope
,
facade
);
mySignature
=
signature
;
mySignatures
=
signatures
;
myTypeArgs
=
typeArgs
;
}
...
...
@@ -78,7 +80,7 @@ public class GrClosureType extends GrLiteralClassType {
public
PsiType
[]
inferParameters
()
{
final
PsiClass
psiClass
=
resolve
();
if
(
psiClass
!=
null
&&
psiClass
.
getTypeParameters
().
length
==
1
)
{
final
PsiType
type
=
GrClosureSignatureUtil
.
getReturnType
(
mySignature
);
final
PsiType
type
=
GrClosureSignatureUtil
.
getReturnType
(
mySignature
s
);
if
(
type
==
PsiType
.
NULL
||
type
==
null
)
{
return
new
PsiType
[]{
null
};
}
...
...
@@ -104,17 +106,17 @@ public class GrClosureType extends GrLiteralClassType {
return
this
;
}
return
new
GrClosureType
(
getLanguageLevel
(),
getResolveScope
(),
myFacade
,
mySignature
,
false
);
return
new
GrClosureType
(
getLanguageLevel
(),
getResolveScope
(),
myFacade
,
mySignature
s
,
false
);
}
@Override
public
boolean
isValid
()
{
return
mySignature
.
isValid
(
);
return
ContainerUtil
.
all
(
mySignatures
,
GrSignature:
:
isValid
);
}
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
GrClosureType
)
{
return
Comparing
.
equal
(
mySignature
,
((
GrClosureType
)
obj
).
mySignature
);
return
Comparing
.
equal
(
mySignature
s
,
((
GrClosureType
)
obj
).
mySignature
s
);
}
return
super
.
equals
(
obj
);
...
...
@@ -123,12 +125,12 @@ public class GrClosureType extends GrLiteralClassType {
@Override
@NotNull
public
PsiClassType
setLanguageLevel
(
@NotNull
final
LanguageLevel
languageLevel
)
{
return
new
GrClosureType
(
languageLevel
,
myScope
,
myFacade
,
mySignature
,
myTypeArgs
);
return
new
GrClosureType
(
languageLevel
,
myScope
,
myFacade
,
mySignature
s
,
myTypeArgs
);
}
@NotNull
public
static
GrClosureType
create
(
@NotNull
Iterable
<?
extends
GroovyResolveResult
>
results
,
@NotNull
GroovyPsiElement
context
)
{
List
<
Gr
Closure
Signature
>
signatures
=
new
ArrayList
<>();
List
<
GrSignature
>
signatures
=
new
ArrayList
<>();
for
(
GroovyResolveResult
result
:
results
)
{
if
(
result
.
getElement
()
instanceof
PsiMethod
)
{
signatures
.
add
(
GrClosureSignatureUtil
.
createSignature
((
PsiMethod
)
result
.
getElement
(),
result
.
getSubstitutor
()));
...
...
@@ -137,42 +139,39 @@ public class GrClosureType extends GrLiteralClassType {
final
GlobalSearchScope
resolveScope
=
context
.
getResolveScope
();
final
JavaPsiFacade
facade
=
JavaPsiFacade
.
getInstance
(
context
.
getProject
());
if
(
signatures
.
size
()
==
1
)
{
return
create
(
signatures
.
get
(
0
),
resolveScope
,
facade
,
LanguageLevel
.
JDK_1_5
,
true
);
}
else
{
return
create
(
GrClosureSignatureUtil
.
createMultiSignature
(
signatures
.
toArray
(
GrClosureSignature
.
EMPTY_ARRAY
)),
resolveScope
,
facade
,
LanguageLevel
.
JDK_1_5
,
true
);
}
return
create
(
signatures
,
resolveScope
,
facade
,
LanguageLevel
.
JDK_1_5
,
true
);
}
public
static
GrClosureType
create
(
@NotNull
GrClosableBlock
closure
,
boolean
shouldInferTypeParameters
)
{
final
Gr
Closure
Signature
signature
=
GrClosureSignatureUtil
.
createSignature
(
closure
);
final
GrSignature
signature
=
GrClosureSignatureUtil
.
createSignature
(
closure
);
final
GlobalSearchScope
resolveScope
=
closure
.
getResolveScope
();
final
JavaPsiFacade
facade
=
JavaPsiFacade
.
getInstance
(
closure
.
getProject
());
GrClosureType
type
=
create
(
signature
,
resolveScope
,
facade
,
LanguageLevel
.
JDK_1_5
,
shouldInferTypeParameters
);
GrClosureType
type
=
create
(
Collections
.
singletonList
(
signature
)
,
resolveScope
,
facade
,
LanguageLevel
.
JDK_1_5
,
shouldInferTypeParameters
);
type
.
setClosure
(
closure
);
return
type
;
}
public
static
GrClosureType
create
(
@NotNull
GrSignature
signature
,
@NotNull
public
static
GrClosureType
create
(
@NotNull
List
<
GrSignature
>
signatures
,
GlobalSearchScope
scope
,
JavaPsiFacade
facade
,
@NotNull
LanguageLevel
languageLevel
,
boolean
shouldInferTypeParameters
)
{
return
new
GrClosureType
(
languageLevel
,
scope
,
facade
,
signature
,
shouldInferTypeParameters
);
return
new
GrClosureType
(
languageLevel
,
scope
,
facade
,
signature
s
,
shouldInferTypeParameters
);
}
@Nullable
public
PsiType
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
GroovyPsiElement
context
)
{
final
GrSignature
newSignature
=
mySignature
.
curry
(
args
,
position
,
context
);
if
(
newSignature
==
null
)
return
null
;
return
new
GrClosureType
(
myLanguageLevel
,
myScope
,
myFacade
,
newSignature
,
myTypeArgs
);
final
List
<
GrSignature
>
curried
=
CurryKt
.
curry
(
mySignatures
,
args
,
position
,
context
);
if
(
curried
.
isEmpty
())
{
return
null
;
}
return
new
GrClosureType
(
myLanguageLevel
,
myScope
,
myFacade
,
curried
,
myTypeArgs
);
}
@NotNull
public
GrSignature
getSignature
()
{
return
mySignature
;
public
List
<
GrSignature
>
getSignature
s
()
{
return
mySignature
s
;
}
@Override
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
+
2
-
2
View file @
3079b60a
...
...
@@ -27,7 +27,7 @@ import org.jetbrains.plugins.groovy.lang.psi.*;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier
;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList
;
import
org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.Gr
Closure
Signature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.*
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument
;
...
...
@@ -567,7 +567,7 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory {
@NotNull
@Override
public
GrMethod
createMethodFromSignature
(
@NotNull
String
name
,
@NotNull
Gr
Closure
Signature
signature
)
{
public
GrMethod
createMethodFromSignature
(
@NotNull
String
name
,
@NotNull
GrSignature
signature
)
{
StringBuilder
builder
=
new
StringBuilder
(
"public"
);
final
PsiType
returnType
=
signature
.
getReturnType
();
if
(
returnType
!=
null
&&
returnType
!=
PsiType
.
NULL
)
{
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosableSignatureImpl.java
+
3
-
31
View file @
3079b60a
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.impl.signatures
;
import
com.intellij.psi.PsiArrayType
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiSubstitutor
;
import
com.intellij.psi.PsiType
;
import
com.intellij.util.ArrayUtil
;
import
com.intellij.util.Function
;
import
com.intellij.util.containers.ContainerUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock
;
import
org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter
;
import
org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter
;
class
GrClosableSignatureImpl
implements
GrClosureSignature
{
class
GrClosableSignatureImpl
implements
GrSignature
{
private
final
GrClosableBlock
myBlock
;
GrClosableSignatureImpl
(
GrClosableBlock
block
)
{
...
...
@@ -83,15 +66,4 @@ class GrClosableSignatureImpl implements GrClosureSignature {
public
boolean
isValid
()
{
return
myBlock
.
isValid
();
}
@Nullable
@Override
public
GrSignature
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
PsiElement
context
)
{
return
GrClosureSignatureUtil
.
curryImpl
(
this
,
args
,
position
,
context
);
}
@Override
public
void
accept
(
@NotNull
GrSignatureVisitor
visitor
)
{
visitor
.
visitClosureSignature
(
this
);
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java
+
139
-
196
View file @
3079b60a
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureWithNewParameters.java
+
5
-
32
View file @
3079b60a
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.impl.signatures
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiSubstitutor
;
import
com.intellij.psi.PsiType
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor
;
import
org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter
;
public
class
GrClosureSignatureWithNewParameters
implements
GrClosureSignature
{
private
final
GrClosureSignature
myDelegate
;
public
class
GrClosureSignatureWithNewParameters
implements
GrSignature
{
private
final
GrSignature
myDelegate
;
private
final
GrClosureParameter
[]
myParams
;
public
GrClosureSignatureWithNewParameters
(
@NotNull
Gr
Closure
Signature
delegate
,
@NotNull
GrClosureParameter
[]
newParams
)
{
public
GrClosureSignatureWithNewParameters
(
@NotNull
GrSignature
delegate
,
@NotNull
GrClosureParameter
[]
newParams
)
{
myDelegate
=
delegate
;
myParams
=
newParams
;
}
...
...
@@ -71,15 +55,4 @@ public class GrClosureSignatureWithNewParameters implements GrClosureSignature {
public
boolean
isValid
()
{
return
myDelegate
.
isValid
();
}
@Nullable
@Override
public
GrSignature
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
PsiElement
context
)
{
return
GrClosureSignatureUtil
.
curryImpl
(
this
,
args
,
position
,
context
);
}
@Override
public
void
accept
(
@NotNull
GrSignatureVisitor
visitor
)
{
visitor
.
visitClosureSignature
(
this
);
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java
+
9
-
35
View file @
3079b60a
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.impl.signatures
;
import
com.intellij.openapi.diagnostic.Logger
;
...
...
@@ -21,16 +7,15 @@ import com.intellij.openapi.util.text.StringUtil;
import
com.intellij.psi.*
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor
;
import
org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter
;
import
org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil
;
/**
* @author Maxim.Medvedev
*/
public
class
GrImmediateClosureSignatureImpl
implements
GrClosureSignature
{
public
class
GrImmediateClosureSignatureImpl
implements
GrSignature
{
private
static
final
Logger
LOG
=
Logger
.
getInstance
(
GrImmediateClosureSignatureImpl
.
class
);
private
final
boolean
myIsVarargs
;
...
...
@@ -99,12 +84,6 @@ public class GrImmediateClosureSignatureImpl implements GrClosureSignature {
return
myParameters
.
length
;
}
@Override
@Nullable
public
GrSignature
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
PsiElement
context
)
{
return
GrClosureSignatureUtil
.
curryImpl
(
this
,
args
,
position
,
context
);
}
@Override
public
boolean
isValid
()
{
for
(
GrClosureParameter
parameter
:
myParameters
)
{
...
...
@@ -116,9 +95,9 @@ public class GrImmediateClosureSignatureImpl implements GrClosureSignature {
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
Gr
Closure
Signature
)
{
return
Comparing
.
equal
(
myParameters
,
((
Gr
Closure
Signature
)
obj
).
getParameters
())
&&
Comparing
.
equal
(
myIsVarargs
,
((
Gr
Closure
Signature
)
obj
).
isVarargs
());
if
(
obj
instanceof
GrSignature
)
{
return
Comparing
.
equal
(
myParameters
,
((
GrSignature
)
obj
).
getParameters
())
&&
Comparing
.
equal
(
myIsVarargs
,
((
GrSignature
)
obj
).
isVarargs
());
}
return
super
.
equals
(
obj
);
}
...
...
@@ -129,9 +108,9 @@ public class GrImmediateClosureSignatureImpl implements GrClosureSignature {
}
@Nullable
public
static
Gr
Closure
Signature
getLeastUpperBound
(
@NotNull
Gr
Closure
Signature
signature1
,
@NotNull
Gr
Closure
Signature
signature2
,
PsiManager
manager
)
{
public
static
GrSignature
getLeastUpperBound
(
@NotNull
GrSignature
signature1
,
@NotNull
GrSignature
signature2
,
@NotNull
PsiManager
manager
)
{
GrClosureParameter
[]
parameters1
=
signature1
.
getParameters
();
GrClosureParameter
[]
parameters2
=
signature2
.
getParameters
();
...
...
@@ -154,11 +133,6 @@ public class GrImmediateClosureSignatureImpl implements GrClosureSignature {
}
return
null
;
//todo
}
@Override
public
void
accept
(
@NotNull
GrSignatureVisitor
visitor
)
{
visitor
.
visitClosureSignature
(
this
);
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMethodSignatureImpl.java
+
5
-
16
View file @
3079b60a
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.impl.signatures
;
import
com.intellij.psi.*
;
import
com.intellij.psi.PsiClass
;
import
com.intellij.psi.PsiMethod
;
import
com.intellij.psi.PsiSubstitutor
;
import
com.intellij.psi.PsiType
;
import
com.intellij.psi.util.TypeConversionUtil
;
import
com.intellij.util.containers.ContainerUtil
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor
;
import
org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter
;
import
org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil
;
class
GrMethodSignatureImpl
implements
Gr
Closure
Signature
{
class
GrMethodSignatureImpl
implements
GrSignature
{
private
final
PsiMethod
myMethod
;
private
final
PsiSubstitutor
mySubstitutor
;
...
...
@@ -82,15 +82,4 @@ class GrMethodSignatureImpl implements GrClosureSignature {
public
boolean
isValid
()
{
return
myMethod
.
isValid
()
&&
getSubstitutor
().
isValid
();
}
@Nullable
@Override
public
GrSignature
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
PsiElement
context
)
{
return
GrClosureSignatureUtil
.
curryImpl
(
this
,
args
,
position
,
context
);
}
@Override
public
void
accept
(
@NotNull
GrSignatureVisitor
visitor
)
{
visitor
.
visitClosureSignature
(
this
);
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java
deleted
100644 → 0
+
0
-
73
View file @
05a20f1f
/*
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jetbrains.plugins.groovy.lang.psi.impl.signatures
;
import
com.intellij.psi.PsiElement
;
import
com.intellij.psi.PsiType
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrMultiSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
;
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @author Max Medvedev
*/
public
class
GrMultiSignatureImpl
implements
GrMultiSignature
{
private
final
GrClosureSignature
[]
mySignatures
;
public
GrMultiSignatureImpl
(
GrClosureSignature
[]
signatures
)
{
mySignatures
=
signatures
;
}
@Override
public
GrClosureSignature
[]
getAllSignatures
()
{
return
mySignatures
;
}
@Override
public
boolean
isValid
()
{
for
(
GrClosureSignature
signature
:
mySignatures
)
{
if
(!
signature
.
isValid
())
return
false
;
}
return
true
;
}
@Override
public
GrSignature
curry
(
@NotNull
PsiType
[]
args
,
int
position
,
@NotNull
PsiElement
context
)
{
List
<
GrClosureSignature
>
newClosures
=
new
ArrayList
<>();
for
(
GrClosureSignature
old
:
mySignatures
)
{
final
GrSignature
curried
=
old
.
curry
(
args
,
position
,
context
);
if
(
curried
instanceof
GrClosureSignature
)
{
newClosures
.
add
((
GrClosureSignature
)
curried
);
}
else
if
(
curried
instanceof
GrMultiSignature
)
{
newClosures
.
addAll
(
Arrays
.
asList
(((
GrMultiSignature
)
curried
).
getAllSignatures
()));
}
}
return
new
GrMultiSignatureImpl
(
newClosures
.
toArray
(
GrClosureSignature
.
EMPTY_ARRAY
));
}
@Override
public
void
accept
(
@NotNull
GrSignatureVisitor
visitor
)
{
visitor
.
visitMultiSignature
(
this
);
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/curry.kt
0 → 100644
+
12
-
0
View file @
3079b60a
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package
org.jetbrains.plugins.groovy.lang.psi.impl.signatures
import
com.intellij.psi.PsiElement
import
com.intellij.psi.PsiType
import
org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature
fun
curry
(
signatures
:
List
<
GrSignature
>,
args
:
Array
<
PsiType
>,
position
:
Int
,
context
:
PsiElement
):
List
<
GrSignature
>
{
return
signatures
.
flatMap
{
GrClosureSignatureUtil
.
curryImpl
(
it
,
args
,
position
,
context
)
}
}
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help