-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5088 from neoGeneva/Add-AnalyzeOpenDocumentsOnly
Add AnalyzeOpenDocumentsOnly
- Loading branch information
Showing
10 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { IDisposable } from "../Disposable"; | ||
import { OmniSharpServer } from "../omnisharp/server"; | ||
import * as vscode from 'vscode'; | ||
import CompositeDisposable from "../CompositeDisposable"; | ||
import * as serverUtils from '../omnisharp/utils'; | ||
import { isVirtualCSharpDocument } from "./virtualDocumentTracker"; | ||
|
||
export default function fileOpenClose(server: OmniSharpServer): IDisposable { | ||
return new FileOpenCloseProvider(server); | ||
} | ||
|
||
class FileOpenCloseProvider implements IDisposable { | ||
private _server: OmniSharpServer; | ||
private _diagnostics: vscode.DiagnosticCollection; | ||
private _disposable: CompositeDisposable; | ||
|
||
constructor(server: OmniSharpServer) { | ||
this._server = server; | ||
this._diagnostics = vscode.languages.createDiagnosticCollection('csharp'); | ||
|
||
setTimeout(async () => { | ||
for (let editor of vscode.window.visibleTextEditors) { | ||
let document = editor.document; | ||
|
||
await this._onDocumentOpen(document); | ||
} | ||
}, 0); | ||
|
||
this._disposable = new CompositeDisposable(this._diagnostics, | ||
vscode.workspace.onDidOpenTextDocument(this._onDocumentOpen, this), | ||
vscode.workspace.onDidCloseTextDocument(this._onDocumentClose, this), | ||
vscode.window.onDidChangeActiveTextEditor(this._onActiveTextEditorChange, this) | ||
); | ||
} | ||
|
||
private async _onDocumentOpen(e: vscode.TextDocument) { | ||
if (shouldIgnoreDocument(e)) { | ||
return; | ||
} | ||
|
||
await serverUtils.fileOpen(this._server, { FileName: e.fileName }); | ||
} | ||
|
||
private async _onDocumentClose(e: vscode.TextDocument) { | ||
if (shouldIgnoreDocument(e)) { | ||
return; | ||
} | ||
|
||
await serverUtils.fileClose(this._server, { FileName: e.fileName }); | ||
} | ||
|
||
private async _onActiveTextEditorChange(e: vscode.TextEditor) { | ||
if (shouldIgnoreDocument(e.document)) { | ||
return; | ||
} | ||
|
||
await serverUtils.filesChanged(this._server, [{ FileName: e.document.fileName }]); | ||
} | ||
|
||
dispose = () => this._disposable.dispose(); | ||
} | ||
|
||
function shouldIgnoreDocument(document: vscode.TextDocument) { | ||
if (document.languageId !== 'csharp') { | ||
return true; | ||
} | ||
|
||
if (document.uri.scheme !== 'file' && | ||
!isVirtualCSharpDocument(document)) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters