mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Move assertion
GitOrigin-RevId: 64366d76ea7bfa84260aab2e40b1337da121adb8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2110ad0aa4
commit
6ff5610c5c
+3
-2
@@ -6,6 +6,7 @@ import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -34,7 +35,7 @@ public class CompletionInitializationContext {
|
||||
|
||||
public CompletionInitializationContext(final Editor editor,
|
||||
final @NotNull Caret caret,
|
||||
@NotNull Language language,
|
||||
Language language,
|
||||
final PsiFile file,
|
||||
final CompletionType completionType,
|
||||
int invocationCount) {
|
||||
@@ -74,7 +75,7 @@ public class CompletionInitializationContext {
|
||||
|
||||
@NotNull
|
||||
public Language getPositionLanguage() {
|
||||
return myPositionLanguage;
|
||||
return ObjectUtils.assertNotNull(myPositionLanguage);
|
||||
}
|
||||
|
||||
public String getDummyIdentifier() {
|
||||
|
||||
@@ -44,17 +44,19 @@ public class PsiUtilBase extends PsiUtilCore implements PsiEditorUtil {
|
||||
return host != null && isUnderPsiRoot(root, host);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public static Language getLanguageInEditor(@NotNull final Editor editor, @NotNull final Project project) {
|
||||
return getLanguageInEditor(editor.getCaretModel().getCurrentCaret(), project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public static Language getLanguageInEditor(@NotNull Caret caret, @NotNull final Project project) {
|
||||
Editor editor = caret.getEditor();
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
|
||||
assert file != null;
|
||||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int caretOffset = caret.getOffset();
|
||||
int mostProbablyCorrectLanguageOffset = caretOffset == caret.getSelectionEnd() ? caret.getSelectionStart() : caretOffset;
|
||||
|
||||
Reference in New Issue
Block a user