GitOrigin-RevId: 7e49951d8f4cb38b879baa0315c77c365396430d
This commit is contained in:
Alexey Kudravtsev
2020-06-16 12:33:23 +03:00
committed by intellij-monorepo-bot
parent 6ca8defdf6
commit 3b56d51785
4 changed files with 26 additions and 27 deletions
@@ -154,7 +154,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
* @return a pair where first element is read usages and second is write usages
*/
@NotNull
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, PsiElement psiElement, boolean withDeclarations) {
public static Couple<Collection<TextRange>> getHighlightUsages(@NotNull PsiElement target, @NotNull PsiElement psiElement, boolean withDeclarations) {
return getUsages(target, psiElement, withDeclarations, true);
}
@@ -170,7 +170,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
}
@NotNull
private static Couple<Collection<TextRange>> getUsages(@NotNull PsiElement target, PsiElement psiElement, boolean withDeclarations, boolean detectAccess) {
private static Couple<Collection<TextRange>> getUsages(@NotNull PsiElement target, @NotNull PsiElement psiElement, boolean withDeclarations, boolean detectAccess) {
List<TextRange> readRanges = new ArrayList<>();
List<TextRange> writeRanges = new ArrayList<>();
final ReadWriteAccessDetector detector = detectAccess ? ReadWriteAccessDetector.findDetector(target) : null;
@@ -345,6 +345,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
myEditor, BraceHighlighter.getAlarm(), leftBraceRange.getStartOffset(), leftBraceRange.getEndOffset(), null);
}
@NotNull
private List<HighlightInfo> getHighlights() {
if (myReadAccessRanges.isEmpty() && myWriteAccessRanges.isEmpty() && myCodeBlockMarkerRanges.isEmpty()) {
return Collections.emptyList();
@@ -369,7 +370,8 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
return result;
}
private HighlightInfo createHighlightInfo(TextRange range, HighlightInfoType type, Set<Pair<Object, TextRange>> existingMarkupTooltips) {
@NotNull
private HighlightInfo createHighlightInfo(@NotNull TextRange range, @NotNull HighlightInfoType type, @NotNull Set<Pair<Object, TextRange>> existingMarkupTooltips) {
int start = range.getStartOffset();
String tooltip = start <= myDocument.getTextLength() ? HighlightHandlerBase.getLineTextErrorStripeTooltip(myDocument, start, false) : null;
String unescapedTooltip = existingMarkupTooltips.contains(new Pair<Object, TextRange>(tooltip, range)) ? null : tooltip;
@@ -380,7 +382,7 @@ public class IdentifierHighlighterPass extends TextEditorHighlightingPass {
return builder.createUnconditionally();
}
public static void clearMyHighlights(Document document, Project project) {
public static void clearMyHighlights(@NotNull Document document, @NotNull Project project) {
MarkupModel markupModel = DocumentMarkupModel.forDocument(document, project, true);
for (RangeHighlighter highlighter : markupModel.getAllHighlighters()) {
HighlightInfo info = HighlightInfo.fromRangeHighlighter(highlighter);
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.*;
@State(name="HighlightingSettingsPerFile", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
@State(name = "HighlightingSettingsPerFile", storages = @Storage(StoragePathMacros.WORKSPACE_FILE))
public class HighlightingSettingsPerFile extends HighlightingLevelManager implements PersistentStateComponent<Element> {
@NonNls private static final String SETTING_TAG = "setting";
@NonNls private static final String ROOT_ATT_PREFIX = "root";
@@ -38,7 +38,7 @@ public class HighlightingSettingsPerFile extends HighlightingLevelManager implem
vcsIgnoreFileNames = VcsFacade.getInstance().getVcsIgnoreFileNames(project);
}
public static HighlightingSettingsPerFile getInstance(Project project){
public static HighlightingSettingsPerFile getInstance(Project project) {
return (HighlightingSettingsPerFile)ServiceManager.getService(project, HighlightingLevelManager.class);
}
@@ -56,38 +56,36 @@ public class HighlightingSettingsPerFile extends HighlightingLevelManager implem
Language language = array.get(i);
if (provider.getPsi(language) == file) return i;
}
throw new RuntimeException("Cannot find root for: "+ file);
throw new RuntimeException("Cannot find root for: " + file);
}
@NotNull
public FileHighlightingSetting getHighlightingSettingForRoot(@NotNull PsiElement root){
public FileHighlightingSetting getHighlightingSettingForRoot(@NotNull PsiElement root) {
PsiFile containingFile = root.getContainingFile();
VirtualFile virtualFile = containingFile.getVirtualFile();
FileHighlightingSetting[] fileHighlightingSettings = myHighlightSettings.get(virtualFile);
int index = getRootIndex(containingFile);
if(fileHighlightingSettings == null || fileHighlightingSettings.length <= index) {
return getDefaultHighlightingSetting(root.getProject(), virtualFile);
if (fileHighlightingSettings != null && fileHighlightingSettings.length > index) {
return fileHighlightingSettings[index];
}
return fileHighlightingSettings[index];
return virtualFile == null ? FileHighlightingSetting.FORCE_HIGHLIGHTING : getDefaultHighlightingSetting(root.getProject(), virtualFile);
}
@NotNull
private static FileHighlightingSetting getDefaultHighlightingSetting(@NotNull Project project, VirtualFile virtualFile) {
if (virtualFile != null) {
DefaultHighlightingSettingProvider[] providers = DefaultHighlightingSettingProvider.EP_NAME.getExtensions();
List<DefaultHighlightingSettingProvider> filtered = DumbService.getInstance(project).filterByDumbAwareness(providers);
for (DefaultHighlightingSettingProvider p : filtered) {
FileHighlightingSetting setting = p.getDefaultSetting(project, virtualFile);
if (setting != null) {
return setting;
}
private static FileHighlightingSetting getDefaultHighlightingSetting(@NotNull Project project, @NotNull VirtualFile virtualFile) {
DefaultHighlightingSettingProvider[] providers = DefaultHighlightingSettingProvider.EP_NAME.getExtensions();
List<DefaultHighlightingSettingProvider> filtered = DumbService.getInstance(project).filterByDumbAwareness(providers);
for (DefaultHighlightingSettingProvider p : filtered) {
FileHighlightingSetting setting = p.getDefaultSetting(project, virtualFile);
if (setting != null) {
return setting;
}
}
return FileHighlightingSetting.FORCE_HIGHLIGHTING;
}
private static FileHighlightingSetting @NotNull [] getDefaults(@NotNull PsiFile file){
private static FileHighlightingSetting @NotNull [] getDefaults(@NotNull PsiFile file) {
int rootsCount = file.getViewProvider().getLanguages().size();
FileHighlightingSetting[] fileHighlightingSettings = new FileHighlightingSetting[rootsCount];
Arrays.fill(fileHighlightingSettings, FileHighlightingSetting.FORCE_HIGHLIGHTING);
@@ -184,7 +182,7 @@ public class HighlightingSettingsPerFile extends HighlightingLevelManager implem
return !SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile);
}
public int countRoots(FileHighlightingSetting setting) {
public int countRoots(@NotNull FileHighlightingSetting setting) {
int count = 0;
for (FileHighlightingSetting[] settingsForRoots : myHighlightSettings.values()) {
for (FileHighlightingSetting settingForRoot : settingsForRoots) {
@@ -559,8 +559,8 @@ public final class VirtualFilePointerManagerImpl extends VirtualFilePointerManag
return new ChangeApplier() {
@Override
public void beforeVfsChange() {
//noinspection SynchronizeOnThis
CollectedEvents collected;
//noinspection SynchronizeOnThis
synchronized (VirtualFilePointerManagerImpl.this) {
collected = myCollectedEvents;
if (collected.startModCount == myPointerSetModCount) {
@@ -16,9 +16,9 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
import java.util.function.IntFunction;
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
@ApiStatus.NonExtendable
// cannot be final because of https://plugins.jetbrains.com/plugin/7831-illuminated-cloud
public class ContainerUtil {
@@ -84,7 +84,6 @@ public class ContainerUtil {
/**
* @deprecated Use {@link TreeMap#TreeMap(Map)}
*/
@SuppressWarnings("unused")
@Contract(pure = true)
@Deprecated
public static @NotNull <K extends Comparable<? super K>, V> TreeMap<K, V> newTreeMap(@NotNull Map<? extends K, ? extends V> map) {
@@ -647,7 +646,7 @@ public class ContainerUtil {
}
@Override
public void forEach(java.util.function.Consumer<? super E> action) {
public void forEach(Consumer<? super E> action) {
myStore.forEach(action);
}
}
@@ -682,7 +681,7 @@ public class ContainerUtil {
}
@Override
public void forEach(java.util.function.Consumer<? super E> action) {
public void forEach(Consumer<? super E> action) {
//noinspection ForLoopReplaceableByForEach
for (int i = 0, length = myStore.length; i < length; i++) {
action.accept(myStore[i]);