diff --git a/dockerCompose/dockerComposeParser.ts b/dockerCompose/dockerComposeParser.ts index a8426ad209..0a6e4f509f 100644 --- a/dockerCompose/dockerComposeParser.ts +++ b/dockerCompose/dockerComposeParser.ts @@ -10,7 +10,7 @@ import {Parser, TokenType, IToken} from '../parser'; export class DockerComposeParser extends Parser { constructor() { var parseRegex = /\:+$/g; - super(parseRegex, /docker\-compose\.yml$/); + super(parseRegex); } parseLine(textLine: vscode.TextLine): IToken[] { diff --git a/dockerExtension.ts b/dockerExtension.ts index 6131cf9374..184aa33dee 100644 --- a/dockerExtension.ts +++ b/dockerExtension.ts @@ -17,7 +17,7 @@ export function activate(ctx: vscode.ExtensionContext): void { ctx.subscriptions.push(vscode.languages.registerHoverProvider(DOCKERFILE_MODE_ID, dockerHoverProvider)); ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(DOCKERFILE_MODE_ID, new DockerfileCompletionItemProvider(), '.')); - const YAML_MODE_ID: vscode.DocumentFilter = { language: 'yaml', scheme: 'file'}; + const YAML_MODE_ID: vscode.DocumentFilter = { language: 'yaml', scheme: 'file', pattern: '**/docker-compose.yml' }; var yamlHoverProvider = new DockerHoverProvider(new DockerComposeParser(), DOCKER_COMPOSE_KEY_INFO); ctx.subscriptions.push(vscode.languages.registerHoverProvider(YAML_MODE_ID, yamlHoverProvider)); ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(YAML_MODE_ID, new DockerComposeCompletionItemProvider(), '.')) diff --git a/dockerHoverProvider.ts b/dockerHoverProvider.ts index a400c15ab4..01bee56524 100644 --- a/dockerHoverProvider.ts +++ b/dockerHoverProvider.ts @@ -20,10 +20,6 @@ export class DockerHoverProvider implements HoverProvider { } public provideHover(document: TextDocument, position: Position, token: CancellationToken): Thenable { - if (!this._parser.isFileSupported(document.fileName)) { - return Promise.resolve(null); - } - var line = document.lineAt(position.line); if (line.text.length === 0) { diff --git a/dockerfile/dockerfileParser.ts b/dockerfile/dockerfileParser.ts index 356536245d..5f79b7f1c3 100644 --- a/dockerfile/dockerfileParser.ts +++ b/dockerfile/dockerfileParser.ts @@ -10,7 +10,7 @@ import {Parser, TokenType, IToken} from '../parser'; export class DockerfileParser extends Parser { constructor() { var parseRegex = /\ +$/g; - super(parseRegex, undefined); + super(parseRegex); } parseLine(textLine: TextLine): IToken[] { diff --git a/parser.ts b/parser.ts index 6f80ec3009..b81bfcd567 100644 --- a/parser.ts +++ b/parser.ts @@ -8,19 +8,9 @@ import {TextLine} from 'vscode'; export abstract class Parser { _tokenParseRegex: RegExp; - _fileNameRegex: RegExp; - constructor(parseTokenRegex: RegExp, fileNameRegex: RegExp) { + constructor(parseTokenRegex: RegExp) { this._tokenParseRegex = parseTokenRegex; - this._fileNameRegex = fileNameRegex; - } - - isFileSupported(fileName: string): boolean { - if (this._fileNameRegex !== undefined) { - return this._fileNameRegex.test(fileName); - } - - return true; } keyNameFromKeyToken(keyToken: string): string {