-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add diagnostic - add language services - general optimization See Changelog for details
- Loading branch information
1 parent
fc99f3a
commit ca30774
Showing
40 changed files
with
2,551 additions
and
733 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
.vscode/ | ||
.gitignore/ | ||
.git/ | ||
**/*.ts | ||
**/tsconfig.json | ||
**/tslint.json | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Feature examples | ||
## Diagnostics | ||
|
||
![](not_decl.png) | ||
![](redefinition.png) | ||
|
||
## Hover | ||
![](hover.png) | ||
|
||
## Auto-Completion for keywords, declared definitions in lex/flex | ||
|
||
![](lex_define.gif) | ||
|
||
![](lex_rule.gif) | ||
|
||
## Auto-Completion for keywords, declared union types in yacc/bison | ||
|
||
![](yacc_token.gif) | ||
|
||
## Auto-Completion for symbols in yacc/bison | ||
![](yacc_symbol.gif) | ||
|
||
## Auto-Completion for symbol type in yacc/bison | ||
![](yacc_type.gif) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,88 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
* | ||
* Modified to adapt the project | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { TextDocument } from 'vscode'; | ||
|
||
export interface DocumentCache<T> { | ||
get(document: TextDocument): T; | ||
onDocumentRemoved(document: TextDocument): void; | ||
dispose(): void; | ||
} | ||
|
||
export function CreateDocumentCache<T>(maxEntries: number, cleanupIntervalTimeInSec: number, parse: (document: TextDocument) => T): DocumentCache<T> { | ||
let languageModels: { [uri: string]: { version: number, languageId: string, cTime: number, languageModel: T } } = {}; | ||
let nModels = 0; | ||
|
||
let cleanupInterval: NodeJS.Timer | undefined = undefined; | ||
if (cleanupIntervalTimeInSec > 0) { | ||
cleanupInterval = setInterval(() => { | ||
const cutoffTime = Date.now() - cleanupIntervalTimeInSec * 1000; | ||
const uris = Object.keys(languageModels); | ||
for (const uri of uris) { | ||
const languageModelInfo = languageModels[uri]; | ||
if (languageModelInfo.cTime < cutoffTime) { | ||
delete languageModels[uri]; | ||
nModels--; | ||
} | ||
} | ||
}, cleanupIntervalTimeInSec * 1000); | ||
} | ||
|
||
return { | ||
get(document: TextDocument): T { | ||
const version = document.version; | ||
const languageId = document.languageId; | ||
const languageModelInfo = languageModels[document.uri.toString()]; | ||
if (languageModelInfo && languageModelInfo.version === version && languageModelInfo.languageId === languageId) { | ||
languageModelInfo.cTime = Date.now(); | ||
return languageModelInfo.languageModel; | ||
} | ||
|
||
const t0 = Date.now(); | ||
const languageModel = parse(document); | ||
const t1 = Date.now(); | ||
console.log(`Parsing time ${t1 - t0}`); | ||
languageModels[document.uri.toString()] = { languageModel, version, languageId, cTime: Date.now() }; | ||
if (!languageModelInfo) { | ||
nModels++; | ||
} | ||
|
||
if (nModels === maxEntries) { | ||
let oldestTime = Number.MAX_VALUE; | ||
let oldestUri = null; | ||
for (const uri in languageModels) { | ||
const languageModelInfo = languageModels[uri]; | ||
if (languageModelInfo.cTime < oldestTime) { | ||
oldestUri = uri; | ||
oldestTime = languageModelInfo.cTime; | ||
} | ||
} | ||
if (oldestUri) { | ||
delete languageModels[oldestUri]; | ||
nModels--; | ||
} | ||
} | ||
return languageModel; | ||
|
||
}, | ||
onDocumentRemoved(document: TextDocument) { | ||
const uri = document.uri.toString(); | ||
if (languageModels[uri]) { | ||
delete languageModels[uri]; | ||
nModels--; | ||
} | ||
}, | ||
dispose() { | ||
if (typeof cleanupInterval !== 'undefined') { | ||
clearInterval(cleanupInterval); | ||
cleanupInterval = undefined; | ||
languageModels = {}; | ||
nModels = 0; | ||
} | ||
} | ||
}; | ||
} |
Oops, something went wrong.