Skip to content

Commit 2d78997

Browse files
committed
Lazy load documents from files for the Symbols View in Eclipse
1 parent 55bf699 commit 2d78997

File tree

1 file changed

+18
-4
lines changed
  • eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs

1 file changed

+18
-4
lines changed

eclipse-language-servers/org.springframework.tooling.ls.eclipse.gotosymbol/src/org/springframework/tooling/ls/eclipse/gotosymbol/dialogs/SelectionTracker.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,16 @@ public static synchronized void disposeAll(IWorkbenchWindow[] workbenchWindows)
7777
// there is a selection change
7878
static class DocumentData implements Disposable {
7979

80-
public final IFileEditorInput input;
81-
private final IDocumentProvider documentProvider;
80+
private final IFile file;
81+
82+
private IFileEditorInput input;
83+
private IDocumentProvider documentProvider;
8284

8385
public DocumentData(IFile file) {
84-
super();
86+
this.file = file;
87+
}
88+
89+
private void init() {
8590
this.input = new FileEditorInput(file);
8691
this.documentProvider = DocumentProviderRegistry.getDefault().getDocumentProvider(input);
8792
if (this.documentProvider != null) {
@@ -105,13 +110,22 @@ public void dispose() {
105110
}
106111
}
107112

113+
/**
114+
* May load the contents of the file into a document if there is no editor
115+
* opened for the file therefore do not execute on the UI thread
116+
*
117+
* @return the document
118+
*/
108119
public IDocument getDocument() {
120+
if (input == null) {
121+
init();
122+
}
109123
return this.documentProvider != null ? this.documentProvider.getDocument(input) : null;
110124
}
111125

112126
@Override
113127
public String toString() {
114-
return "DocumentData [file=" + input.getFile() + "]";
128+
return "DocumentData [file=" + file + "]";
115129
}
116130

117131
}

0 commit comments

Comments
 (0)