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