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