mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 09:08:46 +00:00
Move js/ts language mode ids to own file
This commit is contained in:
parent
abcdfe2c8c
commit
e6a76e4bd3
6 changed files with 24 additions and 14 deletions
|
@ -9,6 +9,7 @@ import { workspace, TextDocument, TextDocumentChangeEvent, TextDocumentContentCh
|
|||
import * as Proto from '../protocol';
|
||||
import { ITypescriptServiceClient } from '../typescriptService';
|
||||
import { Delayer } from '../utils/async';
|
||||
import * as languageModeIds from '../utils/languageModeIds';
|
||||
|
||||
interface IDiagnosticRequestor {
|
||||
requestDiagnostic(filepath: string): void;
|
||||
|
@ -16,10 +17,10 @@ interface IDiagnosticRequestor {
|
|||
|
||||
function mode2ScriptKind(mode: string): 'TS' | 'TSX' | 'JS' | 'JSX' | undefined {
|
||||
switch (mode) {
|
||||
case 'typescript': return 'TS';
|
||||
case 'typescriptreact': return 'TSX';
|
||||
case 'javascript': return 'JS';
|
||||
case 'javascriptreact': return 'JSX';
|
||||
case languageModeIds.typescript: return 'TS';
|
||||
case languageModeIds.typescriptreact: return 'TSX';
|
||||
case languageModeIds.javascript: return 'JS';
|
||||
case languageModeIds.javascriptreact: return 'JSX';
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import { tsTextSpanToVsRange, vsPositionToTsFileLocation } from '../utils/conver
|
|||
|
||||
import * as nls from 'vscode-nls';
|
||||
import { applyCodeAction } from '../utils/codeAction';
|
||||
import * as languageModeIds from '../utils/languageModeIds';
|
||||
|
||||
let localize = nls.loadMessageBundle();
|
||||
|
||||
class MyCompletionItem extends CompletionItem {
|
||||
|
@ -236,7 +238,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP
|
|||
const body = msg.body;
|
||||
if (body) {
|
||||
// Only enable dot completions in TS files for now
|
||||
let enableDotCompletions = document && (document.languageId === 'typescript' || document.languageId === 'typescriptreact');
|
||||
let enableDotCompletions = document && (document.languageId === languageModeIds.typescript || document.languageId === languageModeIds.typescriptreact);
|
||||
|
||||
// TODO: Workaround for https://github.com/Microsoft/TypeScript/issues/13456
|
||||
// Only enable dot completions when previous character is an identifier.
|
||||
|
|
|
@ -35,6 +35,7 @@ import { getContributedTypeScriptServerPlugins, TypeScriptServerPlugin } from '.
|
|||
import { openOrCreateConfigFile, isImplicitProjectConfigFile } from './utils/tsconfig';
|
||||
import { tsLocationToVsPosition } from './utils/convert';
|
||||
import FormattingConfigurationManager from './features/formattingConfigurationManager';
|
||||
import * as languageModeIds from './utils/languageModeIds';
|
||||
|
||||
interface LanguageDescription {
|
||||
id: string;
|
||||
|
@ -54,21 +55,16 @@ interface ProjectConfigMessageItem extends MessageItem {
|
|||
id: ProjectConfigAction;
|
||||
}
|
||||
|
||||
const MODE_ID_TS = 'typescript';
|
||||
const MODE_ID_TSX = 'typescriptreact';
|
||||
const MODE_ID_JS = 'javascript';
|
||||
const MODE_ID_JSX = 'javascriptreact';
|
||||
|
||||
const standardLanguageDescriptions: LanguageDescription[] = [
|
||||
{
|
||||
id: 'typescript',
|
||||
diagnosticSource: 'ts',
|
||||
modeIds: [MODE_ID_TS, MODE_ID_TSX],
|
||||
modeIds: [languageModeIds.typescript, languageModeIds.typescriptreact],
|
||||
configFile: 'tsconfig.json'
|
||||
}, {
|
||||
id: 'javascript',
|
||||
diagnosticSource: 'js',
|
||||
modeIds: [MODE_ID_JS, MODE_ID_JSX],
|
||||
modeIds: [languageModeIds.javascript, languageModeIds.javascriptreact],
|
||||
configFile: 'jsconfig.json'
|
||||
}
|
||||
];
|
||||
|
|
9
extensions/typescript/src/utils/languageModeIds.ts
Normal file
9
extensions/typescript/src/utils/languageModeIds.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const typescript = 'typescript';
|
||||
export const typescriptreact = 'typescriptreact';
|
||||
export const javascript = 'javascript';
|
||||
export const javascriptreact = 'javascriptreact';
|
|
@ -8,9 +8,10 @@ import { ITypescriptServiceClient } from '../typescriptService';
|
|||
import { loadMessageBundle } from 'vscode-nls';
|
||||
import { dirname } from 'path';
|
||||
import { openOrCreateConfigFile, isImplicitProjectConfigFile } from './tsconfig';
|
||||
import * as languageModeIds from '../utils/languageModeIds';
|
||||
|
||||
const localize = loadMessageBundle();
|
||||
const selector = ['javascript', 'javascriptreact'];
|
||||
const selector = [languageModeIds.javascript, languageModeIds.javascriptreact];
|
||||
|
||||
|
||||
interface Hint {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import * as vscode from 'vscode';
|
||||
import { TypeScriptVersion } from './versionProvider';
|
||||
import * as languageModeIds from './languageModeIds';
|
||||
|
||||
export default class VersionStatus {
|
||||
private onChangeEditorSub: vscode.Disposable;
|
||||
|
@ -37,7 +38,7 @@ export default class VersionStatus {
|
|||
}
|
||||
|
||||
const doc = vscode.window.activeTextEditor.document;
|
||||
if (vscode.languages.match('typescript', doc) || vscode.languages.match('typescriptreact', doc)) {
|
||||
if (vscode.languages.match([languageModeIds.typescript, languageModeIds.typescriptreact], doc)) {
|
||||
this.versionBarEntry.show();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue