mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid NPEs in command-line diff application
This commit is contained in:
+12
-10
@@ -56,17 +56,19 @@ public class PsiAwareTextEditorProvider extends TextEditorProvider implements As
|
||||
LOG.error("Cannot open text editor for " + file);
|
||||
}
|
||||
CodeFoldingState state = null;
|
||||
try {
|
||||
Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (document != null) {
|
||||
state = CodeFoldingManager.getInstance(project).buildInitialFoldings(document);
|
||||
if (!project.isDefault()) { // There's no CodeFoldingManager for default project (which is used in diff command-line application)
|
||||
try {
|
||||
Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
if (document != null) {
|
||||
state = CodeFoldingManager.getInstance(project).buildInitialFoldings(document);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Error building initial foldings", e);
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error("Error building initial foldings", e);
|
||||
}
|
||||
final CodeFoldingState finalState = state;
|
||||
return new Builder() {
|
||||
|
||||
+5
-2
@@ -133,7 +133,9 @@ class TextEditorComponent extends JBLoadingPanel implements DataProvider {
|
||||
*/
|
||||
void dispose(){
|
||||
myDocument.removeDocumentListener(myDocumentListener);
|
||||
EditorHistoryManager.getInstance(myProject).updateHistoryEntry(myFile, false);
|
||||
if (!myProject.isDefault()) { // There's no EditorHistoryManager for default project (which is used in diff command-line application)
|
||||
EditorHistoryManager.getInstance(myProject).updateHistoryEntry(myFile, false);
|
||||
}
|
||||
disposeEditor(myEditor);
|
||||
myConnection.disconnect();
|
||||
|
||||
@@ -276,7 +278,8 @@ class TextEditorComponent extends JBLoadingPanel implements DataProvider {
|
||||
final Editor e = validateCurrentEditor();
|
||||
if (e == null) return null;
|
||||
|
||||
if (!myProject.isDisposed()) {
|
||||
// There's no FileEditorManager for default project (which is used in diff command-line application)
|
||||
if (!myProject.isDisposed() && !myProject.isDefault()) {
|
||||
final Object o = FileEditorManager.getInstance(myProject).getData(dataId, e, e.getCaretModel().getCurrentCaret());
|
||||
if (o != null) return o;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user