Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDE-Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DP-Group 14
IDE-Plugin
Commits
b50484fb
Commit
b50484fb
authored
4 years ago
by
s1995588
Browse files
Options
Downloads
Patches
Plain Diff
changed some variable names and added distributions
parent
bd0a80b3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
media/main.js
+23
-23
23 additions, 23 deletions
media/main.js
src/extension.ts
+3
-3
3 additions, 3 deletions
src/extension.ts
src/sidebar.ts
+31
-27
31 additions, 27 deletions
src/sidebar.ts
with
57 additions
and
53 deletions
media/main.js
+
23
−
23
View file @
b50484fb
...
...
@@ -12,7 +12,7 @@
toolDropDown
.
addEventListener
(
'
change
'
,
event
=>
{
var
oldState
=
vscode
.
getState
();
var
currentTool
=
toolDropDown
.
options
[
toolDropDown
.
selectedIndex
].
value
;
vscode
.
setState
({
tools
:
oldState
.
tools
,
constant
s
:
oldState
.
constant
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
currentTool
});
vscode
.
setState
({
tools
:
oldState
.
tools
,
documentVar
s
:
oldState
.
documentVar
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
currentTool
});
vscode
.
postMessage
({
type
:
"
toolSelected
"
,
toolName
:
currentTool
});
});
...
...
@@ -21,9 +21,9 @@
const
message
=
event
.
data
;
// The json data that the extension sent
console
.
log
(
"
Received message
"
);
switch
(
message
.
type
)
{
case
'
update
Constant
s
'
:
case
'
update
DocumentVar
s
'
:
{
update
Constants
(
message
.
constant
s
,
message
.
uri
);
update
DocumentVars
(
message
.
documentVar
s
,
message
.
uri
);
break
;
}
case
'
updateParameters
'
:
...
...
@@ -42,7 +42,7 @@
const
runButton
=
document
.
getElementById
(
"
run-button
"
);
runButton
.
addEventListener
(
"
click
"
,
event
=>
{
const
state
=
vscode
.
getState
();
for
(
const
file
of
state
.
constant
s
)
{
for
(
const
file
of
state
.
documentVar
s
)
{
if
(
file
.
uri
===
state
.
currentUri
)
{
for
(
const
tool
of
state
.
parameters
)
{
if
(
tool
.
toolName
===
state
.
currentTool
)
{
...
...
@@ -71,7 +71,7 @@
vscode
.
postMessage
({
type
:
"
toolSelected
"
,
toolName
:
oldState
.
currentTool
});
vscode
.
setState
({
tools
:
tools
,
constant
s
:
oldState
.
constant
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
vscode
.
setState
({
tools
:
tools
,
documentVar
s
:
oldState
.
documentVar
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
}
function
addConstantItem
(
ul
,
name
,
value
)
{
...
...
@@ -91,7 +91,7 @@
valueBox
.
classList
.
add
(
"
value
"
);
valueBox
.
addEventListener
(
"
input
"
,
event
=>
{
let
oldState
=
vscode
.
getState
();
for
(
const
file
of
oldState
.
constant
s
)
{
for
(
const
file
of
oldState
.
documentVar
s
)
{
if
(
file
.
uri
===
oldState
.
currentUri
)
{
for
(
const
constant
of
file
.
constants
)
{
if
(
constant
.
name
===
name
)
{
...
...
@@ -102,7 +102,7 @@
break
;
}
}
vscode
.
setState
({
tools
:
oldState
.
tools
,
constant
s
:
oldState
.
constant
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
vscode
.
setState
({
tools
:
oldState
.
tools
,
documentVar
s
:
oldState
.
documentVar
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
});
li
.
appendChild
(
valueBox
);
...
...
@@ -138,7 +138,7 @@
break
;
}
}
vscode
.
setState
({
tools
:
oldState
.
tools
,
constant
s
:
oldState
.
constant
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
vscode
.
setState
({
tools
:
oldState
.
tools
,
documentVar
s
:
oldState
.
documentVar
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
});
li
.
appendChild
(
valueBox
);
...
...
@@ -148,36 +148,36 @@
/**
*
* @param {Array<{ uri: string, constants: Array<{ name: string, value: string }>
}>} constant
s
* @param {Array<{ uri: string, constants: Array<{ name: string, value: string }>
, distributions: Array<{ name: string, value: string }> }>} documentVar
s
* @param {string} uri
*/
function
update
Constants
(
constant
s
,
uri
)
{
function
update
DocumentVars
(
documentVar
s
,
uri
)
{
const
constantsUl
=
document
.
querySelector
(
"
#constants
"
);
const
oldState
=
vscode
.
getState
();
// combines the oldstate constants with the "new" constants.
for
(
const
file
of
constant
s
)
{
const
index
=
oldState
.
constant
s
.
findIndex
(
x
=>
x
.
uri
===
file
.
uri
);
for
(
const
file
of
documentVar
s
)
{
const
index
=
oldState
.
documentVar
s
.
findIndex
(
x
=>
x
.
uri
===
file
.
uri
);
if
(
index
!==
-
1
)
{
for
(
const
constant
of
file
.
constants
)
{
const
oldConstantIndex
=
oldState
.
constant
s
[
index
].
constants
.
findIndex
(
x
=>
x
.
name
===
constant
.
name
);
const
oldConstantIndex
=
oldState
.
documentVar
s
[
index
].
constants
.
findIndex
(
x
=>
x
.
name
===
constant
.
name
);
if
(
oldConstantIndex
!==
-
1
)
{
constant
.
value
=
oldState
.
constant
s
[
index
].
constants
[
oldConstantIndex
].
value
;
constant
.
value
=
oldState
.
documentVar
s
[
index
].
constants
[
oldConstantIndex
].
value
;
}
}
}
}
for
(
const
file
of
oldState
.
constant
s
)
{
const
index
=
constant
s
.
findIndex
(
x
=>
x
.
uri
===
file
.
uri
);
for
(
const
file
of
oldState
.
documentVar
s
)
{
const
index
=
documentVar
s
.
findIndex
(
x
=>
x
.
uri
===
file
.
uri
);
if
(
index
===
-
1
)
{
constant
s
.
push
(
file
);
documentVar
s
.
push
(
file
);
}
}
constantsUl
.
innerHTML
=
""
;
// adds the constants to the sidebar.
for
(
const
file
of
constant
s
)
{
for
(
const
file
of
documentVar
s
)
{
if
(
file
.
uri
===
uri
)
{
for
(
const
constant
of
file
.
constants
)
{
addConstantItem
(
constantsUl
,
constant
.
name
,
constant
.
value
);
...
...
@@ -190,7 +190,7 @@
constantsUl
.
innerHTML
=
"
There are no undefined constants.
"
;
}
vscode
.
setState
({
tools
:
oldState
.
tools
,
constants
:
constant
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
uri
,
currentTool
:
oldState
.
currentTool
});
vscode
.
setState
({
tools
:
oldState
.
tools
,
documentVars
:
documentVar
s
,
parameters
:
oldState
.
parameters
,
currentUri
:
uri
,
currentTool
:
oldState
.
currentTool
});
}
/**
...
...
@@ -232,13 +232,13 @@
}
}
vscode
.
setState
({
tools
:
oldState
.
tools
,
constant
s
:
oldState
.
constant
s
,
parameters
:
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
vscode
.
setState
({
tools
:
oldState
.
tools
,
documentVar
s
:
oldState
.
documentVar
s
,
parameters
:
parameters
,
currentUri
:
oldState
.
currentUri
,
currentTool
:
oldState
.
currentTool
});
}
const
oldState
=
vscode
.
getState
()
||
{
tools
:
[],
constant
s
:
[],
parameters
:
[],
currentUri
:
""
,
currentTool
:
""
};
const
oldState
=
vscode
.
getState
()
||
{
tools
:
[],
documentVar
s
:
[],
parameters
:
[],
currentUri
:
""
,
currentTool
:
""
};
const
tools
=
oldState
.
tools
;
const
constant
s
=
oldState
.
constant
s
;
const
documentVar
s
=
oldState
.
documentVar
s
;
const
parameters
=
oldState
.
parameters
;
const
currentUri
=
oldState
.
currentUri
;
const
currentTool
=
oldState
.
currentTool
;
...
...
@@ -248,6 +248,6 @@
}
else
{
fillTools
(
tools
);
updateParameters
(
parameters
,
currentTool
);
update
Constants
(
constant
s
,
currentUri
);
update
DocumentVars
(
documentVar
s
,
currentUri
);
}
}());
This diff is collapsed.
Click to expand it.
src/extension.ts
+
3
−
3
View file @
b50484fb
...
...
@@ -13,7 +13,7 @@ import {
}
from
"
vscode-languageclient/node
"
;
import
{
AnalysisResultsProvider
,
Result
}
from
"
./analysisResults
"
;
import
{
ModestCommands
}
from
"
./commands
"
;
import
{
get
Constant
s
,
initializeTools
,
ModestSidebarProvider
}
from
"
./sidebar
"
;
import
{
get
DocumentVar
s
,
initializeTools
,
ModestSidebarProvider
}
from
"
./sidebar
"
;
export
let
client
:
LanguageClient
|
undefined
;
export
let
provider
:
ModestSidebarProvider
;
...
...
@@ -151,12 +151,12 @@ export function activate(context: ExtensionContext) {
vscode
.
window
.
onDidChangeActiveTextEditor
(
textEditor
=>
{
if
(
textEditor
)
{
get
Constant
s
(
textEditor
.
document
);
get
DocumentVar
s
(
textEditor
.
document
);
}
});
vscode
.
workspace
.
onDidSaveTextDocument
(
textEditor
=>
{
get
Constant
s
(
textEditor
);
get
DocumentVar
s
(
textEditor
);
});
//#endregion
...
...
This diff is collapsed.
Click to expand it.
src/sidebar.ts
+
31
−
27
View file @
b50484fb
...
...
@@ -10,9 +10,9 @@ import {
import
{
analysisResultsProvider
,
client
,
provider
}
from
'
./extension
'
;
export
let
t
oolNames
:
Array
<
string
>
|
undefined
;
export
let
constant
s
:
Array
<
{
uri
:
string
,
constants
:
Array
<
{
name
:
string
,
value
:
string
}
>
}
>
=
[];
export
let
p
arameters
:
Array
<
{
toolName
:
string
,
parameters
:
Array
<
{
id
:
string
,
v
alue
:
string
,
type
:
ParameterType
,
category
:
string
}
>
}
>
=
[];
export
let
localT
oolNames
:
Array
<
string
>
|
undefined
;
export
let
localDocumentVar
s
:
Array
<
{
uri
:
string
,
constants
:
Array
<
{
name
:
string
,
value
:
string
}
>
,
distributions
:
Array
<
{
name
:
string
,
value
:
string
}
>
}
>
=
[];
export
let
localP
arameters
:
Array
<
{
toolName
:
string
,
parameters
:
Array
<
{
id
:
string
,
defaultV
alue
:
string
,
type
:
ParameterType
,
category
:
string
}
>
}
>
=
[];
//#region interfaces
interface
ParameterDefinitions
{
...
...
@@ -47,32 +47,36 @@ interface ResultNotification {
export
function
initializeTools
()
{
client
?.
sendRequest
<
any
>
(
"
modest/getTools
"
).
then
(
data
=>
{
t
oolNames
=
data
.
availableTools
;
localT
oolNames
=
data
.
availableTools
;
provider
.
sendMessage
({
type
:
"
fillTools
"
,
tools
:
t
oolNames
tools
:
localT
oolNames
});
});
}
export
function
get
Constant
s
(
document
:
TextDocument
)
{
export
function
get
DocumentVar
s
(
document
:
TextDocument
)
{
if
(
document
.
languageId
===
"
modest
"
)
{
if
(
document
.
uri
)
{
let
uri
=
document
.
uri
.
toString
();
let
jsonObject
=
{
"
textDocument
"
:
TextDocumentIdentifier
.
create
(
uri
)
};
client
?.
sendRequest
<
Array
<
string
>
>
(
"
modest/get
Constant
s
"
,
jsonObject
).
then
(
data
=>
{
const
index
=
constant
s
.
findIndex
(
x
=>
x
.
uri
===
uri
);
const
newConstants
=
data
.
map
(
constant
=>
{
client
?.
sendRequest
<
{
constants
:
Array
<
string
>
,
distributions
:
Array
<
string
>
}
>
(
"
modest/get
DocumentVar
s
"
,
jsonObject
).
then
(
data
=>
{
const
index
=
localDocumentVar
s
.
findIndex
(
x
=>
x
.
uri
===
uri
);
const
newConstants
=
data
.
constants
.
map
(
constant
=>
{
return
{
name
:
constant
,
value
:
""
};
});
const
newDistributions
=
data
.
distributions
.
map
(
distribution
=>
{
return
{
name
:
distribution
,
value
:
""
};
});
if
(
index
===
-
1
)
{
constant
s
.
push
({
"
uri
"
:
uri
,
constants
:
newConstants
});
localDocumentVar
s
.
push
({
"
uri
"
:
uri
,
constants
:
newConstants
,
distributions
:
newDistributions
});
}
else
{
constants
[
index
].
constants
=
newConstants
;
localDocumentVars
[
index
].
constants
=
newConstants
;
localDocumentVars
[
index
].
distributions
=
newDistributions
;
}
provider
.
sendMessage
({
type
:
"
update
Constant
s
"
,
constants
:
constant
s
,
type
:
"
update
DocumentVar
s
"
,
documentVars
:
localDocumentVar
s
,
"
uri
"
:
uri
});
});
...
...
@@ -83,31 +87,31 @@ export function getConstants(document: TextDocument) {
function
getParameters
(
toolName
:
string
)
{
let
jsonObject
=
{
"
toolName
"
:
toolName
};
client
?.
sendRequest
<
ParameterDefinitions
>
(
"
modest/getParameters
"
,
jsonObject
).
then
(
data
=>
{
const
index
=
p
arameters
.
findIndex
(
x
=>
x
.
toolName
===
toolName
);
const
index
=
localP
arameters
.
findIndex
(
x
=>
x
.
toolName
===
toolName
);
const
newParameters
=
data
.
parameterDefinitions
.
map
(
parameter
=>
{
return
{
id
:
parameter
.
id
,
v
alue
:
parameter
.
defaultValue
,
type
:
parameter
.
type
,
category
:
parameter
.
category
};
return
{
id
:
parameter
.
id
,
defaultV
alue
:
parameter
.
defaultValue
,
type
:
parameter
.
type
,
category
:
parameter
.
category
};
});
if
(
index
===
-
1
)
{
p
arameters
.
push
({
toolName
:
toolName
,
parameters
:
newParameters
});
localP
arameters
.
push
({
toolName
:
toolName
,
parameters
:
newParameters
});
}
else
{
p
arameters
[
index
].
parameters
=
newParameters
;
localP
arameters
[
index
].
parameters
=
newParameters
;
}
provider
.
sendMessage
({
type
:
"
updateParameters
"
,
parameters
:
p
arameters
,
parameters
:
localP
arameters
,
toolName
:
toolName
});
});
}
function
runTool
(
uri
:
string
,
toolName
:
string
,
constants
:
{
name
:
string
;
value
:
string
;
}[],
suppliedParameters
:
{
id
:
string
;
value
:
string
;
}[])
{
const
toolIndex
=
p
arameters
.
findIndex
(
x
=>
x
.
toolName
===
toolName
);
const
toolIndex
=
localP
arameters
.
findIndex
(
x
=>
x
.
toolName
===
toolName
);
let
serverParameters
:
Array
<
{
id
:
string
,
value
:
string
}
>
=
[];
if
(
toolIndex
!==
-
1
)
{
for
(
const
parameter
of
suppliedParameters
)
{
const
parameterIndex
=
p
arameters
[
toolIndex
].
parameters
.
findIndex
(
x
=>
x
.
id
===
parameter
.
id
);
const
parameterIndex
=
localP
arameters
[
toolIndex
].
parameters
.
findIndex
(
x
=>
x
.
id
===
parameter
.
id
);
if
(
parameterIndex
!==
-
1
)
{
if
(
p
arameters
[
toolIndex
].
parameters
[
parameterIndex
].
v
alue
!==
parameter
.
value
)
{
if
(
localP
arameters
[
toolIndex
].
parameters
[
parameterIndex
].
defaultV
alue
!==
parameter
.
value
)
{
serverParameters
.
push
(
parameter
);
}
}
...
...
@@ -132,7 +136,7 @@ function runTool(uri: string, toolName: string, constants: { name: string; value
if
(
data
.
data
&&
data
.
data
!==
""
)
{
try
{
analysisResultsProvider
.
setJsonString
(
data
.
data
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
}
}
...
...
@@ -176,16 +180,16 @@ export class ModestSidebarProvider implements vscode.WebviewViewProvider {
console
.
log
(
data
);
switch
(
data
.
type
)
{
case
'
init
'
:
{
if
(
t
oolNames
)
{
if
(
localT
oolNames
)
{
provider
.
sendMessage
({
type
:
"
fillTools
"
,
tools
:
t
oolNames
tools
:
localT
oolNames
});
}
if
(
constant
s
)
{
if
(
localDocumentVar
s
)
{
provider
.
sendMessage
({
type
:
"
update
Constant
s
"
,
constants
:
constant
s
type
:
"
update
DocumentVar
s
"
,
documentVars
:
localDocumentVar
s
});
}
break
;
...
...
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