Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private tryFindDecoration(
symbol: SemanticSymbol
): TextEditorDecorationType|undefined {
const get = (name: string) => {
if (!this.semanticEnabled.get(name))
return undefined;
const decorations = unwrap(this.semanticDecorations.get(name), "semantic");
return decorations[symbol.id % decorations.length];
};
switch (symbol.kind) {
// Functions
case SymbolKind.Method:
case SymbolKind.Constructor:
return get('memberFunction');
case SymbolKind.Function:
return get('function');
case CclsSymbolKind.StaticMethod:
return get('staticMemberFunction');
// Types
case SymbolKind.Namespace:
return get('namespace');
case SymbolKind.Class:
case SymbolKind.Struct:
case SymbolKind.Enum:
case SymbolKind.TypeParameter:
return get('type');
case CclsSymbolKind.TypeAlias:
private asDocumentSymbol(node: TestNode, uri: string): SymbolInformation {
return SymbolInformation.create(
node.name.replace(/.*\\/g, ''),
node.class === node.name ? SymbolKind.Class : SymbolKind.Method,
node.range,
uri
);
}
}
break;
case SymbolKind.TypeParameter:
options.class = 'ccls--type-parameter';
break;
case SymbolKind.Function:
options.class = 'ccls--free-function';
break;
case SymbolKind.Method:
options.class = 'ccls--member-function';
break;
case CustomSymbolKind.StaticMethod:
options.class = 'ccls--static-member-function';
break;
case SymbolKind.Variable:
if (symbol.parentKind == SymbolKind.Function ||
symbol.parentKind == SymbolKind.Method ||
symbol.parentKind == SymbolKind.Constructor) {
options.class = 'ccls--free-variable';
} else {
options.class = 'ccls--global-variable';
}
break;
case SymbolKind.Field:
if (symbol.storage == StorageClass.Static) {
options.class = 'ccls--static-meber-variable';
} else {
options.class = 'ccls--member-variable';
}
break;
case CustomSymbolKind.Parameter:
options.class = 'ccls--parameter';
return items;
}
const OUTLINE_KIND_TO_LSP_KIND = {
array: SymbolKind.Array,
boolean: SymbolKind.Boolean,
class: SymbolKind.Class,
constant: SymbolKind.Constant,
constructor: SymbolKind.Constructor,
enum: SymbolKind.Enum,
field: SymbolKind.Field,
file: SymbolKind.File,
function: SymbolKind.Function,
interface: SymbolKind.Interface,
method: SymbolKind.Method,
module: SymbolKind.Module,
namespace: SymbolKind.Namespace,
number: SymbolKind.Number,
package: SymbolKind.Package,
property: SymbolKind.Property,
string: SymbolKind.String,
variable: SymbolKind.Variable,
};
case 'local var':
case 'const':
return SymbolKind.Variable;
case 'function':
case 'local function':
return SymbolKind.Function;
case 'enum':
return SymbolKind.Enum;
case 'module':
return SymbolKind.Module;
case 'class':
return SymbolKind.Class;
case 'interface':
return SymbolKind.Interface;
case 'method':
return SymbolKind.Method;
case 'property':
case 'getter':
case 'setter':
return SymbolKind.Property;
}
return SymbolKind.Variable;
}
case 'local var':
case 'const':
return SymbolKind.Variable;
case 'function':
case 'local function':
return SymbolKind.Function;
case 'enum':
return SymbolKind.Enum;
case 'module':
return SymbolKind.Module;
case 'class':
return SymbolKind.Class;
case 'interface':
return SymbolKind.Interface;
case 'method':
return SymbolKind.Method;
case 'property':
case 'getter':
case 'setter':
return SymbolKind.Property;
}
return SymbolKind.Variable;
}
case 'enum':
return SymbolKind.Enum
case 'enum member':
return SymbolKind.Constant
case 'var':
return SymbolKind.Variable
case 'local var':
return SymbolKind.Variable
case 'function':
return SymbolKind.Function
case 'local function':
return SymbolKind.Function
case 'method':
return SymbolKind.Method
case 'getter':
return SymbolKind.Method
case 'setter':
return SymbolKind.Method
case 'property':
return SymbolKind.Property
case 'constructor':
return SymbolKind.Constructor
case 'parameter':
return SymbolKind.Variable
case 'type parameter':
return SymbolKind.Variable
case 'alias':
return SymbolKind.Variable
case 'let':
return SymbolKind.Variable
case 'const':
return SymbolKind.Constant
if (node instanceof nodes.Selector) {
entry.name = node.getText();
locationNode = node.findAParent(nodes.NodeType.Ruleset, nodes.NodeType.ExtendsReference);
if (locationNode) {
entry.location = Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return false;
}
else if (node instanceof nodes.VariableDeclaration) {
entry.name = node.getName();
entry.kind = SymbolKind.Variable;
}
else if (node instanceof nodes.MixinDeclaration) {
entry.name = node.getName();
entry.kind = SymbolKind.Method;
}
else if (node instanceof nodes.FunctionDeclaration) {
entry.name = node.getName();
entry.kind = 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 = Location.create(document.uri, getRange(locationNode, document));
result.push(entry);
}
return true;
case 'local var':
case 'const':
return SymbolKind.Variable;
case 'function':
case 'local function':
return SymbolKind.Function;
case 'enum':
return SymbolKind.Enum;
case 'module':
return SymbolKind.Module;
case 'class':
return SymbolKind.Class;
case 'interface':
return SymbolKind.Interface;
case 'method':
return SymbolKind.Method;
case 'property':
case 'getter':
case 'setter':
return SymbolKind.Property;
}
return SymbolKind.Variable;
}