Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
B Language Extension
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
B Language Extension
Commits
cb53b058
Commit
cb53b058
authored
5 years ago
by
SeeBasTStick
Browse files
Options
Downloads
Patches
Plain Diff
fix: server crashed due to wrong oackage.json
parent
0877896d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/src/extension.ts
+11
-1
11 additions, 1 deletion
client/src/extension.ts
package.json
+1
-2
1 addition, 2 deletions
package.json
server/src/server.ts
+34
-21
34 additions, 21 deletions
server/src/server.ts
with
46 additions
and
24 deletions
client/src/extension.ts
+
11
−
1
View file @
cb53b058
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
package.json
+
1
−
2
View file @
cb53b058
...
...
@@ -23,8 +23,7 @@
"proB"
],
"activationEvents"
:
[
"onLanguage:B"
,
"onLanguage:eventB"
"onLanguage:plaintext"
],
"main"
:
"./client/out/extension"
,
"contributes"
:
{
...
...
This diff is collapsed.
Click to expand it.
server/src/server.ts
+
34
−
21
View file @
cb53b058
...
...
@@ -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
Example
Settings
{
// 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
<
Example
Settings
>>
=
new
Map
();
let
documentSettings
:
Map
<
string
,
Thenable
<
Settings
>>
=
new
Map
();
connection
.
onDidChangeConfiguration
(
change
=>
{
if
(
hasConfigurationCapability
)
{
// Reset all cached document settings
documentSettings
.
clear
();
}
else
{
globalSettings
=
<
Example
Settings
>
(
globalSettings
=
<
Settings
>
(
(
change
.
settings
.
languageServer
||
defaultSettings
)
);
}
...
...
@@ -116,7 +118,7 @@ connection.onDidChangeConfiguration(change => {
documents
.
all
().
forEach
(
validateTextDocument
);
});
function
getDocumentSettings
(
resource
:
string
):
Thenable
<
Example
Settings
>
{
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
}
},
];
}
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment