mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -8,19 +8,20 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Helper interface for PSI elements which may be added as ForeignLeaf and need to redirect annotations
|
||||
* to another text range.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ExternallyAnnotated {
|
||||
/**
|
||||
* If inspection started for files with ForeignLeaf substitutions founds any problem in them
|
||||
* it should be able to display them locally. This method allows to define such substitution text range.
|
||||
* it should be able to display it locally. This method allows to define such substitution text range.
|
||||
* An example from C/C++ macro substitution:<br/><pre>
|
||||
* #define T(x) int x
|
||||
* int k;
|
||||
* T(k) = 0; // the problem [duplicate declaration 'k'] need to be annotated
|
||||
* T(k) = 0; // the problem [duplicate declaration 'k'] needs to be annotated
|
||||
* // for macro parameter, not declarator
|
||||
* </pre><br/>
|
||||
* See {@code ProblemDescriptorBase} constructor for details.
|
||||
* See {@link com.intellij.codeInspection.ProblemDescriptorBase} constructor for details.
|
||||
*
|
||||
* @return TextRange to which problem descriptions should be redirected, {@code null} if annotator need to skip the problem
|
||||
* @return TextRange to which problem descriptions should be redirected, {@code null} if annotator needs to skip the problem
|
||||
*/
|
||||
@Nullable
|
||||
TextRange getAnnotationRegion();
|
||||
|
||||
@@ -85,10 +85,7 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable
|
||||
try {
|
||||
return computeIcon(flags);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (IndexNotReadyException e) {
|
||||
catch (ProcessCanceledException | IndexNotReadyException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -70,6 +70,7 @@ public class DummyHolderViewProvider extends AbstractFileViewProvider {
|
||||
return target == getBaseLanguage() ? myHolder : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<PsiFile> getCachedPsiFiles() {
|
||||
return Collections.singletonList(myHolder);
|
||||
|
||||
+7
-6
@@ -29,7 +29,6 @@ import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.tree.FileElement;
|
||||
import com.intellij.psi.templateLanguages.OuterLanguageElement;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.NullableFunction;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,9 +40,9 @@ import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends AbstractFileViewProvider {
|
||||
private final ConcurrentMap<Language, PsiFileImpl> myRoots = ContainerUtil.newConcurrentMap(1, 0.75f, 1);
|
||||
private MultiplePsiFilesPerDocumentFileViewProvider myOriginal = null;
|
||||
private MultiplePsiFilesPerDocumentFileViewProvider myOriginal;
|
||||
|
||||
public MultiplePsiFilesPerDocumentFileViewProvider(PsiManager manager, VirtualFile virtualFile, boolean eventSystemEnabled) {
|
||||
public MultiplePsiFilesPerDocumentFileViewProvider(@NotNull PsiManager manager, @NotNull VirtualFile virtualFile, boolean eventSystemEnabled) {
|
||||
super(manager, virtualFile, eventSystemEnabled, virtualFile.getFileType());
|
||||
}
|
||||
|
||||
@@ -67,7 +66,7 @@ public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends Abstra
|
||||
return roots;
|
||||
}
|
||||
|
||||
protected final void removeFile(final Language language) {
|
||||
protected final void removeFile(@NotNull Language language) {
|
||||
PsiFileImpl file = myRoots.remove(language);
|
||||
if (file != null) {
|
||||
file.markInvalidated();
|
||||
@@ -108,9 +107,10 @@ public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends Abstra
|
||||
return myRoots.get(target);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final List<PsiFile> getCachedPsiFiles() {
|
||||
return ContainerUtil.mapNotNull(myRoots.keySet(), (NullableFunction<Language, PsiFile>)language -> getCachedPsi(language));
|
||||
return ContainerUtil.mapNotNull(myRoots.keySet(), this::getCachedPsi);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -148,7 +148,8 @@ public abstract class MultiplePsiFilesPerDocumentFileViewProvider extends Abstra
|
||||
return copy;
|
||||
}
|
||||
|
||||
protected abstract MultiplePsiFilesPerDocumentFileViewProvider cloneInner(VirtualFile fileCopy);
|
||||
@NotNull
|
||||
protected abstract MultiplePsiFilesPerDocumentFileViewProvider cloneInner(@NotNull VirtualFile fileCopy);
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
|
||||
@@ -149,6 +149,7 @@ public class SingleRootFileViewProvider extends AbstractFileViewProvider impleme
|
||||
return file == PsiUtilCore.NULL_PSI_FILE ? null : file;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final List<PsiFile> getCachedPsiFiles() {
|
||||
return ContainerUtil.createMaybeSingletonList(getCachedPsi(getBaseLanguage()));
|
||||
@@ -219,7 +220,6 @@ public class SingleRootFileViewProvider extends AbstractFileViewProvider impleme
|
||||
return contentSize > PersistentFSConstants.getMaxIntellisenseFileSize();
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
public static boolean isTooLargeForContentLoading(@NotNull VirtualFile vFile, final long contentSize) {
|
||||
return contentSize > PersistentFSConstants.FILE_LENGTH_TO_CACHE_THRESHOLD;
|
||||
}
|
||||
|
||||
@@ -193,8 +193,9 @@ public class TextRange implements Segment, Serializable {
|
||||
|
||||
@Nullable
|
||||
public TextRange intersection(@NotNull TextRange range) {
|
||||
if (!intersects(range)) return null;
|
||||
return new TextRange(Math.max(myStartOffset, range.getStartOffset()), Math.min(myEndOffset, range.getEndOffset()));
|
||||
int newStart = Math.max(myStartOffset, range.getStartOffset());
|
||||
int newEnd = Math.min(myEndOffset, range.getEndOffset());
|
||||
return isProperRange(newStart, newEnd) ? new TextRange(newStart, newEnd) : null;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
@@ -224,8 +225,12 @@ public class TextRange implements Segment, Serializable {
|
||||
}
|
||||
|
||||
public static void assertProperRange(int startOffset, int endOffset, @NotNull Object message) {
|
||||
if (startOffset > endOffset || startOffset < 0) {
|
||||
if (!isProperRange(startOffset, endOffset)) {
|
||||
LOG.error("Invalid range specified: (" + startOffset + "," + endOffset + "); " + message);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isProperRange(int startOffset, int endOffset) {
|
||||
return startOffset <= endOffset && startOffset >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +54,9 @@ public class RestFileViewProvider extends MultiplePsiFilesPerDocumentFileViewPro
|
||||
return PythonLanguage.getInstance();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected MultiplePsiFilesPerDocumentFileViewProvider cloneInner(VirtualFile virtualFile) {
|
||||
protected MultiplePsiFilesPerDocumentFileViewProvider cloneInner(@NotNull VirtualFile virtualFile) {
|
||||
return new RestFileViewProvider(getManager(), virtualFile, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user