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
db4d89b9
Commit
db4d89b9
authored
4 years ago
by
Sytze de Witte
Browse files
Options
Downloads
Patches
Plain Diff
improved analysis results
parent
087160bc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/analysisResults.ts
+57
-10
57 additions, 10 deletions
src/analysisResults.ts
src/extension.ts
+59
-19
59 additions, 19 deletions
src/extension.ts
with
116 additions
and
29 deletions
src/analysisResults.ts
+
57
−
10
View file @
db4d89b9
import
*
as
vscode
from
"
vscode
"
;
import
*
as
fs
from
"
fs
"
;
import
*
as
path
from
"
path
"
;
import
{
LogTraceNotification
}
from
"
vscode-languageclient
"
;
import
{
LogTraceNotification
,
SemanticTokensRefreshRequest
}
from
"
vscode-languageclient
"
;
export
class
AnalysisResultsProvider
implements
vscode
.
TreeDataProvider
<
Result
>
{
...
...
@@ -41,7 +41,7 @@ export class AnalysisResultsProvider
return
Promise
.
resolve
(
res
);
}
else
{
if
(
this
.
jsonObject
)
{
return
Promise
.
resolve
(
this
.
data
ToResult
(
this
.
jsonObject
[
"
data
"
]
));
return
Promise
.
resolve
(
[
this
.
root
ToResult
(
this
.
jsonObject
)
]
);
}
else
{
return
Promise
.
resolve
([]);
}
...
...
@@ -68,7 +68,46 @@ export class AnalysisResultsProvider
}
}
dataToResult
(
data
:
JSON
[])
{
rootToResult
(
root
:
JSON
|
any
)
{
const
label
=
this
.
modestFile
;
var
values
:
Result
[]
=
[];
if
(
root
[
"
tool
"
][
"
name
"
]){
const
toolName
=
new
Result
(
"
Tool
"
,
root
[
"
tool
"
][
"
name
"
],
[],
[],
vscode
.
TreeItemCollapsibleState
.
None
,
label
);
values
.
push
(
toolName
);
}
var
data
:
Result
[]
=
[];
if
(
root
[
"
open-parameter-values
"
]){
const
openParameterValues
=
new
Result
(
"
Open parameter values
"
,
`(
${
root
[
"
open-parameter-values
"
].
length
}
)`
,
this
.
valuesToResults
(
root
[
"
open-parameter-values
"
],
"
Open parameter values
"
),
[],
vscode
.
TreeItemCollapsibleState
.
Collapsed
,
label
);
data
.
push
(
openParameterValues
);
}
const
analysisResultsData
=
new
Result
(
"
Analysis results
"
,
`(
${
root
[
"
data
"
].
length
}
)`
,
[],
this
.
dataToResult
(
root
[
"
data
"
],
null
),
vscode
.
TreeItemCollapsibleState
.
Expanded
,
label
);
data
.
push
(
analysisResultsData
);
return
new
Result
(
this
.
modestFile
,
""
,
values
,
data
,
vscode
.
TreeItemCollapsibleState
.
Expanded
,
null
);
}
dataToResult
(
data
:
JSON
[],
parentName
:
string
|
null
)
{
var
results
:
Result
[]
=
[];
data
.
forEach
((
element
:
{
[
x
:
string
]:
any
})
=>
{
...
...
@@ -80,10 +119,10 @@ export class AnalysisResultsProvider
}
var
value
=
element
[
"
value
"
]
?
String
(
element
[
"
value
"
])
:
""
;
var
values
=
element
[
"
values
"
]
?
this
.
valuesToResults
(
element
[
"
values
"
])
?
this
.
valuesToResults
(
element
[
"
values
"
]
,
label
)
:
[];
var
data
=
element
[
"
data
"
]
?
this
.
dataToResult
(
element
[
"
data
"
])
?
this
.
dataToResult
(
element
[
"
data
"
]
,
label
)
:
[];
results
.
push
(
new
Result
(
...
...
@@ -91,7 +130,8 @@ export class AnalysisResultsProvider
value
,
values
,
data
,
vscode
.
TreeItemCollapsibleState
.
Collapsed
vscode
.
TreeItemCollapsibleState
.
Collapsed
,
parentName
)
);
});
...
...
@@ -99,7 +139,7 @@ export class AnalysisResultsProvider
return
results
;
}
valuesToResults
(
values
:
JSON
[])
{
valuesToResults
(
values
:
JSON
[]
,
parentName
:
string
|
null
)
{
var
results
:
Result
[]
=
[];
values
.
forEach
((
v
:
{
[
x
:
string
]:
any
})
=>
{
...
...
@@ -113,7 +153,8 @@ export class AnalysisResultsProvider
value
,
[],
[],
vscode
.
TreeItemCollapsibleState
.
None
vscode
.
TreeItemCollapsibleState
.
None
,
parentName
)
);
});
...
...
@@ -133,7 +174,7 @@ export class AnalysisResultsProvider
return
this
.
modestFile
;
}
private
pathExists
(
p
:
string
):
boolean
{
pathExists
(
p
:
string
):
boolean
{
try
{
fs
.
accessSync
(
p
);
}
catch
(
err
)
{
...
...
@@ -144,18 +185,24 @@ export class AnalysisResultsProvider
}
export
class
Result
extends
vscode
.
TreeItem
{
constructor
(
public
readonly
label
:
string
,
private
value
:
string
,
private
values
:
Result
[],
private
data
:
Result
[],
public
readonly
collapsibleState
:
vscode
.
TreeItemCollapsibleState
public
readonly
collapsibleState
:
vscode
.
TreeItemCollapsibleState
,
private
parentName
:
string
|
null
)
{
super
(
label
,
collapsibleState
);
this
.
tooltip
=
`
${
this
.
label
}
:
${
this
.
value
}
`
;
this
.
description
=
this
.
value
;
}
getParentName
()
{
return
this
.
parentName
;
}
getLabel
()
{
return
this
.
label
;
}
...
...
This diff is collapsed.
Click to expand it.
src/extension.ts
+
59
−
19
View file @
db4d89b9
...
...
@@ -212,7 +212,7 @@ export function activate(context: ExtensionContext) {
vscode
.
commands
.
registerCommand
(
"
analysisResults.openInEditor
"
,
(
res
:
Result
)
=>
openInEditor
(
res
.
getLabel
(),
res
.
getValue
()
)
(
res
:
Result
)
=>
openInEditor
(
analysisResultsProvider
,
res
)
);
vscode
.
commands
.
registerCommand
(
...
...
@@ -304,8 +304,6 @@ function loadResults(provider: AnalysisResultsProvider) {
var
fpath
=
fileUri
[
0
].
fsPath
;
provider
.
setJsonPath
(
fpath
);
vscode
.
window
.
showInformationMessage
(
`Opened
${
fpath
.
split
(
"
/
"
).
pop
()}
.`
);
}
else
{
vscode
.
window
.
showInformationMessage
(
`Could not open selected file.`
);
}
});
}
...
...
@@ -318,25 +316,67 @@ function exportResults(provider: AnalysisResultsProvider) {
});
}
function
openInEditor
(
label
:
string
,
value
:
string
)
{
function
openInEditor
(
prov
:
AnalysisResultsProvider
,
res
:
Result
)
{
if
(
vscode
.
workspace
.
workspaceFolders
!==
undefined
)
{
let
wsPath
=
vscode
.
workspace
.
workspaceFolders
[
0
].
uri
.
path
;
const
date
=
new
Date
().
toISOString
().
split
(
'
.
'
)[
0
];
const
newFile
=
vscode
.
Uri
.
parse
(
`untitled:
${
wsPath
}
/analysis/
${
label
}
-
${
date
}
.txt`
);
vscode
.
workspace
.
openTextDocument
(
newFile
).
then
(
async
document
=>
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
const
regex
=
new
RegExp
(
'
(
\\
)|
\\
.),
'
,
'
gm
'
);
var
newText
=
value
.
replace
(
regex
,
"
$1,
\n
"
);
console
.
log
(
newText
);
edit
.
insert
(
newFile
,
new
vscode
.
Position
(
0
,
0
),
newText
);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
if
(
success
)
{
vscode
.
window
.
showTextDocument
(
document
);
}
else
{
vscode
.
window
.
showInformationMessage
(
`Could not open
${
label
}
in editor.`
);
}
});
const
parent
=
res
.
getParentName
()
?
res
.
getParentName
()
+
"
-
"
:
""
;
const
newPath
=
`
${
wsPath
}
/analysis/
${
prov
.
getModestFile
()}
-
${
parent
}${
res
.
getLabel
()}
.txt`
;
const
regex
=
new
RegExp
(
'
(
\\
)|
\\
.),
'
,
'
gm
'
);
const
newText
=
res
.
getValue
().
replace
(
regex
,
"
$1,
\n
"
);
if
(
pathExists
(
newPath
))
{
vscode
.
workspace
.
openTextDocument
(
newPath
).
then
(
async
document
=>
{
var
overwrite
=
await
vscode
.
window
.
showInformationMessage
(
`This value already has been saved as a text file.`
,
"
Open existing file
"
,
"
Create new file
"
,
"
Overwrite file
"
);
if
(
overwrite
===
"
Overwrite file
"
)
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
replace
(
vscode
.
Uri
.
parse
(
newPath
),
new
vscode
.
Range
(
new
vscode
.
Position
(
0
,
0
),
document
.
positionAt
(
document
.
getText
().
length
-
1
)),
newText
);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
if
(
success
)
{
vscode
.
window
.
showTextDocument
(
document
);
}
}
else
if
(
overwrite
===
"
Open existing file
"
)
{
vscode
.
window
.
showTextDocument
(
document
);
}
else
if
(
overwrite
===
"
Create new file
"
)
{
const
newFile
=
vscode
.
Uri
.
parse
(
`untitled:
${
newPath
.
replace
(
"
.txt
"
,
""
)}
-
${
date
}
.txt`
);
vscode
.
workspace
.
openTextDocument
(
newFile
).
then
(
async
document
=>
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
edit
.
insert
(
newFile
,
new
vscode
.
Position
(
0
,
0
),
newText
);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
if
(
success
)
{
vscode
.
window
.
showTextDocument
(
document
);
}
});
}
});
}
else
{
const
newFile
=
vscode
.
Uri
.
parse
(
"
untitled:
"
+
newPath
);
vscode
.
workspace
.
openTextDocument
(
newFile
).
then
(
async
document
=>
{
const
edit
=
new
vscode
.
WorkspaceEdit
();
const
regex
=
new
RegExp
(
'
(
\\
)|
\\
.),
'
,
'
gm
'
);
var
newText
=
res
.
getValue
().
replace
(
regex
,
"
$1,
\n
"
);
edit
.
insert
(
newFile
,
new
vscode
.
Position
(
0
,
0
),
newText
);
const
success
=
await
vscode
.
workspace
.
applyEdit
(
edit
);
if
(
success
)
{
vscode
.
window
.
showTextDocument
(
document
);
}
});
}
}
}
function
pathExists
(
p
:
string
):
boolean
{
try
{
fs
.
accessSync
(
p
);
}
catch
(
err
)
{
return
false
;
}
return
true
;
}
class
ModestSidebarProvider
implements
vscode
.
WebviewViewProvider
{
...
...
@@ -443,7 +483,7 @@ class ModestSidebarProvider implements vscode.WebviewViewProvider {
<h3>Constants</h3>
<ul class="option-list" id="constants">There are no undefined constants.</ul>
<h3>Options</h3>
<ul class="option-list" id="options">There are no undefined
options.
</ul>
<ul class="option-list" id="options">There are no undefined</ul>
<script nonce="
${
nonce
}
" src="
${
scriptUri
}
"></script>
</body>
</html>`
;
...
...
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