修改 common 模式下的 linter 模式
This commit is contained in:
parent
048fa9d2ea
commit
9f44885060
@ -1,7 +1,7 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import { MainOutput, ReportType, IProgress } from './global';
|
import { MainOutput, ReportType, IProgress, globalLookup } from './global';
|
||||||
import { hdlParam } from './hdlParser';
|
import { hdlParam } from './hdlParser';
|
||||||
import * as manager from './manager';
|
import * as manager from './manager';
|
||||||
import * as lspLinter from './function/lsp/linter';
|
import * as lspLinter from './function/lsp/linter';
|
||||||
@ -72,6 +72,9 @@ async function launch(context: vscode.ExtensionContext) {
|
|||||||
await registerCommand(context, packageJson);
|
await registerCommand(context, packageJson);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 注册全局变量
|
||||||
|
globalLookup.activeEditor = vscode.window.activeTextEditor;
|
||||||
|
|
||||||
await vscode.window.withProgress({
|
await vscode.window.withProgress({
|
||||||
location: vscode.ProgressLocation.Window,
|
location: vscode.ProgressLocation.Window,
|
||||||
title: t('info.progress.initialize-configure')
|
title: t('info.progress.initialize-configure')
|
||||||
|
@ -7,12 +7,6 @@ import { WASI } from 'wasi';
|
|||||||
|
|
||||||
type SynthMode = 'before' | 'after' | 'RTL';
|
type SynthMode = 'before' | 'after' | 'RTL';
|
||||||
type AbsPath = string;
|
type AbsPath = string;
|
||||||
enum HdlLangID {
|
|
||||||
Verilog = 'verilog',
|
|
||||||
SystemVerilog = 'systemverilog',
|
|
||||||
Vhdl = 'vhdl',
|
|
||||||
Unknown = 'Unknown'
|
|
||||||
};
|
|
||||||
|
|
||||||
interface SimpleOpe {
|
interface SimpleOpe {
|
||||||
workspacePath: string,
|
workspacePath: string,
|
||||||
|
@ -5,9 +5,10 @@ import * as Linter from '../lsp/linter/common';
|
|||||||
import { HdlLangID } from '../../global/enum';
|
import { HdlLangID } from '../../global/enum';
|
||||||
import * as lspLinter from '../lsp/linter';
|
import * as lspLinter from '../lsp/linter';
|
||||||
import { t } from '../../i18n';
|
import { t } from '../../i18n';
|
||||||
import { IProgress } from '../../global';
|
import { globalLookup, IProgress } from '../../global';
|
||||||
import { refreshWorkspaceDiagonastics } from '../lsp/linter/manager';
|
import { clearDiagnostics, publishDiagnostics, refreshWorkspaceDiagonastics } from '../lsp/linter/manager';
|
||||||
import { prjManage } from '../../manager';
|
import { prjManage } from '../../manager';
|
||||||
|
import { hdlFile, hdlPath } from '../../hdlFs';
|
||||||
|
|
||||||
interface ConfigItem {
|
interface ConfigItem {
|
||||||
name: string,
|
name: string,
|
||||||
@ -167,12 +168,24 @@ export async function registerLinter(client: LanguageClient) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 切换标签页时的行为
|
// 切换标签页时的行为
|
||||||
vscode.window.onDidChangeActiveTextEditor(editor => {
|
vscode.window.onDidChangeActiveTextEditor(async editor => {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('change to ', editor);
|
const linterMode = Linter.getLinterMode();
|
||||||
})
|
const currentPath = hdlPath.toEscapePath(editor.document.fileName);
|
||||||
|
if (globalLookup.activeEditor && linterMode === 'common') {
|
||||||
|
const previousPath = hdlPath.toEscapePath(globalLookup.activeEditor.document.fileName);
|
||||||
|
if (hdlFile.isHDLFile(previousPath)) {
|
||||||
|
clearDiagnostics(client, previousPath);
|
||||||
|
}
|
||||||
|
if (hdlFile.isHDLFile(currentPath)) {
|
||||||
|
publishDiagnostics(client, currentPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
globalLookup.activeEditor = editor;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import * as vscode from 'vscode';
|
||||||
import { opeParam, OpeParamDefaults } from './opeParam';
|
import { opeParam, OpeParamDefaults } from './opeParam';
|
||||||
import { PrjInfo, PrjInfoDefaults } from './prjInfo';
|
import { PrjInfo, PrjInfoDefaults } from './prjInfo';
|
||||||
import { MainOutput, LinterOutput, YosysOutput, WaveViewOutput, ReportType } from './outputChannel';
|
import { MainOutput, LinterOutput, YosysOutput, WaveViewOutput, ReportType } from './outputChannel';
|
||||||
@ -11,12 +12,19 @@ type RelPath = string;
|
|||||||
|
|
||||||
type AllowNull<T> = T | null;
|
type AllowNull<T> = T | null;
|
||||||
|
|
||||||
|
|
||||||
interface IProgress {
|
interface IProgress {
|
||||||
message?: string,
|
message?: string,
|
||||||
increment?: number
|
increment?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IGlobalLookup {
|
||||||
|
activeEditor?: vscode.TextEditor
|
||||||
|
}
|
||||||
|
|
||||||
|
const globalLookup: IGlobalLookup = {
|
||||||
|
activeEditor: undefined
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
opeParam,
|
opeParam,
|
||||||
OpeParamDefaults,
|
OpeParamDefaults,
|
||||||
@ -33,5 +41,6 @@ export {
|
|||||||
ReportType,
|
ReportType,
|
||||||
AllowNull,
|
AllowNull,
|
||||||
LspClient,
|
LspClient,
|
||||||
IProgress
|
IProgress,
|
||||||
|
globalLookup
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user