mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migrate to newer API
This commit is contained in:
+1
-1
@@ -148,7 +148,7 @@ public class InjectedGeneralHighlightingPass extends GeneralHighlightingPass imp
|
||||
@NotNull final ProgressIndicator progress) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
|
||||
List<DocumentWindow> injected = InjectedLanguageUtil.getCachedInjectedDocuments(myFile);
|
||||
List<DocumentWindow> injected = InjectedLanguageManager.getInstance(myProject).getCachedInjectedDocumentsInRange(myFile, myFile.getTextRange());
|
||||
final Collection<PsiElement> hosts = new THashSet<>(elements1.size() + elements2.size() + injected.size());
|
||||
|
||||
//rehighlight all injected PSI regardless the range,
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.codeInsight.highlighting.NontrivialBraceMatcher;
|
||||
import com.intellij.codeInsight.template.impl.editorActions.TypedActionHandlerBase;
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -42,6 +43,7 @@ import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import com.intellij.openapi.fileTypes.PlainTextLanguage;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.ProperTextRange;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -336,7 +338,8 @@ public class TypedHandler extends TypedActionHandlerBase {
|
||||
// even for uncommitted document try to retrieve injected fragment that has been there recently
|
||||
// we are assuming here that when user is (even furiously) typing, injected language would not change
|
||||
// and thus we can use its lexer to insert closing braces etc
|
||||
for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(oldFile)) {
|
||||
List<DocumentWindow> injected = InjectedLanguageManager.getInstance(oldFile.getProject()).getCachedInjectedDocumentsInRange(oldFile, ProperTextRange.create(offset, offset));
|
||||
for (DocumentWindow documentWindow : injected) {
|
||||
if (documentWindow.isValid() && documentWindow.containsRange(offset, offset)) {
|
||||
PsiFile injectedFile = PsiDocumentManager.getInstance(oldFile.getProject()).getPsiFile(documentWindow);
|
||||
if (injectedFile != null) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.lang.Language;
|
||||
import com.intellij.lang.folding.FoldingBuilder;
|
||||
import com.intellij.lang.folding.FoldingDescriptor;
|
||||
import com.intellij.lang.folding.LanguageFolding;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -140,7 +141,7 @@ public class FoldingUpdate {
|
||||
Object lastTimeStamp = editor.getUserData(LAST_UPDATE_INJECTED_STAMP_KEY);
|
||||
if (lastTimeStamp instanceof Long && ((Long)lastTimeStamp).longValue() == timeStamp) return null;
|
||||
|
||||
List<DocumentWindow> injectedDocuments = InjectedLanguageUtil.getCachedInjectedDocuments(file);
|
||||
List<DocumentWindow> injectedDocuments = InjectedLanguageManager.getInstance(project).getCachedInjectedDocumentsInRange(file, file.getTextRange());
|
||||
if (injectedDocuments.isEmpty()) return null;
|
||||
final List<EditorWindow> injectedEditors = new ArrayList<>();
|
||||
final List<PsiFile> injectedFiles = new ArrayList<>();
|
||||
|
||||
@@ -992,7 +992,8 @@ public class LookupImpl extends LightweightHint implements LookupEx, Disposable
|
||||
PsiFile hostFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myEditor.getDocument());
|
||||
if (hostFile != null) {
|
||||
// inspired by com.intellij.codeInsight.editorActions.TypedHandler.injectedEditorIfCharTypedIsSignificant()
|
||||
for (DocumentWindow documentWindow : InjectedLanguageUtil.getCachedInjectedDocuments(hostFile)) {
|
||||
List<DocumentWindow> injected = InjectedLanguageManager.getInstance(myProject).getCachedInjectedDocumentsInRange(hostFile, TextRange.create(offset, offset));
|
||||
for (DocumentWindow documentWindow : injected ) {
|
||||
if (documentWindow.isValid() && documentWindow.containsRange(offset, offset)) {
|
||||
return documentWindow;
|
||||
}
|
||||
|
||||
@@ -19,12 +19,13 @@ package com.intellij.psi.formatter.common;
|
||||
import com.intellij.formatting.*;
|
||||
import com.intellij.injected.editor.DocumentWindow;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -95,13 +96,14 @@ public abstract class AbstractBlock implements ASTBlock, ExtraRangesProvider {
|
||||
if (file == null) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
if (InjectedLanguageUtil.getCachedInjectedDocuments(file).isEmpty()) {
|
||||
|
||||
TextRange blockRange = myNode.getTextRange();
|
||||
PsiManager psiManager = null;
|
||||
List<DocumentWindow> documentWindows = InjectedLanguageManager.getInstance(psiManager.getProject()).getCachedInjectedDocumentsInRange(file, blockRange);
|
||||
if (documentWindows.isEmpty()) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
TextRange blockRange = myNode.getTextRange();
|
||||
List<DocumentWindow> documentWindows = InjectedLanguageUtil.getCachedInjectedDocuments(file);
|
||||
|
||||
for (DocumentWindow documentWindow : documentWindows) {
|
||||
int startOffset = documentWindow.injectedToHost(0);
|
||||
int endOffset = startOffset + documentWindow.getTextLength();
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ public class CodeFormatterFacade {
|
||||
final LinkedHashSet<TextRange> injectedFileRangesSet = ContainerUtilRt.newLinkedHashSet();
|
||||
|
||||
if (!psi.getProject().isDefault()) {
|
||||
List<DocumentWindow> injectedDocuments = InjectedLanguageUtil.getCachedInjectedDocuments(file);
|
||||
List<DocumentWindow> injectedDocuments = InjectedLanguageManager.getInstance(file.getProject()).getCachedInjectedDocumentsInRange(file, file.getTextRange());
|
||||
if (!injectedDocuments.isEmpty()) {
|
||||
for (DocumentWindow injectedDocument : injectedDocuments) {
|
||||
injectedFileRangesSet.add(TextRange.from(injectedDocument.injectedToHost(0), injectedDocument.getTextLength()));
|
||||
|
||||
Reference in New Issue
Block a user