mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Proved a diagnostics for prebuilt stubs in case of stub/AST mismatch
This commit is contained in:
@@ -28,6 +28,7 @@ import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.util.indexing.FileContent;
|
||||
import com.intellij.util.indexing.FileContentImpl;
|
||||
import com.intellij.util.indexing.IndexingDataKeys;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -83,4 +84,8 @@ public class CoreStubTreeLoader extends StubTreeLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPrebuilt(@NotNull VirtualFile virtualFile) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,14 @@ public abstract class StubTreeLoader {
|
||||
IndexingStampInfo indexingStampInfo = getIndexingStampInfo(file);
|
||||
boolean upToDate = indexingStampInfo != null && indexingStampInfo.isUpToDate(document, file, psiFile);
|
||||
|
||||
boolean canBePrebuilt = isPrebuilt(psiFile.getVirtualFile());
|
||||
|
||||
String msg = _message + "\nPlease report the problem to JetBrains with the files attached\n";
|
||||
|
||||
if (canBePrebuilt) {
|
||||
msg += "This stub can have pre-built origin\n";
|
||||
}
|
||||
|
||||
if (upToDate) {
|
||||
msg += "INDEXED VERSION IS THE CURRENT ONE";
|
||||
}
|
||||
@@ -136,6 +143,8 @@ public abstract class StubTreeLoader {
|
||||
return upToDate ? handleUpToDateMismatch(msg, attachments) : new RuntimeExceptionWithAttachments(msg, attachments);
|
||||
}
|
||||
|
||||
protected abstract boolean isPrebuilt(@NotNull VirtualFile virtualFile);
|
||||
|
||||
private static UpToDateStubIndexMismatch handleUpToDateMismatch(@NotNull String message, Attachment[] attachments) {
|
||||
return new UpToDateStubIndexMismatch(message, attachments);
|
||||
}
|
||||
|
||||
@@ -247,4 +247,22 @@ public class StubTreeLoaderImpl extends StubTreeLoader {
|
||||
protected IndexingStampInfo getIndexingStampInfo(@NotNull VirtualFile file) {
|
||||
return StubUpdatingIndex.getIndexingStampInfo(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPrebuilt(@NotNull VirtualFile virtualFile) {
|
||||
boolean canBePrebuilt = false;
|
||||
try {
|
||||
final PrebuiltStubsProvider prebuiltStubsProvider =
|
||||
PrebuiltStubsProviders.INSTANCE.forFileType(virtualFile.getFileType());
|
||||
if (prebuiltStubsProvider != null) {
|
||||
canBePrebuilt = null !=
|
||||
prebuiltStubsProvider
|
||||
.findStub(new FileContentImpl(virtualFile, virtualFile.contentsToByteArray()));
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// pass
|
||||
}
|
||||
return canBePrebuilt;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user