Skip to content

Commit

Permalink
Merge pull request #11 from Microsoft/develop
Browse files Browse the repository at this point in the history
Using pattern in the DocumentFilter for compose files and removing th…
  • Loading branch information
Peter Jausovec authored and Peter Jausovec committed Nov 13, 2015
2 parents 31fb1d1 + d0613fe commit ad5f11d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion dockerCompose/dockerComposeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
2 changes: 1 addition & 1 deletion dockerExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(), '.'))
Expand Down
4 changes: 0 additions & 4 deletions dockerHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export class DockerHoverProvider implements HoverProvider {
}

public provideHover(document: TextDocument, position: Position, token: CancellationToken): Thenable<Hover> {
if (!this._parser.isFileSupported(document.fileName)) {
return Promise.resolve(null);
}

var line = document.lineAt(position.line);

if (line.text.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion dockerfile/dockerfileParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
12 changes: 1 addition & 11 deletions parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ad5f11d

Please sign in to comment.