Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
0e576f35
Commit
0e576f35
authored
6 years ago
by
Daniil Ovchinnikov
Browse files
Options
Download
Email Patches
Plain Diff
[groovy] add resolve kind assertions
parent
70379901
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt
+2
-0
.../org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/caches/fileCache.kt
+9
-2
...jetbrains/plugins/groovy/lang/resolve/caches/fileCache.kt
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/KindsResolverProcessor.kt
+15
-3
.../groovy/lang/resolve/processors/KindsResolverProcessor.kt
plugins/groovy/src/org/jetbrains/plugins/groovy/ext/logback/LogbackDelegateMemberContributor.kt
+4
-0
...ns/groovy/ext/logback/LogbackDelegateMemberContributor.kt
plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantMemberContributor.java
+3
-16
.../jetbrains/plugins/groovy/gant/GantMemberContributor.java
with
33 additions
and
21 deletions
+33
-21
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.kt
+
2
-
0
View file @
0e576f35
...
@@ -33,6 +33,8 @@ val log: Logger = logger(::log)
...
@@ -33,6 +33,8 @@ val log: Logger = logger(::log)
@JvmField
@JvmField
val
NON_CODE
:
Key
<
Boolean
?>
=
Key
.
create
(
"groovy.process.non.code.members"
)
val
NON_CODE
:
Key
<
Boolean
?>
=
Key
.
create
(
"groovy.process.non.code.members"
)
val
sorryCannotKnowElementKind
:
Key
<
Boolean
>
=
Key
.
create
(
"groovy.skip.kind.check.please"
)
fun
initialState
(
processNonCodeMembers
:
Boolean
):
ResolveState
=
ResolveState
.
initial
().
put
(
NON_CODE
,
processNonCodeMembers
)
fun
initialState
(
processNonCodeMembers
:
Boolean
):
ResolveState
=
ResolveState
.
initial
().
put
(
NON_CODE
,
processNonCodeMembers
)
fun
ResolveState
.
processNonCodeMembers
():
Boolean
=
get
(
NON_CODE
).
let
{
it
==
null
||
it
}
fun
ResolveState
.
processNonCodeMembers
():
Boolean
=
get
(
NON_CODE
).
let
{
it
==
null
||
it
}
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/caches/fileCache.kt
+
9
-
2
View file @
0e576f35
...
@@ -11,6 +11,7 @@ import com.intellij.util.containers.MostlySingularMultiMap
...
@@ -11,6 +11,7 @@ import com.intellij.util.containers.MostlySingularMultiMap
import
org.jetbrains.plugins.groovy.lang.resolve.AnnotationHint
import
org.jetbrains.plugins.groovy.lang.resolve.AnnotationHint
import
org.jetbrains.plugins.groovy.lang.resolve.getName
import
org.jetbrains.plugins.groovy.lang.resolve.getName
import
org.jetbrains.plugins.groovy.lang.resolve.imports.importedNameKey
import
org.jetbrains.plugins.groovy.lang.resolve.imports.importedNameKey
import
org.jetbrains.plugins.groovy.lang.resolve.sorryCannotKnowElementKind
private
data class
ElementWithState
(
val
element
:
PsiElement
,
val
state
:
ResolveState
)
private
data class
ElementWithState
(
val
element
:
PsiElement
,
val
state
:
ResolveState
)
...
@@ -46,10 +47,16 @@ class FileCacheBuilderProcessor(private val annotationResolve: Boolean) : PsiSco
...
@@ -46,10 +47,16 @@ class FileCacheBuilderProcessor(private val annotationResolve: Boolean) : PsiSco
private
class
FileDeclarationsCache
(
private
val
declarations
:
MostlySingularMultiMap
<
String
,
ElementWithState
>)
:
DeclarationHolder
{
private
class
FileDeclarationsCache
(
private
val
declarations
:
MostlySingularMultiMap
<
String
,
ElementWithState
>)
:
DeclarationHolder
{
override
fun
processDeclarations
(
processor
:
PsiScopeProcessor
,
state
:
ResolveState
,
place
:
PsiElement
):
Boolean
{
override
fun
processDeclarations
(
processor
:
PsiScopeProcessor
,
state
:
ResolveState
,
place
:
PsiElement
):
Boolean
{
val
newState
=
state
.
put
(
sorryCannotKnowElementKind
,
true
)
val
declarationProcessor
=
{
(
element
,
cachedState
):
ElementWithState
->
val
declarationProcessor
=
{
(
element
,
cachedState
):
ElementWithState
->
processor
.
execute
(
element
,
s
tate
.
putAll
(
cachedState
))
processor
.
execute
(
element
,
newS
tate
.
putAll
(
cachedState
))
}
}
val
name
=
processor
.
getName
(
state
)
val
name
=
processor
.
getName
(
state
)
return
if
(
name
==
null
)
declarations
.
processAllValues
(
declarationProcessor
)
else
declarations
.
processForKey
(
name
,
declarationProcessor
)
return
if
(
name
==
null
)
{
declarations
.
processAllValues
(
declarationProcessor
)
}
else
{
declarations
.
processForKey
(
name
,
declarationProcessor
)
}
}
}
}
}
This diff is collapsed.
Click to expand it.
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/processors/KindsResolverProcessor.kt
+
15
-
3
View file @
0e576f35
...
@@ -12,6 +12,7 @@ import org.jetbrains.plugins.groovy.lang.psi.util.elementInfo
...
@@ -12,6 +12,7 @@ import org.jetbrains.plugins.groovy.lang.psi.util.elementInfo
import
org.jetbrains.plugins.groovy.lang.resolve.BaseGroovyResolveResult
import
org.jetbrains.plugins.groovy.lang.resolve.BaseGroovyResolveResult
import
org.jetbrains.plugins.groovy.lang.resolve.getName
import
org.jetbrains.plugins.groovy.lang.resolve.getName
import
org.jetbrains.plugins.groovy.lang.resolve.getResolveKind
import
org.jetbrains.plugins.groovy.lang.resolve.getResolveKind
import
org.jetbrains.plugins.groovy.lang.resolve.sorryCannotKnowElementKind
open
class
KindsResolverProcessor
(
open
class
KindsResolverProcessor
(
protected
val
name
:
String
,
protected
val
name
:
String
,
...
@@ -41,9 +42,20 @@ open class KindsResolverProcessor(
...
@@ -41,9 +42,20 @@ open class KindsResolverProcessor(
val
elementName
=
getName
(
state
,
element
)
val
elementName
=
getName
(
state
,
element
)
if
(
name
!=
elementName
)
return
true
if
(
name
!=
elementName
)
return
true
val
kind
=
getResolveKind
(
element
)
?:
return
true
val
kind
=
requireNotNull
(
getResolveKind
(
element
))
{
if
(
kind
!
in
kinds
)
{
"Unknown kind. ${elementInfo(element)}"
return
true
}
if
(
state
[
sorryCannotKnowElementKind
]
==
true
)
{
if
(
kind
!
in
kinds
)
{
// return without exception
return
true
}
}
else
{
require
(
kind
in
kinds
)
{
"Unneeded kind. ${elementInfo(element)}"
}
}
}
if
(
kind
in
candidates
)
{
if
(
kind
in
candidates
)
{
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/src/org/jetbrains/plugins/groovy/ext/logback/LogbackDelegateMemberContributor.kt
+
4
-
0
View file @
0e576f35
...
@@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
...
@@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
import
org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.DELEGATES_TO_KEY
import
org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.DELEGATES_TO_KEY
import
org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.DELEGATES_TO_STRATEGY_KEY
import
org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.DELEGATES_TO_STRATEGY_KEY
import
org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.getContainingCall
import
org.jetbrains.plugins.groovy.lang.resolve.delegatesTo.getContainingCall
import
org.jetbrains.plugins.groovy.lang.resolve.shouldProcessMethods
import
org.jetbrains.plugins.groovy.lang.resolve.wrapClassType
import
org.jetbrains.plugins.groovy.lang.resolve.wrapClassType
class
LogbackDelegateMemberContributor
:
NonCodeMembersContributor
()
{
class
LogbackDelegateMemberContributor
:
NonCodeMembersContributor
()
{
...
@@ -28,6 +29,9 @@ class LogbackDelegateMemberContributor : NonCodeMembersContributor() {
...
@@ -28,6 +29,9 @@ class LogbackDelegateMemberContributor : NonCodeMembersContributor() {
override
fun
getParentClassName
():
String
=
componentDelegateFqn
override
fun
getParentClassName
():
String
=
componentDelegateFqn
override
fun
processDynamicElements
(
qualifierType
:
PsiType
,
processor
:
PsiScopeProcessor
,
place
:
PsiElement
,
state
:
ResolveState
)
{
override
fun
processDynamicElements
(
qualifierType
:
PsiType
,
processor
:
PsiScopeProcessor
,
place
:
PsiElement
,
state
:
ResolveState
)
{
if
(!
processor
.
shouldProcessMethods
())
{
return
}
val
name
=
processor
.
getHint
(
NameHint
.
KEY
)
?.
getName
(
state
)
val
name
=
processor
.
getHint
(
NameHint
.
KEY
)
?.
getName
(
state
)
val
componentClass
=
getComponentClass
(
place
)
?:
return
val
componentClass
=
getComponentClass
(
place
)
?:
return
val
componentProcessor
=
ComponentProcessor
(
processor
,
place
,
name
)
val
componentProcessor
=
ComponentProcessor
(
processor
,
place
,
name
)
...
...
This diff is collapsed.
Click to expand it.
plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantMemberContributor.java
+
3
-
16
View file @
0e576f35
/*
// 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.
* 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.
*/
package
org.jetbrains.plugins.groovy.gant
;
package
org.jetbrains.plugins.groovy.gant
;
import
com.intellij.psi.*
;
import
com.intellij.psi.*
;
...
@@ -32,6 +18,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
...
@@ -32,6 +18,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
import
org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames
;
import
org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames
;
import
org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor
;
import
org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor
;
import
org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
;
import
org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil
;
import
org.jetbrains.plugins.groovy.lang.resolve.ResolveUtilKt
;
import
org.jetbrains.plugins.groovy.runner.GroovyScriptUtil
;
import
org.jetbrains.plugins.groovy.runner.GroovyScriptUtil
;
/**
/**
...
@@ -95,7 +82,7 @@ public class GantMemberContributor extends NonCodeMembersContributor {
...
@@ -95,7 +82,7 @@ public class GantMemberContributor extends NonCodeMembersContributor {
}
}
}
}
if
(!
antTasksProcessed
)
{
if
(!
antTasksProcessed
&&
ResolveUtilKt
.
shouldProcessMethods
(
processor
)
)
{
processAntTasks
(
processor
,
place
,
state
);
processAntTasks
(
processor
,
place
,
state
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
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