set psi class super class, completions not working

Morning,

I am setting the super class for a script in the same way that org.jetbrains.plugins.groovy.transformations.impl.BaseScriptTransformationSupport sets it.

So I am trying to do the moral equivalent of "@BaseScript FooBar delegate", without actually having to have that in the script.

Code linting then works for methods defined in the base script. The problem is completions do not work... I have no clue why. 

Any hint would be appreciated, eg which contributor provides completions for methods defined in the base script - I would guess at GrThisSuperCompletionProvider but I can't hit a breakpoint in there.

cheers, jamie

0

These completions are provided by CompleteReferenceExpression#processVariants.

Could you please share the snippet of how you set the super class?

 

0

Hi Daniil - I do it in an AstTransformationSupport:


@Override
void applyTransformation(@NotNull TransformationContext context) {
PsiClassType baseClass = ...
context.setSuperType(baseClass)
}

I'm not sure the best place to do this, but as I said it works ok for linting, and my AstTransformationSupport runs after anything else that could set the superclass.

 

0

From what you described: you are doing it right, your AstTransformationSupport is the last one, setSuperType(), etc.
The fact the resolve/navigation works properly means that the base script is actually added.

Assuming statements above are true: this may be a bug, but I cannot reproduce it. 

You may share the code privately, so I'd be given a chance to debug it myself (daniil.ovchinnikov@jetbrains.com).

0

Thanks Daniil. I tried to debug it in a different way given that you are confirming I am doing it right. 

It turns out that the BaseScriptTransformationSupport is running before my transform, but also after. It's invoked in the flow of CompleteReferenceExpression#processVariants, and then mine does not run again... so it's overwriting the super class.

I've added order="last" to my transform but doesn't appear to make a difference. 

Having said all that, I think there is a way I can disable BaseScriptTransformationSupport and handle what it does, so I'll try that. Thanks again...

 

0

BaseScriptTransformationSupport cannot be run twice on same class with same transformation context.

0

请先登录再写评论。