refactor(lsp): migrate remaining LSP console calls to debugLogger

- LspConfigLoader.ts: 7 console.warn calls → debugLogger.warn
- LspConnectionFactory.ts: 1 console.warn call → debugLogger.warn
- Add eslint no-console overrides for test files and scripts
- Completes LSP subsystem migration (8 more calls)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
tanzhenxin 2026-02-02 17:50:18 +08:00
parent c261db3ef7
commit 340becefb4
3 changed files with 20 additions and 8 deletions

View file

@ -169,6 +169,7 @@ export default tseslint.config(
...vitest.configs.recommended.rules,
'vitest/expect-expect': 'off',
'vitest/no-commented-out-tests': 'off',
'no-console': 'off', // Allow console in tests
'@typescript-eslint/no-unused-vars': [
'error',
{
@ -190,6 +191,7 @@ export default tseslint.config(
},
},
rules: {
'no-console': 'off', // Allow console in scripts
'@typescript-eslint/no-unused-vars': [
'error',
{

View file

@ -17,6 +17,9 @@ import type {
LspServerConfig,
LspSocketOptions,
} from './types.js';
import { createDebugLogger } from '../utils/debugLogger.js';
const debugLogger = createDebugLogger('LSP');
export class LspConfigLoader {
constructor(private readonly workspaceRoot: string) {}
@ -36,7 +39,7 @@ export class LspConfigLoader {
const data = JSON.parse(configContent);
return this.parseConfigSource(data, lspConfigPath);
} catch (error) {
console.warn('Failed to load user .lsp.json config:', error);
debugLogger.warn('Failed to load user .lsp.json config:', error);
return [];
}
}
@ -62,7 +65,9 @@ export class LspConfigLoader {
lspServers,
);
if (!fs.existsSync(configPath)) {
console.warn(`LSP config not found for ${originBase}: ${configPath}`);
debugLogger.warn(
`LSP config not found for ${originBase}: ${configPath}`,
);
continue;
}
@ -77,7 +82,7 @@ export class LspConfigLoader {
),
);
} catch (error) {
console.warn(
debugLogger.warn(
`Failed to load extension LSP config from ${configPath}:`,
error,
);
@ -91,7 +96,7 @@ export class LspConfigLoader {
...this.parseConfigSource(hydrated, `${originBase} (lspServers)`),
);
} else {
console.warn(
debugLogger.warn(
`LSP config for ${originBase} must be an object or a JSON file path.`,
);
}
@ -316,12 +321,14 @@ export class LspConfigLoader {
const socket = this.normalizeSocketOptions(spec);
if (transport === 'stdio' && !command) {
console.warn(`LSP config error in ${origin}: ${name} missing command`);
debugLogger.warn(
`LSP config error in ${origin}: ${name} missing command`,
);
return null;
}
if (transport !== 'stdio' && !socket) {
console.warn(
debugLogger.warn(
`LSP config error in ${origin}: ${name} missing socket info`,
);
return null;
@ -485,7 +492,7 @@ export class LspConfigLoader {
return resolved;
}
console.warn(
debugLogger.warn(
`LSP workspaceFolder must be within ${this.workspaceRoot}; using workspace root instead.`,
);
return this.workspaceRoot;

View file

@ -8,6 +8,9 @@ import * as cp from 'node:child_process';
import * as net from 'node:net';
import { DEFAULT_LSP_REQUEST_TIMEOUT_MS } from './constants.js';
import type { JsonRpcMessage } from './types.js';
import { createDebugLogger } from '../utils/debugLogger.js';
const debugLogger = createDebugLogger('LSP');
interface PendingRequest {
resolve: (value: unknown) => void;
@ -375,7 +378,7 @@ export class LspConnectionFactory {
try {
await lspConnection.connection.shutdown();
} catch (e) {
console.warn('LSP shutdown failed:', e);
debugLogger.warn('LSP shutdown failed:', e);
} finally {
lspConnection.connection.end();
}