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

added warnings

parent 4dfb3f09
Branches
Tags
No related merge requests found
......@@ -5,5 +5,7 @@
"typescript.preferences.quoteStyle": "single",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
},
"languageServer.strictChecks": true,
"languageServer.wdChecks": true
}
\ No newline at end of file
......@@ -579,6 +579,11 @@
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true
},
"error": {
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/error/-/error-10.3.0.tgz",
"integrity": "sha512-y0yyhFzqncP5zCdlnwFvrorcujP55Du7uouOmmZQPQVXJvKPXWehVeqHe1mb/HLrdYB2z5MFs8v/ZWHv3YvTGg=="
},
"es-abstract": {
"version": "1.17.5",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz",
......@@ -1977,6 +1982,11 @@
"is-number": "^7.0.0"
}
},
"ts-xor": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/ts-xor/-/ts-xor-1.0.8.tgz",
"integrity": "sha512-0u70/SDLSCaX23UddnwAb2GvZZ2N0Rbjnmemn5pHoR40D32Xcva5KRGWV9SdJOKHCjJUlmctmCTvT0z+2yT8aw=="
},
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
......
......@@ -6,6 +6,7 @@
"publisher": "SeeBasTStick",
"icon": "prob2-ui.png",
"author": "Sebastian Stock",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/SeeBasTStick/b-eventb-language-extension"
......@@ -57,13 +58,13 @@
"languageServer.wdChecks": {
"scope": "window",
"type": "boolean",
"default": "off",
"default": "false",
"description": "Option for WD Checks"
},
"languageServer.strictChecks": {
"scope": "window",
"type": "boolean",
"default": "off",
"default": "false",
"description": "Option for stricter Checks"
}
}
......@@ -77,21 +78,23 @@
"test": "sh ./scripts/e2e.sh"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.38",
"@typescript-eslint/parser": "^2.3.0",
"eslint": "^6.4.0",
"mocha": "^6.2.2",
"typescript": "^3.8.3",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.4",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^7.0.0",
"mocha": "^7.1.2",
"typescript": "^3.9.3",
"vscode": "^1.1.37"
},
"dependencies": {
"@types/ndjson": "^1.5.0",
"@types/stream-to-array": "^2.3.0",
"@types/vscode": "^1.45.1",
"error": "^10.3.0",
"ndjson": "^1.5.0",
"path": "^0.12.7",
"stream-to-array": "^2.3.0",
"ts-xor": "^1.0.8",
"vscode-api": "0.0.0",
"vscode-uri": "^2.1.1"
}
......
......@@ -2,7 +2,7 @@ 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{
......@@ -17,44 +17,74 @@ export class ErrorMatcher{
crlfDelay: Infinity
});
for await (const line of rl) {
let obj:Error = JSON.parse(line)
let obj : XOR<Error, Warning> = JSON.parse(line)
let diagnostic : Diagnostic
console.log(obj)
var diagnostic:Diagnostic = {
severity: DiagnosticSeverity.Error,
let serveity : DiagnosticSeverity
let content : ErrorOrWarning
if(obj.error ){
content = obj.error
serveity = DiagnosticSeverity.Error
}
else{
if(obj.warning){
content = obj.warning
serveity = DiagnosticSeverity.Warning
}else{
throw new Error("Parsed Object is neither Warning nor Error - this is wrong")
}
}
diagnostic = {
severity: serveity,
range: {
start:
{
character: obj.error.start.col,
line:obj.error.start.line - 1
character: content.start.col,
line: content.start.line - 1
},
end: {
character:obj.error.end.col,
line :obj.error.end.line -1
character:content.end.col,
line :content.end.line -1
}
},
message: obj.error.message,
message: content.message,
source: 'prob_prolog'
};
diagnostics.add(diagnostic)
}
return diagnostics
}
}
interface Error{
error : {
message : string
type : string
file : string
start : {
line : number
col : number
export interface Error{
error : ErrorOrWarning;
}
end : {
line : number
col : number
export interface Warning{
warning : ErrorOrWarning
}
};
export interface ErrorOrWarning {
message: string;
type: string;
file: string;
start: StartOrEnd;
end: StartOrEnd;
}
export interface StartOrEnd {
line: number;
col: number;
}
\ No newline at end of file
......@@ -6,7 +6,6 @@ import {
InitializeParams,
DidChangeConfigurationNotification,
CompletionItem,
CompletionItemKind,
TextDocumentPositionParams,
TextDocumentSyncKind,
InitializeResult,
......@@ -21,7 +20,6 @@ import * as fs from 'fs';
import {ErrorMatcher} from './ErrorMatcher';
import * as wordComplition from './wordCompletion'
import * as path from 'path';
import { settings } from 'cluster';
......@@ -147,6 +145,9 @@ documents.onDidSave(change => {
async function validateTextDocument(textDocument: TextDocument): Promise<void> {
globalSettings = await getDocumentSettings(textDocument.uri) // Waiting for correct setting; otherwise allways default
let documentPath:path.ParsedPath = path.parse(URI.parse(textDocument.uri).path);
let errorPath:string = documentPath.dir+'/_error.json'
......@@ -160,6 +161,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
let diagnostics : Array<Diagnostic> = new Array()
let diagnosticsPromise : Promise<Set<Diagnostic>>
console.log(command)
if(correctPath(globalSettings.probHome))
{
exec(command, (err:string, stdout:string, stderr:string) => {
......@@ -180,7 +182,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
function getCommand(documentPath : string, errorPath : string) : string{
let wdCmd = ""
let strict = ""
console.log(globalSettings.wdChecks + " " + globalSettings.strictChecks)
if(globalSettings.wdChecks){
wdCmd = " -wd-check -release_java_parser "
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment