mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-63712
This commit is contained in:
+4
-1
@@ -345,7 +345,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
|
||||
TextRange textRange = place.getRangeInsideHost().shiftRight(place.host.getTextRange().getStartOffset());
|
||||
if (textRange.isEmpty()) continue;
|
||||
String desc = injectedPsi.getLanguage().getDisplayName() + ": " + injectedPsi.getText();
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT, textRange, null, desc, injectedAttributes);
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_BACKGROUND, textRange, null, desc, injectedAttributes);
|
||||
info.fromInjection = true;
|
||||
outInfos.add(info);
|
||||
}
|
||||
@@ -521,6 +521,9 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP
|
||||
forcedAttributes = TextAttributes.ERASE_MARKER;
|
||||
}
|
||||
else {
|
||||
HighlightInfo info = HighlightInfo.createHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT, annRange, null,null,TextAttributes.ERASE_MARKER);
|
||||
holder.add(info);
|
||||
|
||||
Color back = attributes.getBackgroundColor() == null ? myGlobalScheme.getDefaultBackground() : attributes.getBackgroundColor();
|
||||
Color fore = attributes.getForegroundColor() == null ? myGlobalScheme.getDefaultForeground() : attributes.getForegroundColor();
|
||||
forcedAttributes = new TextAttributes(fore, back, attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType());
|
||||
|
||||
@@ -90,7 +90,9 @@ public interface HighlightInfoType {
|
||||
HighlightInfoType TODO = new HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, null); // t.o.d.o attributes depend on the t.o.d.o text
|
||||
HighlightInfoType UNHANDLED_EXCEPTION = new HighlightInfoTypeImpl(HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES);
|
||||
|
||||
HighlightSeverity INJECTED_FRAGMENT_SEVERITY = new HighlightSeverity("INJECTED_FRAGMENT", SYMBOL_TYPE_SEVERITY.myVal - 1);
|
||||
HighlightInfoType INJECTED_LANGUAGE_FRAGMENT = new HighlightInfoTypeImpl(SYMBOL_TYPE_SEVERITY, CodeInsightColors.INFORMATION_ATTRIBUTES);
|
||||
HighlightInfoType INJECTED_LANGUAGE_BACKGROUND = new HighlightInfoTypeImpl(INJECTED_FRAGMENT_SEVERITY, CodeInsightColors.INFORMATION_ATTRIBUTES);
|
||||
|
||||
@NotNull
|
||||
HighlightSeverity getSeverity(@Nullable PsiElement psiElement);
|
||||
|
||||
+3
@@ -489,6 +489,9 @@ public class UpdateHighlightersUtil {
|
||||
else if (severityRegistrar.compare(severity, HighlightSeverity.ERROR) >= 0) {
|
||||
layer = HighlighterLayer.ERROR;
|
||||
}
|
||||
else if (severity == HighlightInfoType.INJECTED_FRAGMENT_SEVERITY) {
|
||||
layer = HighlighterLayer.CARET_ROW-1;
|
||||
}
|
||||
else {
|
||||
layer = HighlighterLayer.ADDITIONAL_SYNTAX;
|
||||
}
|
||||
|
||||
+7
-8
@@ -30,6 +30,7 @@ import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -42,15 +43,14 @@ public class HighlightingSettingsPerFile implements PersistentStateComponent<Ele
|
||||
@NonNls private static final String ROOT_ATT_PREFIX = "root";
|
||||
@NonNls private static final String FILE_ATT = "file";
|
||||
|
||||
public static HighlightingSettingsPerFile getInstance(Project progect){
|
||||
return ServiceManager.getService(progect, HighlightingSettingsPerFile.class);
|
||||
public static HighlightingSettingsPerFile getInstance(Project project){
|
||||
return ServiceManager.getService(project, HighlightingSettingsPerFile.class);
|
||||
}
|
||||
|
||||
private final Map<VirtualFile, FileHighlighingSetting[]> myHighlightSettings = new HashMap<VirtualFile, FileHighlighingSetting[]>();
|
||||
|
||||
private final Map<PsiFile, InspectionProfile> myProfileSettings = new WeakHashMap<PsiFile, InspectionProfile>();
|
||||
|
||||
public FileHighlighingSetting getHighlightingSettingForRoot(PsiElement root){
|
||||
public FileHighlighingSetting getHighlightingSettingForRoot(@NotNull PsiElement root){
|
||||
final PsiFile containingFile = root.getContainingFile();
|
||||
final VirtualFile virtualFile = containingFile.getVirtualFile();
|
||||
FileHighlighingSetting[] fileHighlighingSettings = myHighlightSettings.get(virtualFile);
|
||||
@@ -62,7 +62,7 @@ public class HighlightingSettingsPerFile implements PersistentStateComponent<Ele
|
||||
return fileHighlighingSettings[index];
|
||||
}
|
||||
|
||||
public static FileHighlighingSetting[] getDefaults(PsiFile file){
|
||||
public static FileHighlighingSetting[] getDefaults(@NotNull PsiFile file){
|
||||
final int rootsCount = file.getViewProvider().getLanguages().size();
|
||||
final FileHighlighingSetting[] fileHighlighingSettings = new FileHighlighingSetting[rootsCount];
|
||||
for (int i = 0; i < fileHighlighingSettings.length; i++) {
|
||||
@@ -71,7 +71,7 @@ public class HighlightingSettingsPerFile implements PersistentStateComponent<Ele
|
||||
return fileHighlighingSettings;
|
||||
}
|
||||
|
||||
public void setHighlightingSettingForRoot(PsiElement root, FileHighlighingSetting setting) {
|
||||
public void setHighlightingSettingForRoot(@NotNull PsiElement root, @NotNull FileHighlighingSetting setting) {
|
||||
final PsiFile containingFile = root.getContainingFile();
|
||||
final VirtualFile virtualFile = containingFile.getVirtualFile();
|
||||
if (virtualFile == null) return;
|
||||
@@ -134,8 +134,7 @@ public class HighlightingSettingsPerFile implements PersistentStateComponent<Ele
|
||||
myProfileSettings.clear();
|
||||
}
|
||||
|
||||
public synchronized InspectionProfile getInspectionProfile(final PsiFile file) {
|
||||
public synchronized InspectionProfile getInspectionProfile(@NotNull PsiFile file) {
|
||||
return myProfileSettings.get(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-2
@@ -37,6 +37,7 @@ import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointListener;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.PluginDescriptor;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -137,8 +138,10 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme
|
||||
final Processor<DocumentWindow> commitProcessor = new Processor<DocumentWindow>() {
|
||||
@Override
|
||||
public boolean process(DocumentWindow documentWindow) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (documentManager.isUncommited(hostDocument)) return false; // will be committed later
|
||||
if (myProject.isDisposed()) return false;
|
||||
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
|
||||
if (indicator != null && indicator.isCanceled()) return false;
|
||||
if (documentManager.isUncommited(hostDocument) || !hostPsiFile.isValid()) return false; // will be committed later
|
||||
|
||||
RangeMarker rangeMarker = documentWindow.getHostRanges()[0];
|
||||
PsiElement element = rangeMarker.isValid() ? hostPsiFile.findElementAt(rangeMarker.getStartOffset()) : null;
|
||||
@@ -173,6 +176,7 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme
|
||||
final Runnable commitInjectionsRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (myProgress.isCanceled()) return;
|
||||
JobUtil.invokeConcurrentlyUnderProgress(new ArrayList<DocumentWindow>(injected), myProgress, !synchronously, commitProcessor);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -385,7 +385,7 @@ public final class IterationState {
|
||||
}
|
||||
|
||||
TextAttributes textAttributes = highlighter.getTextAttributes();
|
||||
if (textAttributes != null) {
|
||||
if (textAttributes != null && textAttributes != TextAttributes.ERASE_MARKER) {
|
||||
cachedAttributes.add(textAttributes);
|
||||
}
|
||||
}
|
||||
@@ -393,8 +393,8 @@ public final class IterationState {
|
||||
if (selection != null) cachedAttributes.add(selection);
|
||||
if (fold != null) cachedAttributes.add(fold);
|
||||
if (guard != null) cachedAttributes.add(guard);
|
||||
if (syntax != null) cachedAttributes.add(syntax);
|
||||
if (caret != null) cachedAttributes.add(caret);
|
||||
if (syntax != null) cachedAttributes.add(syntax);
|
||||
|
||||
Color fore = null;
|
||||
Color back = isInGuardedBlock ? myReadOnlyColor : null;
|
||||
|
||||
+8
-11
@@ -120,12 +120,10 @@ public class ExpectedHighlightingData {
|
||||
boolean checkWeakWarnings = false;
|
||||
boolean checkInfos = false;
|
||||
|
||||
|
||||
|
||||
highlightingTypes.put(ERROR_MARKER, new ExpectedHighlightingSet(HighlightSeverity.ERROR, false, true));
|
||||
highlightingTypes.put(WARNING_MARKER, new ExpectedHighlightingSet(HighlightSeverity.WARNING, false, checkWarnings));
|
||||
highlightingTypes.put(WEAK_WARNING_MARKER, new ExpectedHighlightingSet(HighlightSeverity.WEAK_WARNING, false, checkWeakWarnings));
|
||||
//highlightingTypes.put("inject", new ExpectedHighlightingSet(HighlightInfoType.INJECTED_FRAGMENT_SEVERITY, false, checkInfos));
|
||||
highlightingTypes.put("inject", new ExpectedHighlightingSet(HighlightInfoType.INJECTED_FRAGMENT_SEVERITY, false, checkInfos));
|
||||
highlightingTypes.put(INFO_MARKER, new ExpectedHighlightingSet(HighlightSeverity.INFORMATION, false, checkInfos));
|
||||
highlightingTypes.put("symbolName", new ExpectedHighlightingSet(HighlightInfoType.SYMBOL_TYPE_SEVERITY, false, false));
|
||||
for (SeveritiesProvider provider : Extensions.getExtensions(SeveritiesProvider.EP_NAME)) {
|
||||
@@ -162,8 +160,7 @@ public class ExpectedHighlightingData {
|
||||
}
|
||||
public void checkInfos() {
|
||||
highlightingTypes.put(INFO_MARKER, new ExpectedHighlightingSet(HighlightSeverity.INFORMATION, false, true));
|
||||
//highlightingTypes.put("inject", new ExpectedHighlightingSet(HighlightInfoType.INJECTED_FRAGMENT_SEVERITY, false, true));
|
||||
|
||||
highlightingTypes.put("inject", new ExpectedHighlightingSet(HighlightInfoType.INJECTED_FRAGMENT_SEVERITY, false, true));
|
||||
}
|
||||
public void checkSymbolNames() {
|
||||
highlightingTypes.put("symbolName", new ExpectedHighlightingSet(HighlightInfoType.SYMBOL_TYPE_SEVERITY, false, true));
|
||||
@@ -357,7 +354,7 @@ public class ExpectedHighlightingData {
|
||||
int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0);
|
||||
int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0);
|
||||
|
||||
if (failMessage.length() != 0) failMessage += '\n';
|
||||
if (!failMessage.isEmpty()) failMessage += '\n';
|
||||
failMessage += fileName + "Extra line marker highlighted " +
|
||||
"(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" +
|
||||
"(" + (x2 + 1) + ", " + (y2 + 1) + ")"
|
||||
@@ -377,7 +374,7 @@ public class ExpectedHighlightingData {
|
||||
int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0);
|
||||
int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0);
|
||||
|
||||
if (failMessage.length() != 0) failMessage += '\n';
|
||||
if (!failMessage.isEmpty()) failMessage += '\n';
|
||||
failMessage += fileName + "Line marker was not highlighted " +
|
||||
"(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" +
|
||||
"(" + (x2 + 1) + ", " + (y2 + 1) + ")"
|
||||
@@ -386,7 +383,7 @@ public class ExpectedHighlightingData {
|
||||
}
|
||||
}
|
||||
|
||||
if (failMessage.length() > 0) Assert.fail(failMessage);
|
||||
if (!failMessage.isEmpty()) Assert.fail(failMessage);
|
||||
}
|
||||
|
||||
private static boolean containsLineMarker(LineMarkerInfo info, Collection<LineMarkerInfo> where) {
|
||||
@@ -427,7 +424,7 @@ public class ExpectedHighlightingData {
|
||||
int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0);
|
||||
int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0);
|
||||
|
||||
if (failMessage.length() != 0) failMessage += '\n';
|
||||
if (!failMessage.isEmpty()) failMessage += '\n';
|
||||
failMessage += fileName + "Extra text fragment highlighted " +
|
||||
"(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" +
|
||||
"(" + (x2 + 1) + ", " + (y2 + 1) + ")" +
|
||||
@@ -453,7 +450,7 @@ public class ExpectedHighlightingData {
|
||||
int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0);
|
||||
int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0);
|
||||
|
||||
if (failMessage.length() != 0) failMessage += '\n';
|
||||
if (!failMessage.isEmpty()) failMessage += '\n';
|
||||
failMessage += fileName + "Text fragment was not highlighted " +
|
||||
"(" + (x1 + 1) + ", " + (y1 + 1) + ")" + "-" +
|
||||
"(" + (x2 + 1) + ", " + (y2 + 1) + ")" +
|
||||
@@ -464,7 +461,7 @@ public class ExpectedHighlightingData {
|
||||
}
|
||||
}
|
||||
|
||||
if (failMessage.length() > 0) {
|
||||
if (!failMessage.isEmpty()) {
|
||||
compareTexts(infos, text, failMessage, filePath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user