Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed May 22, 2018
1 parent fd6123a commit a538790
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/services/languageFacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,20 +783,42 @@ let atDirectiveList: IEntry[];
export function getAtDirectives(): IEntry[] {
if (!atDirectiveList) {
atDirectiveList = [];
for (let i = 0, len = atDirectives.length; i < len; i++) {
for (let i = 0; i < atDirectives.length; i++) {
let rawEntry = atDirectives[i];
atDirectiveList.push(new EntryImpl(rawEntry));
}
}
return atDirectiveList;
}

import { scssAtDirectives } from '../data/scss';
let scssAtDirectiveList: IEntry[];
export function getScssAtDirectives(): IEntry[] {
if (!atDirectiveList) {
atDirectiveList = [];
for (let i = 0; i < atDirectives.length; i++) {
let rawEntry = atDirectives[i];
atDirectiveList.push(new EntryImpl(rawEntry));
}
}

if (!scssAtDirectiveList) {
scssAtDirectiveList = [];
for (let i = 0; i < scssAtDirectives.length; i++) {
let rawEntry = scssAtDirectives[i];
scssAtDirectiveList.push(new EntryImpl(rawEntry));
}
}

return scssAtDirectiveList.concat(atDirectiveList);
}

let pseudoElements = browsers.data.css.pseudoelements;
let pseudoElementList: IEntry[];
export function getPseudoElements(): IEntry[] {
if (!pseudoElementList) {
pseudoElementList = [];
for (let i = 0, len = pseudoElements.length; i < len; i++) {
for (let i = 0; i < pseudoElements.length; i++) {
let rawEntry = pseudoElements[i];
pseudoElementList.push(new EntryImpl(rawEntry));
}
Expand All @@ -809,7 +831,7 @@ let pseudoClassesList: IEntry[];
export function getPseudoClasses(): IEntry[] {
if (!pseudoClassesList) {
pseudoClassesList = [];
for (let i = 0, len = pseudoClasses.length; i < len; i++) {
for (let i = 0; i < pseudoClasses.length; i++) {
let rawEntry = pseudoClasses[i];
pseudoClassesList.push(new EntryImpl(rawEntry));
}
Expand Down
14 changes: 14 additions & 0 deletions src/services/scssCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,19 @@ export class SCSSCompletion extends CSSCompletion {
return result;
}

public getCompletionForTopLevel(result: CompletionList): CompletionList {
for (let entry of languageFacts.getScssAtDirectives()) {
if (entry.browsers.count > 0) {
result.items.push({
label: entry.name,
textEdit: TextEdit.replace(this.getCompletionRange(null), entry.name),
documentation: languageFacts.getEntryDescription(entry),
kind: CompletionItemKind.Keyword
});
}
}
this.getCompletionsForSelector(null, false, result);
return result;
}
}

15 changes: 15 additions & 0 deletions src/test/scss/scssCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,21 @@ suite('SCSS - Completions', () => {
{ label: '.foo' }
]
});
testCompletionFor('@', {
items: [
{ label: '@extend' },
{ label: '@at-root' },
{ label: '@debug' },
{ label: '@warn' },
{ label: '@error' },
{ label: '@if' },
{ label: '@for' },
{ label: '@each' },
{ label: '@while' },
{ label: '@mixin' },
{ label: '@include' }
]
});
// issue #250
testCompletionFor('.foo { display: block;|', {
count: 0
Expand Down

0 comments on commit a538790

Please sign in to comment.