Skip to content

Commit

Permalink
Override new shouldSkipAutopopup, as the old one is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
RedNesto committed Sep 13, 2024
1 parent 44ffaaa commit 15e3806
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.demonwav.mcdev.platform.mixin.handlers.MixinAnnotationHandler
import com.demonwav.mcdev.platform.mixin.util.MixinConstants
import com.intellij.codeInsight.completion.CompletionConfidence
import com.intellij.codeInsight.completion.SkipAutopopupInStrings
import com.intellij.openapi.editor.Editor
import com.intellij.patterns.PlatformPatterns
import com.intellij.patterns.PsiJavaPatterns
import com.intellij.patterns.StandardPatterns
Expand All @@ -47,7 +48,12 @@ class MixinCompletionConfidence : CompletionConfidence() {
PlatformPatterns.psiFile(),
)!!

override fun shouldSkipAutopopup(element: PsiElement, psiFile: PsiFile, offset: Int): ThreeState {
override fun shouldSkipAutopopup(
editor: Editor,
element: PsiElement,
psiFile: PsiFile,
offset: Int
): ThreeState {
// Enable auto complete for all string literals which are children of one of the annotations in Mixin
// TODO: Make this more reliable (we don't need to enable it for all parts of the annotation)
return if (SkipAutopopupInStrings.isInStringLiteral(element) && mixinAnnotation.accepts(element)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ package com.demonwav.mcdev.translations.reference

import com.intellij.codeInsight.completion.CompletionConfidence
import com.intellij.codeInsight.completion.SkipAutopopupInStrings
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.util.ThreeState

class TranslationReferenceCompletionConfidence : CompletionConfidence() {
override fun shouldSkipAutopopup(element: PsiElement, psiFile: PsiFile, offset: Int): ThreeState {

override fun shouldSkipAutopopup(
editor: Editor,
element: PsiElement,
psiFile: PsiFile,
offset: Int
): ThreeState {
return if (
SkipAutopopupInStrings.isInStringLiteral(element) &&
element.parent.references.any { it is TranslationReference }
Expand Down

0 comments on commit 15e3806

Please sign in to comment.