Move assertion

GitOrigin-RevId: 64366d76ea7bfa84260aab2e40b1337da121adb8
This commit is contained in:
Dmitry Trofimov
2019-09-17 13:32:17 +00:00
committed by intellij-monorepo-bot
parent 2110ad0aa4
commit 6ff5610c5c
2 changed files with 8 additions and 5 deletions
@@ -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;