Skip to content

Commit 59707af

Browse files
committed
assembled parser with group and now have working parser with console logs to move forward to mvp
1 parent 288f531 commit 59707af

File tree

4 files changed

+524
-99
lines changed

4 files changed

+524
-99
lines changed

extension.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ function activate(context) {
1818
});
1919

2020
vscode.commands.registerCommand('myExtension.pickFile', async () => {
21-
const tree = new Parser();
22-
const file = await vscode.window.showOpenDialog({ canSelectFolders: true, canSelectFiles: true, canSelectMany: true });
23-
tree.grabFile(file);
21+
const fileArray = await vscode.window.showOpenDialog({ canSelectFolders: false, canSelectFiles: true, canSelectMany: false });
22+
const tree = new Parser(fileArray[0].path);
23+
tree.parse();
24+
console.log('tree instance', tree);
2425
});
2526

2627
context.subscriptions.push(disposable, result);

src/panel.js

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
const vscode = require('vscode');
2+
const { getNonce } = require('./getNonce.js');
3+
const { Parser } = require('./parser.js');
4+
5+
// let panel;
26

37
function createPanel(context) {
8+
// if the current panel exists, then reveal the column, else make one?
9+
410
// utilize method on vscode.window object to create webview
511
const panel = vscode.window.createWebviewPanel(
612
'reactLabyrinth',
@@ -22,8 +28,34 @@ function createPanel(context) {
2228

2329
// render html of webview here
2430
panel.webview.html = createWebviewHTML(bundleURI);
31+
32+
// will need to use onDidDispose to clear cached data and reset tree when the webview and/or application is closed
33+
34+
// from my understadning, we will have to use onDidReceiveMessage to send message from the webview to and from the extension. its sent and read based on the switch case 'string' and then activates their functionality there
35+
36+
// we will need to grab the value of the root file path => then make new instance of parser => call parse method on new instance => then create a func to then post a message to our flow.jsx
37+
38+
// panel.webview.onDidReceiveMessage(
39+
// async (msg) => {
40+
// console.log('Message: ', msg)
41+
// switch (msg.type) {
42+
// case 'test':
43+
// console.log('testing onDidReceiveMessage');
44+
45+
// break;
46+
// }
47+
// },
48+
// null,
49+
// vscode.Disposable
50+
// );
51+
52+
2553
}
2654

55+
// getNonce generates a new random string each time ext is used to prevent external injection of foreign code into the html
56+
const nonce = getNonce();
57+
58+
// function to update state in webview
2759

2860
// function to create the HTML page for webview
2961
function createWebviewHTML(URI) {
@@ -38,11 +70,18 @@ function createWebviewHTML(URI) {
3870
</head>
3971
<body>
4072
<div id="root"></div>
41-
<script src=${URI}></script>
73+
<script>
74+
const vscode = acquireVsCodeApi();
75+
window.onload = () => {
76+
console.log('VsCode: ', vscode)
77+
vscode.postMessage({command: 'startup'})
78+
}
79+
</script>
80+
<script nonce=${nonce} src=${URI}></script>
4281
</body>
4382
</html>
4483
`
4584
)
4685
}
4786

48-
module.exports = {createPanel};
87+
module.exports = { createPanel };

0 commit comments

Comments
 (0)