mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+4
-16
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.java.parser.JavaParser;
|
||||
import com.intellij.lang.java.parser.JavaParserUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -64,7 +63,7 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
|
||||
|
||||
public BaseExternalAnnotationsManager(@NotNull PsiManager psiManager) {
|
||||
myPsiManager = psiManager;
|
||||
LowMemoryWatcher.register(() -> dropCache(), psiManager.getProject());
|
||||
LowMemoryWatcher.register(this::dropCache, psiManager.getProject());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -154,14 +153,8 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
|
||||
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
|
||||
saxParser.parse(new InputSource(new CharSequenceReader(escapeAttributes(file.getViewProvider().getContents()))), handler);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (ParserConfigurationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
catch (SAXException e) {
|
||||
LOG.error(e);
|
||||
catch (IOException | ParserConfigurationException | SAXException e) {
|
||||
LOG.error(file.getViewProvider().getVirtualFile().getPath(), e);
|
||||
}
|
||||
|
||||
MostlySingularMultiMap<String, AnnotationData> result = handler.getResult();
|
||||
@@ -389,12 +382,7 @@ public abstract class BaseExternalAnnotationsManager extends ExternalAnnotations
|
||||
}
|
||||
}
|
||||
|
||||
private static final JavaParserUtil.ParserWrapper ANNOTATION = new JavaParserUtil.ParserWrapper() {
|
||||
@Override
|
||||
public void parse(final PsiBuilder builder) {
|
||||
JavaParser.INSTANCE.getDeclarationParser().parseAnnotation(builder);
|
||||
}
|
||||
};
|
||||
private static final JavaParserUtil.ParserWrapper ANNOTATION = JavaParser.INSTANCE.getDeclarationParser()::parseAnnotation;
|
||||
|
||||
private class DataParsingSaxHandler extends DefaultHandler {
|
||||
private final MostlySingularMultiMap<String, AnnotationData> myData = new MostlySingularMultiMap<>();
|
||||
|
||||
@@ -36,20 +36,14 @@ public class FileContent extends UserDataHolderBase {
|
||||
myVirtualFile = virtualFile;
|
||||
}
|
||||
|
||||
public void cache() throws IOException {
|
||||
getBytes();
|
||||
getLength();
|
||||
getTimeStamp();
|
||||
isWritable();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public byte[] getBytes() throws IOException {
|
||||
if (myCachedBytes == null) {
|
||||
if (myVirtualFile.isValid()) {
|
||||
myCachedTimeStamp = myVirtualFile.getTimeStamp();
|
||||
myCachedBytes = myVirtualFile.contentsToByteArray(false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
myCachedTimeStamp = -1;
|
||||
myCachedBytes = ArrayUtil.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.util.List;
|
||||
*/
|
||||
public class StubTreeLoaderImpl extends StubTreeLoader {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.stubs.StubTreeLoaderImpl");
|
||||
private static volatile boolean ourStubReloadingProhibited = false;
|
||||
private static volatile boolean ourStubReloadingProhibited;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -57,9 +57,8 @@ public class StubTreeLoaderImpl extends StubTreeLoader {
|
||||
try {
|
||||
byte[] content = vFile.contentsToByteArray();
|
||||
vFile.setPreloadedContentHint(content);
|
||||
final FileContent fc;
|
||||
try {
|
||||
fc = new FileContentImpl(vFile, content);
|
||||
final FileContent fc = new FileContentImpl(vFile, content);
|
||||
fc.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
if (psiFile != null && !vFile.getFileType().isBinary()) {
|
||||
fc.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, psiFile.getViewProvider().getContents());
|
||||
@@ -130,7 +129,7 @@ public class StubTreeLoaderImpl extends StubTreeLoader {
|
||||
checkDeserializationCreatesNoPsi(tree);
|
||||
return tree;
|
||||
}
|
||||
else if (size != 0) {
|
||||
if (size != 0) {
|
||||
return processError(vFile, "Twin stubs: " + vFile.getPresentableUrl() + " has " + size + " stub versions. Should only have one. id=" + id,
|
||||
null);
|
||||
}
|
||||
|
||||
@@ -1486,10 +1486,9 @@ public class FileBasedIndexImpl extends FileBasedIndex implements BaseComponent,
|
||||
|
||||
private void doIndexFileContent(@Nullable Project project, @NotNull final com.intellij.ide.caches.FileContent content) {
|
||||
final VirtualFile file = content.getVirtualFile();
|
||||
|
||||
final FileType fileType = file.getFileType();
|
||||
final Project finalProject = project == null ? ProjectUtil.guessProjectForFile(file) : project;
|
||||
myFileTypeManager.freezeFileTypeTemporarilyIn(file, () -> {
|
||||
final FileType fileType = file.getFileType();
|
||||
final Project finalProject = project == null ? ProjectUtil.guessProjectForFile(file) : project;
|
||||
PsiFile psiFile = null;
|
||||
FileContentImpl fc = null;
|
||||
int inputId = -1;
|
||||
|
||||
-2
@@ -111,8 +111,6 @@ public class ChangeFileEncodingAction extends AnAction implements DumbAware {
|
||||
final Document document,
|
||||
final byte[] bytes,
|
||||
@Nullable final String clearItemText) {
|
||||
final String text = document == null ? null : document.getText();
|
||||
|
||||
return new ChooseFileEncodingAction(myFile) {
|
||||
@Override
|
||||
public void update(final AnActionEvent e) {
|
||||
|
||||
+7
-9
@@ -519,15 +519,13 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
|
||||
return content;
|
||||
}
|
||||
else {
|
||||
try {
|
||||
assert length >= 0 : file;
|
||||
return FileUtil.loadBytes(contentStream, (int)length);
|
||||
}
|
||||
catch (IOException e) {
|
||||
FSRecords.handleError(e);
|
||||
return ArrayUtil.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
try {
|
||||
assert length >= 0 : file;
|
||||
return FileUtil.loadBytes(contentStream, (int)length);
|
||||
}
|
||||
catch (IOException e) {
|
||||
FSRecords.handleError(e);
|
||||
return ArrayUtil.EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user