Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (/^[<\(\[\"]/.test(item.text)) {
return false;
}
// magic words
if (['default', 'constructor', 'new()'].indexOf(item.text) >= 0) {
return false;
}
return true;
}
}
/**
* Maps string-based CompletionEntry::kind to enum-based CompletionItemKind
*/
const completionKinds: { [name: string]: CompletionItemKind } = {
class: CompletionItemKind.Class,
constructor: CompletionItemKind.Constructor,
enum: CompletionItemKind.Enum,
field: CompletionItemKind.Field,
file: CompletionItemKind.File,
function: CompletionItemKind.Function,
interface: CompletionItemKind.Interface,
keyword: CompletionItemKind.Keyword,
method: CompletionItemKind.Method,
module: CompletionItemKind.Module,
property: CompletionItemKind.Property,
reference: CompletionItemKind.Reference,
snippet: CompletionItemKind.Snippet,
text: CompletionItemKind.Text,
unit: CompletionItemKind.Unit,
value: CompletionItemKind.Value,
variable: CompletionItemKind.Variable
createType(typeName: string): CompletionItem {
let completionItem = this.createCompletionItem(this.last_id++, typeName, 'Type', '', CompletionItemKind.Class);
completionItem.insertText = ' ' + typeName; // prefix with a space for formatting
return completionItem;
}
export function isWindows(): boolean {
return /^win/.test(process.platform);
}
export function uriToPath(uri: string): string {
const p = path.resolve(uri.replace(/file:\/\/\//, ''));
return isWindows() ? p.replace(/\//g, '\\') : p;
}
export function pathToUri(p: string): string {
return 'file://' + (isWindows() ? '/' + p.replace(/\//g, '/') : p);
}
export const completionKindsMapping: { [name: string]: CompletionItemKind } = {
class: CompletionItemKind.Class,
constructor: CompletionItemKind.Constructor,
enum: CompletionItemKind.Enum,
field: CompletionItemKind.Field,
file: CompletionItemKind.File,
function: CompletionItemKind.Function,
interface: CompletionItemKind.Interface,
keyword: CompletionItemKind.Keyword,
method: CompletionItemKind.Method,
module: CompletionItemKind.Module,
property: CompletionItemKind.Property,
reference: CompletionItemKind.Reference,
snippet: CompletionItemKind.Snippet,
text: CompletionItemKind.Text,
unit: CompletionItemKind.Unit,
value: CompletionItemKind.Value,
variable: CompletionItemKind.Variable
if (this.usedNamespaces[ns] === element.schema.targetNamespace) {
foundElements.push({ namespace: ns, elements: ownelements, ciKind: CompletionItemKind.Property });
break;
}
}
foundElements = foundElements.concat(derivedelements);
let ret: CompletionItem[] = [];
for (let item of foundElements) {
for (const entry of item.elements)
try {
const citem = CompletionItem.create(entry.$.name);
const nsprefix = item.namespace.length > 0 ? item.namespace + ":" : "";
citem.insertText = "<" + nsprefix + entry.$.name + ">$0";
citem.insertTextFormat = 2;
citem.kind = item.ciKind || CompletionItemKind.Class;
if (item.namespace.length > 0)
citem.detail = "Namespace: " + item.namespace;
try {
citem.documentation = this.markdownText(entry.annotation[0].documentation[0]);
} catch (error) {
}
ret.push(citem);
} catch (error) {
this.connection.console.error("Item error: " + error.toString());
}
}
return ret;
}
}
export function getStubScriptCompletionItem(scriptName: string, program: Program): CompletionItem {
return {
label: scriptName,
kind: CompletionItemKind.Class,
data: {
isScriptStub: true,
scriptName,
projectFile: program.project.filePath,
},
sortText: `α${scriptName}`,
};
}
import {
CompletionItem,
CompletionItemKind
} from 'vscode-languageserver';
type UsableIn = 'BlockPath' | 'MustachePath' | 'SubExpressionPath';
const HelperItem = CompletionItemKind.Function;
const ComponentItem = CompletionItemKind.Class;
class EmberCompletionItem implements CompletionItem {
public detail: string;
constructor(
readonly label: string,
readonly kind: CompletionItemKind,
readonly usableIn: UsableIn[],
readonly version?: string
) {
this.detail = 'Ember';
if (version) {
this.detail = `Ember ${this.version}`;
}
export function GetCompletionKeywords(): CompletionItem[] {
const completionItems = [];
const keywords = [ 'modifier', 'mapping', 'break', 'continue', 'delete', 'else', 'for',
'if', 'new', 'return', 'returns', 'while', 'using',
'private', 'public', 'external', 'internal', 'payable', 'view', 'pure', 'case', 'do', 'else', 'finally',
'in', 'instanceof', 'return', 'throw', 'try', 'typeof', 'yield', 'void'] ;
keywords.forEach(unit => {
const completionItem = CompletionItem.create(unit);
completionItem.kind = CompletionItemKind.Keyword;
completionItems.push(completionItem);
});
completionItems.push(CreateCompletionItem('contract', CompletionItemKind.Class, null));
completionItems.push(CreateCompletionItem('library', CompletionItemKind.Class, null));
completionItems.push(CreateCompletionItem('storage', CompletionItemKind.Field, null));
completionItems.push(CreateCompletionItem('memory', CompletionItemKind.Field, null));
completionItems.push(CreateCompletionItem('var', CompletionItemKind.Field, null));
completionItems.push(CreateCompletionItem('constant', CompletionItemKind.Constant, null));
completionItems.push(CreateCompletionItem('constructor', CompletionItemKind.Constructor, null));
completionItems.push(CreateCompletionItem('event', CompletionItemKind.Event, null));
completionItems.push(CreateCompletionItem('import', CompletionItemKind.Module, null));
completionItems.push(CreateCompletionItem('enum', CompletionItemKind.Enum, null));
completionItems.push(CreateCompletionItem('struct', CompletionItemKind.Struct, null));
completionItems.push(CreateCompletionItem('function', CompletionItemKind.Function, null));
return completionItems;
}
const allMlXqyNamespaces: CompletionItem[] = Object.keys(xqyHints).map((ns) => {
const ci: CompletionItem = {
label: ns,
kind: CompletionItemKind.Class,
data: ns + '.namespace'
}
return ci
})
var fileNode = this.workspaceTree[i];
for (var j = 0, sl = fileNode.classes.length; j < sl; j++) {
var classNode = fileNode.classes[j];
if (classNode.namespace == namespaceToSearch) {
suggestions.push({ label: classNode.name, kind: CompletionItemKind.Class, detail: "(class)" });
}
}
for (var j = 0, sl = fileNode.traits.length; j < sl; j++) {
var traitNode = fileNode.traits[j];
if (traitNode.namespace == namespaceToSearch) {
suggestions.push({ label: traitNode.name, kind: CompletionItemKind.Class, detail: "(trait)" });
}
}
for (var j = 0, sl = fileNode.interfaces.length; j < sl; j++) {
var interfaceNode = fileNode.interfaces[j];
if (interfaceNode.namespace == namespaceToSearch) {
suggestions.push({ label: interfaceNode.name, kind: CompletionItemKind.Interface, detail: "(interface)" });
}
}
}
}
return suggestions;
}
(item: IBracketHandler) => {
return {
label: item.handler.label,
kind: CompletionItemKind.Class,
data: { triggerCharacter: '<' },
};
}
);