Skip to content
Snippets Groups Projects
Commit e34b6bba authored by SeeBasTStick's avatar SeeBasTStick
Browse files

added performance hints and information

parent 9c5ce33a
Branches
Tags
No related merge requests found
......@@ -39,7 +39,7 @@ export function activate(context: ExtensionContext) {
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for B, EventB documents
documentSelector: [{ scheme: 'file', language: 'B' }, { scheme: 'file', language: 'EventB' }],
documentSelector: [{ scheme: 'file', language: 'plaintext' }],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
......
......@@ -2267,6 +2267,11 @@
}
}
},
"without": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/without/-/without-1.2.3.tgz",
"integrity": "sha1-xGXfzUWLuIvLNCy3j8otmA64TGg="
},
"word-wrap": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
......
......@@ -24,8 +24,7 @@
"proB"
],
"activationEvents": [
"onLanguage:B",
"onLanguage:EventB"
"onLanguage:plaintext"
],
"main": "./client/out/extension",
"contributes": {
......@@ -67,26 +66,15 @@
"type": "boolean",
"default": false,
"description": "Option for stricter Checks"
},
"languageServer.performanceInfo": {
"scope": "window",
"type": "boolean",
"default": false,
"description": "Option for preformance Info"
}
}
},
"languages": [
{
"id": "B",
"extensions": [
".mch",
".ref",
".imp",
".def"
]
},
{
"id": "EventB",
"extensions": [
".sys"
]
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
......@@ -115,6 +103,7 @@
"stream-to-array": "^2.3.0",
"ts-xor": "^1.0.8",
"vscode-api": "0.0.0",
"vscode-uri": "^2.1.1"
"vscode-uri": "^2.1.1",
"without": "^1.2.3"
}
}
......@@ -2,7 +2,6 @@ import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver'
import { TextDocument } from 'vscode-languageserver-textdocument'
import * as fs from 'fs';
import * as readline from 'readline'
import {XOR} from 'ts-xor'
export class ErrorMatcher {
......@@ -18,14 +17,15 @@ export class ErrorMatcher{
});
for await (const line of rl) {
let obj : XOR<Error, Warning> = JSON.parse(line)
let diagnostic : Diagnostic
console.log(obj)
try {
let obj: XOR3<Error, Warning, Information> = JSON.parse(line)
let diagnostic: Diagnostic
let serveity: DiagnosticSeverity
let content : ErrorOrWarning
let content: JBody
if (obj.error) {
content = obj.error
serveity = DiagnosticSeverity.Error
......@@ -35,7 +35,8 @@ export class ErrorMatcher{
content = obj.warning
serveity = DiagnosticSeverity.Warning
} else {
throw new Error("Parsed Object is neither Warning nor Error - this is wrong")
content = obj.information
serveity = DiagnosticSeverity.Information
}
}
......@@ -57,24 +58,42 @@ export class ErrorMatcher{
};
diagnostics.add(diagnostic)
}
catch (e) {
throw new Error("unexpected syntax while parsing _error.json")
}
}
return diagnostics
}
}
export declare type XOR3<T, U, V> = (T | U | V) extends object ? ((Without<T, U> & U) & (Without<V, U> & U)) |
((Without<V, T> & T) & (Without<U, T> & T)) |
((Without<T, V> & V) & (Without<U, V> & V)) : T | U | V;
export declare type Without<T, U> = {
[P in Exclude<keyof T, keyof U>]?: never;
};
export interface Information {
information: JBody
}
export interface Error {
error : ErrorOrWarning;
error: JBody;
}
export interface Warning {
warning : ErrorOrWarning
warning: JBody
}
export interface ErrorOrWarning {
export interface JBody {
message: string;
type: string;
file: string;
......@@ -87,4 +106,3 @@ export interface ErrorOrWarning {
col: number;
}
\ No newline at end of file
......@@ -89,6 +89,7 @@ interface Settings {
maxNumberOfProblems: number
strictChecks : boolean
wdChecks : boolean
performanceCheck : boolean
probHome : string
}
......@@ -97,7 +98,8 @@ const defaultSettings: Settings = {
maxNumberOfProblems: 1000,
probHome: "~/prob_prolog/probcli.sh",
strictChecks : false,
wdChecks : false };
wdChecks : false,
performanceCheck : false };
let globalSettings: Settings = defaultSettings;
......@@ -181,6 +183,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
function getCommand(documentPath : string, errorPath : string, settings: Settings) : string{
let wdCmd = ""
let strict = ""
let performanceCheck = ""
if(settings.wdChecks == true){
wdCmd = " -wd-check -release_java_parser "
}
......@@ -189,7 +192,11 @@ function getCommand(documentPath : string, errorPath : string, settings: Setting
strict = " -p STRICT_CLASH_CHECKING TRUE -p TYPE_CHECK_DEFINITIONS TRUE -lint "
}
return settings.probHome + ' -p MAX_INITIALISATIONS 0 -version ' + strict + wdCmd + documentPath +" -p " + "NDJSON_ERROR_LOG_FILE " + errorPath
if(settings.strictChecks == true){
performanceCheck = " -p PERFORMANCE_INFO TRUE "
}
return settings.probHome + ' -p MAX_INITIALISATIONS 0 -version ' + strict + wdCmd + performanceCheck + documentPath +" -p " + "NDJSON_ERROR_LOG_FILE " + errorPath
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment