fix bug of treeView
This commit is contained in:
parent
ee9e990446
commit
9aba47ac10
@ -2,3 +2,8 @@
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
npm i
|
||||
```
|
||||
|
||||
Enter Vscode & F5
|
@ -322,7 +322,7 @@
|
||||
"activitybar": [
|
||||
{
|
||||
"id": "TreeView",
|
||||
"title": "Digital-IDE",
|
||||
"title": "Digital-IDE: TreeView",
|
||||
"icon": "images/svg/view.svg"
|
||||
}
|
||||
]
|
||||
|
@ -6,18 +6,6 @@
|
||||
"soc": {
|
||||
"core": "none"
|
||||
},
|
||||
"arch": {
|
||||
"prjPath": "./prj",
|
||||
"hardware": {
|
||||
"src": "./user/src",
|
||||
"sim": "./user/sim",
|
||||
"data": "./user/data"
|
||||
},
|
||||
"software": {
|
||||
"src": "./user/software/src",
|
||||
"data": "./user/software/data"
|
||||
}
|
||||
},
|
||||
"enableShowLog": false,
|
||||
"device": "none"
|
||||
}
|
@ -20,7 +20,7 @@ async function launch(context: vscode.ExtensionContext) {
|
||||
|
||||
console.timeLog('launch');
|
||||
|
||||
await registerCommand(context);
|
||||
await registerCommand(context);
|
||||
MainOutput.report('Digital-IDE has launched, Version: 0.3.0');
|
||||
MainOutput.report('OS: ' + opeParam.os);
|
||||
}
|
||||
|
@ -3,11 +3,21 @@ import { hdlPath } from '../../hdlFs';
|
||||
|
||||
import { hardwareTreeProvider, softwareTreeProvider, toolTreeProvider } from './command';
|
||||
import { moduleTreeProvider, ModuleDataItem } from './tree';
|
||||
import { Range } from '../../hdlParser/common';
|
||||
|
||||
async function openFileAtPosition(uri: vscode.Uri, line: number, character: number) {
|
||||
const document = await vscode.workspace.openTextDocument(uri);
|
||||
const editor = await vscode.window.showTextDocument(document);
|
||||
const position = new vscode.Position(line, character);
|
||||
editor.selection = new vscode.Selection(position, position);
|
||||
editor.revealRange(new vscode.Range(position, position));
|
||||
}
|
||||
|
||||
function openFileByUri(uri: string) {
|
||||
if (hdlPath.exist(uri)) {
|
||||
vscode.window.showTextDocument(vscode.Uri.file(uri));
|
||||
function openFileByUri(path: string, range: Range) {
|
||||
if (hdlPath.exist(path)) {
|
||||
const uri = vscode.Uri.file(path);
|
||||
const start = range.start;
|
||||
openFileAtPosition(uri, start.line - 1, start.character);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import * as vscode from 'vscode';
|
||||
import { AbsPath, MainOutput, opeParam, ReportType } from '../../global';
|
||||
import { SimPath, SrcPath } from '../../global/prjInfo';
|
||||
import { HdlInstance, hdlParam } from '../../hdlParser/core';
|
||||
import { HdlFileType } from '../../hdlParser/common';
|
||||
import { HdlFileType, Range } from '../../hdlParser/common';
|
||||
import { hdlFile, hdlPath } from '../../hdlFs';
|
||||
import { xilinx, itemModes, otherModes } from './common';
|
||||
import { getIconConfig } from '../../hdlFs/icons';
|
||||
@ -13,7 +13,8 @@ let needExpand = true;
|
||||
interface ModuleDataItem {
|
||||
icon: string, // 图标
|
||||
name: string, // module name
|
||||
type: string,
|
||||
type: string,
|
||||
range: Range | null,
|
||||
path: AbsPath | undefined, // path of the file
|
||||
parent: ModuleDataItem | null // parent file
|
||||
}
|
||||
@ -64,8 +65,8 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
||||
src: null,
|
||||
sim: null,
|
||||
};
|
||||
this.srcRootItem = {icon: 'src', type: HdlFileType.Src, name: 'src', path: '', parent: null};
|
||||
this.simRootItem = {icon: 'sim', type: HdlFileType.Sim, name: 'sim', path: '', parent: null};
|
||||
this.srcRootItem = {icon: 'src', type: HdlFileType.Src, name: 'src', range: null, path: '', parent: null};
|
||||
this.simRootItem = {icon: 'sim', type: HdlFileType.Sim, name: 'sim', range: null, path: '', parent: null};
|
||||
|
||||
}
|
||||
|
||||
@ -120,13 +121,12 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
||||
|
||||
// set iconPath
|
||||
treeItem.iconPath = getIconConfig(element.icon);
|
||||
|
||||
|
||||
// set command
|
||||
treeItem.command = {
|
||||
title: "Open this HDL File",
|
||||
// TODO : 修改这里的指令前缀
|
||||
command: 'TOOL.tree.arch.openFile',
|
||||
arguments: [element.path],
|
||||
command: 'digital-ide.treeView.arch.openFile',
|
||||
arguments: [element.path, element.range],
|
||||
};
|
||||
|
||||
return treeItem;
|
||||
@ -164,6 +164,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
||||
icon: 'top',
|
||||
type: moduleType,
|
||||
name: module.name,
|
||||
range: module.range,
|
||||
path: module.path,
|
||||
parent: element,
|
||||
}));
|
||||
@ -178,6 +179,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
||||
const name = this.firstTop[type]!.name;
|
||||
const path = this.firstTop[type]!.path;
|
||||
const icon = this.makeFirstTopIconName(type);
|
||||
const range = firstTop.range;
|
||||
const parent = element;
|
||||
|
||||
const tops = topModuleItemList.filter(item => item.path === path && item.name === name);
|
||||
@ -197,7 +199,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
||||
} else {
|
||||
// mean the selected top is not an original top module
|
||||
// create it and add it to the head of *topModuleItemList*
|
||||
const selectedTopItem: ModuleDataItem = {icon, type, name, path, parent};
|
||||
const selectedTopItem: ModuleDataItem = {icon, type, name, range, path, parent};
|
||||
adjustItemList.push(selectedTopItem);
|
||||
adjustItemList.push(...topModuleItemList);
|
||||
}
|
||||
@ -222,6 +224,7 @@ class ModuleTreeProvider implements vscode.TreeDataProvider<ModuleDataItem> {
|
||||
icon: 'file',
|
||||
type: instance.name,
|
||||
name: instance.type,
|
||||
range: instance.module ? instance.module.range : null,
|
||||
path: instance.instModPath,
|
||||
parent: element
|
||||
};
|
||||
|
@ -44,15 +44,15 @@ const PrjInfoDefaults: PrjInfoMeta = {
|
||||
device: 'none',
|
||||
|
||||
arch: {
|
||||
prjPath: '',
|
||||
prjPath: './prj',
|
||||
hardware: {
|
||||
src: '',
|
||||
sim: '',
|
||||
data: ''
|
||||
src: './user/src',
|
||||
sim: './user/sim',
|
||||
data: './user/data'
|
||||
},
|
||||
software: {
|
||||
src: '',
|
||||
data: ''
|
||||
src: './user/software/src',
|
||||
data: './user/software/data'
|
||||
}
|
||||
},
|
||||
|
||||
@ -436,8 +436,13 @@ class PrjInfo implements PrjInfoMeta {
|
||||
}
|
||||
|
||||
public getLibraryCustomPaths(absolute: boolean = true): Path[] {
|
||||
const libCustomPath = this.libCustomPath;
|
||||
if (libCustomPath === '') {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (absolute) {
|
||||
const configFolder = hdlPath.join(this.libCustomPath, 'Empty');
|
||||
const configFolder = hdlPath.join(libCustomPath, 'Empty');
|
||||
return this._library.hardware.custom.map<Path>(relPath => hdlPath.rel2abs(configFolder, relPath));
|
||||
}
|
||||
return this._library.hardware.custom;
|
||||
@ -481,7 +486,7 @@ class PrjInfo implements PrjInfoMeta {
|
||||
public get libCustomPath(): AbsPath {
|
||||
const libPath = vscode.workspace.getConfiguration().get('prj.lib.custom.path', this._workspacePath);
|
||||
if (!fs.existsSync(libPath)) {
|
||||
vscode.window.showErrorMessage('property "prj.lib.custom.path" is empty or is an invalid path');
|
||||
return '';
|
||||
}
|
||||
return libPath;
|
||||
}
|
||||
|
@ -67,10 +67,6 @@ class LibManage {
|
||||
return hdlPath.join(opeParam.extensionPath, 'lib');
|
||||
}
|
||||
|
||||
public get libCustomPath(): AbsPath {
|
||||
return opeParam.prjInfo.libCustomPath;
|
||||
}
|
||||
|
||||
public processLibFiles(library: Library): LibFileChange {
|
||||
// 在不设置state属性的时候默认为remote
|
||||
this.next.list = this.getLibFiles(library);
|
||||
|
@ -155,6 +155,8 @@ class LibPick {
|
||||
|
||||
if (selectedPath && hdlPath.exist(selectedPath)) {
|
||||
const userPrjInfo = opeParam.getUserPrjInfo();
|
||||
console.log(userPrjInfo);
|
||||
|
||||
if (selectedPath.includes(this.commonQuickPickItem.path!)) {
|
||||
// this is a module import from common, use relative path
|
||||
const relPath = selectedPath.replace(this.commonQuickPickItem.path + '/', '');
|
||||
|
@ -16,7 +16,7 @@ class PrjManage {
|
||||
return;
|
||||
}
|
||||
const template = hdlFile.readJSON(opeParam.propertyInitPath) as RawPrjInfo;
|
||||
template.arch?.hardware.
|
||||
|
||||
hdlFile.writeJSON(opeParam.propertyJsonPath, template);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user