Skip to content

Commit

Permalink
Refactor: Add project as parameter to `MEExpressionCompletionUtil.a…
Browse files Browse the repository at this point in the history
…ddDefinition`
  • Loading branch information
LlamaLad7 committed Jul 9, 2024
1 parent e654d59 commit a46940c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,15 @@ class MEExpressionAnnotator : Annotator {
) {
if (editor == null) {
MEExpressionCompletionUtil.addDefinition(
project,
startElement,
id,
""
)
return
}
val annotation = MEExpressionCompletionUtil.addDefinition(
project,
startElement,
id,
"dummy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,15 @@ object MEExpressionCompletionUtil {

private fun addDefinition(context: InsertionContext, id: String, definitionValue: String): PsiAnnotation? {
val contextElement = context.file.findElementAt(context.startOffset) ?: return null
return addDefinition(contextElement, id, definitionValue)
return addDefinition(context.project, contextElement, id, definitionValue)
}

fun addDefinition(contextElement: PsiElement, id: String, definitionValue: String): PsiAnnotation? {
val project = contextElement.project
fun addDefinition(
project: Project,
contextElement: PsiElement,
id: String,
definitionValue: String
): PsiAnnotation? {
val injectionHost = contextElement.findMultiInjectionHost() ?: return null
val expressionAnnotation = injectionHost.parentOfType<PsiAnnotation>() ?: return null
if (!expressionAnnotation.hasQualifiedName(MixinConstants.MixinExtras.EXPRESSION)) {
Expand Down

0 comments on commit a46940c

Please sign in to comment.