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

fix: server crashed due to wrong oackage.json

parent 0877896d
Branches
Tags
No related merge requests found
......@@ -17,7 +17,6 @@ let client: LanguageClient;
export function activate(context: ExtensionContext) {
// The server is implemented in node
console.log("test")
let serverModule = context.asAbsolutePath(
path.join('server', 'out', 'server.js')
);
......@@ -54,11 +53,22 @@ export function activate(context: ExtensionContext) {
clientOptions
);
client.onReady().then(() => {
client.onNotification("path_error_prob", (message:string) => {
console.log(message);
});
client.onNotification("parse_error_prob", (message:string) => {
console.log(message);
});
});
//context.subscriptions.push(client.start());
// Start the client. This will also launch the server
client.start();
console.log("Client started")
}
export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined;
......
......@@ -23,8 +23,7 @@
"proB"
],
"activationEvents": [
"onLanguage:B",
"onLanguage:eventB"
"onLanguage:plaintext"
],
"main": "./client/out/extension",
"contributes": {
......
......@@ -14,7 +14,9 @@ import {
CompletionItemKind,
TextDocumentPositionParams,
TextDocumentSyncKind,
InitializeResult
InitializeResult,
NotificationType0,
PublishDiagnosticsNotification
} from 'vscode-languageserver';
......@@ -24,8 +26,9 @@ import {
import { URI } from 'vscode-uri';
import * as fs from 'fs';
import {ErrorMatcher} from './ErrorMatcher'
import * as path from 'path'
import {ErrorMatcher} from './ErrorMatcher';
import * as path from 'path';
// Create a connection for the server. The connection uses Node's IPC as a transport.
// Also include all preview / proposed LSP features.
......@@ -39,6 +42,7 @@ let hasConfigurationCapability: boolean = false;
let hasWorkspaceFolderCapability: boolean = false;
let hasDiagnosticRelatedInformationCapability: boolean = false;
connection.onInitialize((params: InitializeParams) => {
let capabilities = params.capabilities;
......@@ -87,27 +91,25 @@ connection.onInitialized(() => {
}
});
// The example settings
interface ExampleSettings {
// The settings
interface Settings {
maxNumberOfProblems: number;
probHome : string;
}
// The global settings, used when the `workspace/configuration` request is not supported by the client.
// Please note that this is not the case when using this server with the client provided in this example
// but could happen with other clients.
const defaultSettings: ExampleSettings = { maxNumberOfProblems: 1000, probHome: "/home/sebastian/prob_prolog/probcli.sh" };
let globalSettings: ExampleSettings = defaultSettings;
const defaultSettings: Settings = { maxNumberOfProblems: 1000, probHome: "/home/sebastian/prob_prolog/probcli.sh" };
let globalSettings: Settings = defaultSettings;
// Cache the settings of all open documents
let documentSettings: Map<string, Thenable<ExampleSettings>> = new Map();
let documentSettings: Map<string, Thenable<Settings>> = new Map();
connection.onDidChangeConfiguration(change => {
if (hasConfigurationCapability) {
// Reset all cached document settings
documentSettings.clear();
} else {
globalSettings = <ExampleSettings>(
globalSettings = <Settings>(
(change.settings.languageServer || defaultSettings)
);
}
......@@ -116,7 +118,7 @@ connection.onDidChangeConfiguration(change => {
documents.all().forEach(validateTextDocument);
});
function getDocumentSettings(resource: string): Thenable<ExampleSettings> {
function getDocumentSettings(resource: string): Thenable<Settings> {
if (!hasConfigurationCapability) {
return Promise.resolve(globalSettings);
}
......@@ -148,7 +150,6 @@ documents.onDidChangeContent(change => {
});
async function validateTextDocument(textDocument: TextDocument): Promise<void> {
// In this simple example we get the settings for every validate run.
let settings = await getDocumentSettings(textDocument.uri);
let pathy:path.ParsedPath = path.parse(URI.parse(textDocument.uri).path);
......@@ -157,7 +158,8 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
console.log(settings.probHome)
let probCliHome:string = settings.probHome//'/home/sebastian/prob_prolog/probcli.sh'
let probCliHome:string = settings.probHome
let ndjson:string = 'NDJSON_ERROR_LOG_FILE '
let errorPath:string = dic+'/_error.json'
......@@ -172,6 +174,7 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
let diagnosticsPromise : Promise<Set<Diagnostic>>
console.log(command2)
exec(command2, (err:string, stdout:string, stderr:string) => {
let bla = new ErrorMatcher()
diagnosticsPromise = bla.matchError(textDocument, errorPath)
......@@ -182,13 +185,23 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics});
}, function(err){
connection.sendNotification("parse_error_prob", "there are things wrong with the parse results " + err)
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics})
})
});
}
function correctPath(path:string): boolean{
fs.access(path, (err) => {
connection.sendNotification("path_error_prob", path + " seems to be the wrong path to ProB")
return false
})
return true
}
connection.onDidChangeWatchedFiles(_change => {
// Monitored files have change in VSCode
......@@ -199,17 +212,16 @@ connection.onDidChangeWatchedFiles(_change => {
// This handler provides the initial list of the completion items.
connection.onCompletion(
(textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
// The pass parameter contains the position of the text document in
// which code complete got requested. For the example we ignore this
// info and always provide the same completion items.
// console.log("textpos" + textDocumentPosition);
return [
{
label: 'MACHINE',
kind: CompletionItemKind.Text,
data: 1
},
{
label: 'VARIABLES',
kind: CompletionItemKind.Text,
......@@ -224,7 +236,8 @@ connection.onCompletion(
label: 'OPERATIONS',
kind: CompletionItemKind.Text,
data: 4
}
},
];
}
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment