Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var lsptypes = require('vscode-languageserver-types')
var lspproto = require('vscode-languageserver-protocol');
const parser = new tsparser.TypescriptParser();
const lspOutputPath = path.resolve(__dirname, '..', '..', 'lib', 'lsp');
// We can't introspect enums easily so just use a list
// of types to "treat" as enums
const enumList = {
// Enums from the vscode-languageserver-types module
'DiagnosticSeverity': lsptypes.DiagnosticSeverity,
'MarkupKind': lsptypes.MarkupKind,
'CompletionItemKind': lsptypes.CompletionItemKind,
'InsertTextFormat': lsptypes.InsertTextFormat,
'DocumentHighlightKind': lsptypes.DocumentHighlightKind,
'SymbolKind': lsptypes.SymbolKind,
'CodeActionKind': lsptypes.CodeActionKind,
// Enums from the vscode-languageserver-protocol module
'TextDocumentSaveReason': lspproto.TextDocumentSaveReason,
'ResourceOperationKind': lspproto.ResourceOperationKind,
'FailureHandlingKind': lspproto.FailureHandlingKind,
'TextDocumentSyncKind': lspproto.TextDocumentSyncKind,
'MessageType': lspproto.MessageType,
'FileChangeType': lspproto.FileChangeType,
'CompletionTriggerKind': lspproto.CompletionTriggerKind
}
// Some property names are reserved names in ruby, so mutate them
const propertyNameMunging = ['method'];
function GenerateRubyFromInterfaceProperties(iface) {
var rubyText = '';
export const convertTypeScriptKindToSymbolKind = (kind: string): types.SymbolKind => {
switch (kind) {
case "var":
case "let":
return types.SymbolKind.Variable
case "property":
case "getter":
return types.SymbolKind.Property
case "const":
return types.SymbolKind.Constant
case "method":
return types.SymbolKind.Method
case "interface":
return types.SymbolKind.Interface
case "type":
return types.SymbolKind.Constructor
case "class":
return types.SymbolKind.Class
case "module":
return types.SymbolKind.Module
case "alias":
return types.SymbolKind.Variable
case "function":
return types.SymbolKind.Function
case "enum member":
return types.SymbolKind.Enum
default:
return types.SymbolKind.Field
}
}
switch (symbolKind) {
case types.SymbolKind.Class:
return "cube"
case types.SymbolKind.Constructor:
return "building"
case types.SymbolKind.Enum:
return "sitemap"
case types.SymbolKind.Field:
return "var"
case types.SymbolKind.File:
return "file"
case types.SymbolKind.Function:
return "cog"
case types.SymbolKind.Interface:
return "plug"
case types.SymbolKind.Method:
return "flash"
case types.SymbolKind.Module:
return "cubes"
case types.SymbolKind.Property:
return "wrench"
case types.SymbolKind.Variable:
return "code"
default:
return "question"
}
}
export function intoCode(kind: Kind): types.SymbolKind {
switch (kind) {
case "Class": return types.SymbolKind.Class;
case "Constructor": return types.SymbolKind.Constructor;
case "Exn": return types.SymbolKind.Constructor;
case "Label": return types.SymbolKind.Field;
case "Method": return types.SymbolKind.Method;
case "Modtype": return types.SymbolKind.Interface;
case "Module": return types.SymbolKind.Module;
case "Signature": return types.SymbolKind.Interface;
case "Type": return types.SymbolKind.Class;
case "Value": return types.SymbolKind.Variable;
default: throw new Error(`: ${kind}`);
}
}
}
stylesheet.accept(function (node) {
var entry = {
name: null,
kind: vscode_languageserver_types_1.SymbolKind.Class,
location: null
};
var locationNode = node;
if (node instanceof nodes.Selector) {
entry.name = node.getText();
locationNode = node.findAParent(nodes.NodeType.Ruleset, nodes.NodeType.ExtendsReference);
if (locationNode) {
entry.location = vscode_languageserver_types_1.Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return false;
}
else if (node instanceof nodes.VariableDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Variable;
}
kind: vscode_languageserver_types_1.SymbolKind.Class,
location: null
};
var locationNode = node;
if (node instanceof nodes.Selector) {
entry.name = node.getText();
locationNode = node.findAParent(nodes.NodeType.Ruleset, nodes.NodeType.ExtendsReference);
if (locationNode) {
entry.location = vscode_languageserver_types_1.Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return false;
}
else if (node instanceof nodes.VariableDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Variable;
}
else if (node instanceof nodes.MixinDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Method;
}
else if (node instanceof nodes.FunctionDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Function;
}
else if (node instanceof nodes.Keyframe) {
entry.name = localize('literal.keyframes', "@keyframes {0}", node.getName());
}
else if (node instanceof nodes.FontFace) {
entry.name = localize('literal.fontface', "@font-face");
}
if (entry.name) {
private _convertSymbolKindToIconName(symbolKind: types.SymbolKind): string {
switch (symbolKind) {
case types.SymbolKind.Class:
return "cube"
case types.SymbolKind.Constructor:
return "building"
case types.SymbolKind.Enum:
return "sitemap"
case types.SymbolKind.Field:
return "var"
case types.SymbolKind.File:
return "file"
case types.SymbolKind.Function:
return "cog"
case types.SymbolKind.Interface:
return "plug"
case types.SymbolKind.Method:
return "flash"
case types.SymbolKind.Module:
export function intoCode(kind: Kind): types.SymbolKind {
switch (kind) {
case "Class": return types.SymbolKind.Class;
case "Constructor": return types.SymbolKind.Constructor;
case "Exn": return types.SymbolKind.Constructor;
case "Label": return types.SymbolKind.Field;
case "Method": return types.SymbolKind.Method;
case "Modtype": return types.SymbolKind.Interface;
case "Module": return types.SymbolKind.Module;
case "Signature": return types.SymbolKind.Interface;
case "Type": return types.SymbolKind.Class;
case "Value": return types.SymbolKind.Variable;
default: throw new Error(`: ${kind}`);
}
}
}
var locationNode = node;
if (node instanceof nodes.Selector) {
entry.name = node.getText();
locationNode = node.findParent(nodes.NodeType.Ruleset);
}
else if (node instanceof nodes.VariableDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Variable;
}
else if (node instanceof nodes.MixinDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Method;
}
else if (node instanceof nodes.FunctionDeclaration) {
entry.name = node.getName();
entry.kind = vscode_languageserver_types_1.SymbolKind.Function;
}
else if (node instanceof nodes.Keyframe) {
entry.name = localize('literal.keyframes', "@keyframes {0}", node.getName());
}
else if (node instanceof nodes.FontFace) {
entry.name = localize('literal.fontface', "@font-face");
}
if (entry.name) {
entry.location = vscode_languageserver_types_1.Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return true;
});
return result;
JSONDocumentSymbols.prototype.getSymbolKind = function (nodeType) {
switch (nodeType) {
case 'object':
return vscode_languageserver_types_1.SymbolKind.Module;
case 'string':
return vscode_languageserver_types_1.SymbolKind.String;
case 'number':
return vscode_languageserver_types_1.SymbolKind.Number;
case 'array':
return vscode_languageserver_types_1.SymbolKind.Array;
case 'boolean':
return vscode_languageserver_types_1.SymbolKind.Boolean;
default:
return vscode_languageserver_types_1.SymbolKind.Variable;
}
};
JSONDocumentSymbols.prototype.findDocumentColors = function (document, doc) {