mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[groovy] add TRANSFORMATION compile phase
This commit is contained in:
+12
@@ -4,8 +4,10 @@ package org.jetbrains.plugins.groovy.lang.psi.util
|
||||
import com.intellij.psi.ResolveState
|
||||
import com.intellij.psi.scope.PsiScopeProcessor
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.CollectClassMembersUtil.getFields
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.CompilationPhaseHint
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.CompilationPhaseHint.Phase.CONVERSION
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.CompilationPhaseHint.Phase.TRANSFORMATION
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil.processElement
|
||||
import org.jetbrains.plugins.groovy.lang.resolve.shouldProcessFields
|
||||
|
||||
@@ -13,6 +15,7 @@ fun GrTypeDefinition.processPhase(processor: PsiScopeProcessor, state: ResolveSt
|
||||
val hint = requireNotNull(processor.getHint(CompilationPhaseHint.HINT_KEY))
|
||||
return when (hint.beforePhase()) {
|
||||
CONVERSION -> processBeforeConversion(processor, state)
|
||||
TRANSFORMATION -> processBeforeTransformations(processor, state)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,3 +27,12 @@ private fun GrTypeDefinition.processBeforeConversion(processor: PsiScopeProcesso
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun GrTypeDefinition.processBeforeTransformations(processor: PsiScopeProcessor, state: ResolveState): Boolean {
|
||||
if (processor.shouldProcessFields()) {
|
||||
for (codeField in getFields(this, false)) { // property nodes removed if field with same name exists
|
||||
if (!processElement(processor, codeField, state)) return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@ public interface CompilationPhaseHint {
|
||||
Key<CompilationPhaseHint> HINT_KEY = Key.create("groovy.compilation.phase");
|
||||
|
||||
enum Phase {
|
||||
CONVERSION
|
||||
CONVERSION,
|
||||
TRANSFORMATION
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user