type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
InterfaceDeclaration
interface TravelResult<LINE> { mapByGroup: { [groupVal: string]: LINE }; outList: LINE[]; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
TypeAliasDeclaration
type AggregateMethodLoose = AggregateMethodInternal | 'sum' | 'count' | 'first' | 'average' | 'Q1' | 'Q2' | 'Q3' | 'median' | 'min' | 'max';
100pah/echarts-experimental
src/aggregate.ts
TypeScript
TypeAliasDeclaration
type AggregateMethodInternal = keyof typeof METHOD_INTERNAL;
100pah/echarts-experimental
src/aggregate.ts
TypeScript
TypeAliasDeclaration
type CreateInTravel<LINE> = ( upstream: ExternalSource, dataIndex: number, dimInfoList: ResultDimInfoInternal[], groupByDimInfo?: ExternalDimensionDefinition, groupByVal?: OptionDataValue ) => LINE;
100pah/echarts-experimental
src/aggregate.ts
TypeScript
TypeAliasDeclaration
type UpdateInTravel<LINE> = ( upstream: ExternalSource, dataIndex: number, targetLine: LINE, dimInfoList: ResultDimInfoInternal[], groupByDimInfo?: ExternalDimensionDefinition, groupByVal?: OptionDataValue ) => void;
100pah/echarts-experimental
src/aggregate.ts
TypeScript
TypeAliasDeclaration
type CollectionResultLine = number[];
100pah/echarts-experimental
src/aggregate.ts
TypeScript
TypeAliasDeclaration
type FinalResultLine = OptionDataValue[];
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
addCollectionInfo(item: ResultDimInfoInternal['collectionInfoList'][number]) { this._collectionInfoMap[item.method] = this.collectionInfoList.length; this.collectionInfoList.push(item); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
getCollectionInfo(method: AggregateMethodInternal) { return this.collectionInfoList[this._collectionInfoMap[method]]; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
// FIXME: temp implementation. Need refactor. gatherValue(groupByDimInfo: ExternalDimensionDefinition, groupVal: OptionDataValue, value: OptionDataValue) { // FIXME: convert to number compulsorily temporarily. value = +value; if (groupByDimInfo) { if (groupVal != null) { const groupValStr = groupVal + ''; const values = this.gatheredValuesByGroup[groupValStr] || (this.gatheredValuesByGroup[groupValStr] = []); values.push(value); } } else { this.gatheredValuesNoGroup.push(value); } }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'SUM'(upstream, dataIndex, dimInfo) { return upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'COUNT'() { return 1; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'FIRST'(upstream, dataIndex, dimInfo) { return upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'MIN'(upstream, dataIndex, dimInfo) { return upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'MAX'(upstream, dataIndex, dimInfo) { return upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'AVERAGE'(upstream, dataIndex, dimInfo, groupByDimInfo, groupByVal) { // FIXME: refactor, bad implementation. const collectLine = groupByDimInfo ? dimInfo.__collectionResult.mapByGroup[groupByVal + ''] : dimInfo.__collectionResult.outList[0]; return (upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream) as number) / collectLine[dimInfo.getCollectionInfo('COUNT').indexInLine]; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
// FIXME: refactor 'Q1'(upstream, dataIndex, dimInfo, groupByDimInfo, groupByVal) { return lineCreatorForQ(0.25, dimInfo, groupByDimInfo, groupByVal); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'Q2'(upstream, dataIndex, dimInfo, groupByDimInfo, groupByVal) { return lineCreatorForQ(0.5, dimInfo, groupByDimInfo, groupByVal); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'Q3'(upstream, dataIndex, dimInfo, groupByDimInfo, groupByVal) { return lineCreatorForQ(0.75, dimInfo, groupByDimInfo, groupByVal); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'SUM'(val, upstream, dataIndex, dimInfo) { // FIXME: handle other types return (val as number) + (upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream) as number); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'COUNT'(val) { return (val as number) + 1; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'FIRST'(val) { return val; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'MIN'(val, upstream, dataIndex, dimInfo) { return Math.min(val as number, upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream) as number); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'MAX'(val, upstream, dataIndex, dimInfo) { return Math.max(val as number, upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream) as number); }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'AVERAGE'(val, upstream, dataIndex, dimInfo, groupByDimInfo, groupByVal) { // FIXME: refactor, bad implementation. const collectLine = groupByDimInfo ? dimInfo.__collectionResult.mapByGroup[groupByVal + ''] : dimInfo.__collectionResult.outList[0]; return (val as number) + (upstream.retrieveValue(dataIndex, dimInfo.indexInUpstream) as number) / collectLine[dimInfo.getCollectionInfo('COUNT').indexInLine]; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'Q1'(val, upstream, dataIndex, dimInfo) { return val; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'Q2'(val, upstream, dataIndex, dimInfo) { return val; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
MethodDeclaration
'Q3'(val, upstream, dataIndex, dimInfo) { return val; }
100pah/echarts-experimental
src/aggregate.ts
TypeScript
InterfaceDeclaration
/** * Interface to handle a forEach loop in dictionaries */ export interface IForEachInterface<K, V> { /** * Callback function */ (callback: { key: K; value: V }): void; }
rabanti-github/yaca
src/interfaces/IForEachInterfaceDictionary.ts
TypeScript
ArrowFunction
status => { this.alreadyOnWaitList = !!status; }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
ArrowFunction
() => { this.disableAddCard = true; }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
ArrowFunction
status => { this.isFetching = status; }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
ArrowFunction
() => { this.ready = true; this.disableAddCard = this.bitpayCardItems && this.bitpayCardItems.find(c => c.provider === 'galileo'); }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
ArrowFunction
c => c.provider === 'galileo'
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
ArrowFunction
() => { this.iabCardProvider.sendMessage( { message }, () => {} ); }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
ClassDeclaration
@Component({ selector: 'bitpay-card-home', templateUrl: 'bitpay-card-home.html', animations: [ trigger('fadeUp', [ transition(':enter', [ style({ transform: 'translateY(5px)', opacity: 0 }), animate('300ms') ]) ]), trigger('fade', [ transition(':enter', [ style({ opacity: 0 }), animate('300ms') ]) ]), trigger('tileSlideIn', [ transition(':enter', [ style({ transform: 'translateX(10px)', opacity: 0 }), animate('300ms ease') ]) ]) ] }) export class BitPayCardHome implements OnInit { public appName: string; public disableAddCard = true; public isFetching: boolean; public ready: boolean; public alreadyOnWaitList: boolean; @Input() showBitpayCardGetStarted: boolean; @Input() bitpayCardItems: any; @Input() cardExperimentEnabled: boolean; @Input() waitList: boolean; @Input() hasCards: boolean; @Input() network: Network; @Input() initialized: boolean; constructor( private appProvider: AppProvider, private navCtrl: NavController, private iabCardProvider: IABCardProvider, private persistenceProvider: PersistenceProvider, private events: Events ) { this.persistenceProvider.getWaitingListStatus().then(status => { this.alreadyOnWaitList = !!status; }); this.events.subscribe('reachedCardLimit', () => { this.disableAddCard = true; }); this.events.subscribe('isFetchingDebitCards', status => { this.isFetching = status; }); } ngOnInit() { this.appName = this.appProvider.info.userVisibleName; setTimeout(() => { this.ready = true; this.disableAddCard = this.bitpayCardItems && this.bitpayCardItems.find(c => c.provider === 'galileo'); }, 200); } public goToBitPayCardIntroPage() { this.navCtrl.push(this.waitList ? PhaseOneCardIntro : BitPayCardIntroPage); } public trackBy(index) { return index; } public async goToCard(cardId) { const token = await this.persistenceProvider.getBitPayIdPairingToken( this.network ); const email = this.bitpayCardItems[0].email; const message = !token ? `loadDashboard?${cardId}&${email}` : `loadDashboard?${cardId}`; this.iabCardProvider.show(); setTimeout(() => { this.iabCardProvider.sendMessage( { message }, () => {} ); }); } }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
MethodDeclaration
ngOnInit() { this.appName = this.appProvider.info.userVisibleName; setTimeout(() => { this.ready = true; this.disableAddCard = this.bitpayCardItems && this.bitpayCardItems.find(c => c.provider === 'galileo'); }, 200); }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
MethodDeclaration
public goToBitPayCardIntroPage() { this.navCtrl.push(this.waitList ? PhaseOneCardIntro : BitPayCardIntroPage); }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
MethodDeclaration
public trackBy(index) { return index; }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
MethodDeclaration
public async goToCard(cardId) { const token = await this.persistenceProvider.getBitPayIdPairingToken( this.network ); const email = this.bitpayCardItems[0].email; const message = !token ? `loadDashboard?${cardId}&${email}` : `loadDashboard?${cardId}`; this.iabCardProvider.show(); setTimeout(() => { this.iabCardProvider.sendMessage( { message }, () => {} ); }); }
BulletProofLUV-LANE/copay
src/pages/integrations/bitpay-card/bitpay-card-home/bitpay-card-home.ts
TypeScript
FunctionDeclaration
export function GetCodeActions(asmodule : scriptfiles.ASModule, range : Range, diagnostics : Array<Diagnostic>) : Array<CodeAction> { let context = new CodeActionContext(); context.module = asmodule; context.actions = new Array<CodeAction>(); context.range_start = asmodule.getOffset(Position.create(range.start.line, 0)); context.range_end = asmodule.getOffset(Position.create(range.end.line, 10000)); context.scope = asmodule.getScopeAt(context.range_start); context.statement = asmodule.getStatementAt(context.range_start); context.diagnostics = diagnostics; // Actions for adding missing imports AddImportActions(context); // Actions for autos AddAutoActions(context); // Actions for members AddMemberActions(context); // Actions for generating delegate bind functions AddGenerateDelegateFunctionActions(context); // Actions for method override snippets AddMethodOverrideSnippets(context); // Actions for adding casts AddCastHelpers(context); // Actions for adding super calls AddSuperCallHelper(context); // Actions for promoting to member variables AddVariablePromotionHelper(context); // Actions for switch blocks AddSwitchCaseActions(context); return context.actions; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
export function ResolveCodeAction(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) : CodeAction { if (data.type == "import") ResolveImportAction(asmodule, action, data); else if (data.type == "delegateBind") ResolveGenerateDelegateFunctionAction(asmodule, action, data); else if (data.type == "methodOverride") ResolveMethodOverrideSnippet(asmodule, action, data); else if (data.type == "addCast") ResolveCastHelper(asmodule, action, data); else if (data.type == "superCall") ResolveSuperCallHelper(asmodule, action, data); else if (data.type == "materializeAuto") ResolveAutoAction(asmodule, action, data); else if (data.type == "variablePromotion") ResolveVariablePromotionHelper(asmodule, action, data); else if (data.type == "insertMacro") ResolveInsertMacro(asmodule, action, data); else if (data.type == "insertCases") ResolveInsertCases(asmodule, action, data); return action; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddImportActions(context : CodeActionContext) { for (let symbol of context.module.symbols) { if (!symbol.isUnimported) continue; if (!symbol.overlapsRange(context.range_start, context.range_end)) continue; let appliedTo = new Array<Diagnostic>(); for (let diag of context.diagnostics) { if (diag.data) { let data = diag.data as any; if (data.type && data.type == "import") { if (data.symbol[0] == symbol.type && data.symbol[1] == symbol.container_type && data.symbol[2] == symbol.symbol_name) { appliedTo.push(diag); } } } } let symbolDisplayName = symbol.symbol_name; if (symbolDisplayName.startsWith("__")) symbolDisplayName = symbolDisplayName.substr(2); context.actions.push(<CodeAction> { kind: CodeActionKind.QuickFix, title: "Import "+symbolDisplayName, source: "angelscript", diagnostics: appliedTo, isPreferred: true, data: { uri: context.module.uri, type: "import", symbol: symbol, } }); } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveImportAction(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let definitions = scriptsymbols.GetSymbolDefinition(asmodule, data.symbol); if (!definitions || definitions.length == 0) return action; let moduleName = definitions[0].module.modulename; if (asmodule.isModuleImported(moduleName)) return action; // Find the first line to insert on let lastImportLine = 0; // Find if the module is already imported, or the position to append the new import let lineCount = asmodule.textDocument.lineCount; let hasEmptyLine = false; let alreadyImported = false; let importRegex = /\s*import\s+([A-Za-z0-9_]+(\.[A-Za-z0-9_]+)*);/; for(let i = 0; i < lineCount; ++i) { let line = asmodule.textDocument.getText( Range.create(Position.create(i, 0), Position.create(i, 10000)) ); let match = importRegex.exec(line); if (match) { if (match[1] == moduleName) { alreadyImported = true; break; } lastImportLine = i + 1; hasEmptyLine = false; } else if (line.trim().length != 0) { // Break if we find a line that's not empty, signalling the end of the import-block break; } else { hasEmptyLine = true; } } action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; if (alreadyImported) return; let insertString = "import "+moduleName+";\n"; if (!hasEmptyLine) insertString += "\n"; action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(Position.create(lastImportLine, 0), insertString) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddGenerateDelegateFunctionActions(context : CodeActionContext) { for (let diag of context.diagnostics) { let data = diag.data as any; if (data && data.type == "delegateBind") { context.actions.push(<CodeAction> { kind: CodeActionKind.QuickFix, title: "Generate Method: "+data.name+"()", source: "angelscript", diagnostics: [diag], isPreferred: true, data: { uri: context.module.uri, type: "delegateBind", delegate: data.delegate, name: data.name, position: diag.range.start, } }); } } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveGenerateDelegateFunctionAction(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let delegateType = typedb.GetType(data.delegate); if (!delegateType) return; let [insertPosition, indent, prefix, suffix] = FindInsertPositionForGeneratedMethod(asmodule, data.position); let snippet = prefix; snippet += indent+"UFUNCTION()\n"; snippet += GenerateMethodHeaderString("private ", indent, data.name, delegateType.delegateReturn, delegateType.delegateArgs); snippet += "\n"; snippet += indent+"{\n"; snippet += indent+"}\n"; snippet += suffix; action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(insertPosition, snippet) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function GenerateMethodHeaderString(prefix : string, indent : string, name : string, returnType : string, args : Array<typedb.DBArg>) : string { let snippet = indent+prefix; let preambleLength = name.length + 2 + prefix.length; if (returnType) { snippet += returnType; preambleLength += returnType.length; } else { snippet += "void"; preambleLength += 4; } snippet += " "; snippet += name; snippet += "("; let lineLength = preambleLength + indent.length; if (args) { for (let i = 0; i < args.length; ++i) { let arg = args[i]; let argLength = arg.typename.length; if (arg.name) argLength += arg.name.length + 1; if (lineLength + argLength > 100) { if (i != 0) { snippet += ","; lineLength += 1; } snippet += "\n"+indent+" ".repeat(preambleLength); lineLength = indent.length + preambleLength; } else if (i != 0) { snippet += ", "; lineLength += 2; } snippet += arg.typename; if (arg.name) { snippet += " "; snippet += arg.name; } lineLength += argLength; } } snippet += ")"; return snippet; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function FindInsertPositionForGeneratedMethod(asmodule : scriptfiles.ASModule, afterPosition : Position) : [Position, string, string, string] { let offset = asmodule.getOffset(afterPosition); let curScope = asmodule.getScopeAt(offset); let classScope = curScope.getParentTypeScope(); let indent : string = null; let prefix : string = ""; let suffix : string = ""; // Just insert right here if (!classScope) return [Position.create(afterPosition.line, 0), "\t", prefix, suffix]; // Find the first line in the class that has content, and base indentation on that for (let statement of classScope.statements) { let lines = statement.content.split("\n"); for (let line of lines) { if (!/^[ \t\r\n]*$/.test(line)) { indent = ""; for (let i = 0; i < line.length; ++i) { let curchar = line[i]; if (curchar == ' ' || curchar == '\t') { indent += curchar; } else if (curchar == '\n' || curchar == '\r') { continue; } else if (curchar == '#') { indent = null; break; } else { break; } } break; } } if (indent) break; } if (!indent) indent = "\t"; // Find the first scope in our parent that starts after the position, and insert before it let classStartPos = asmodule.getPosition(classScope.start_offset); for (let subscope of classScope.scopes) { let startOffset = subscope.start_offset; while (startOffset < subscope.end_offset) { let curchar = asmodule.content[startOffset]; if (curchar == ' ' || curchar == '\t' || curchar == '\r' || curchar == '\n') ++startOffset; else break; } let scopeStartPos = asmodule.getPosition(startOffset); let checkStartPos = scopeStartPos; if (subscope.element_head instanceof scriptfiles.ASStatement) checkStartPos = asmodule.getPosition(subscope.element_head.start_offset); else if (!subscope.element_head) checkStartPos = asmodule.getPosition(subscope.end_offset); if (checkStartPos.line >= afterPosition.line) { prefix += "\n"; return [Position.create(scopeStartPos.line-1, 10000), indent, prefix, suffix]; } } let endOfClass = asmodule.getPosition(classScope.end_offset); if (!asmodule.isLineEmpty(endOfClass.line-1)) prefix += "\n"; return [endOfClass, indent, prefix, suffix]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddMethodOverrideSnippets(context : CodeActionContext) { if (!context.scope) return; let typeOfScope = context.scope.getParentType(); if (!typeOfScope || !typeOfScope.supertype) return; let validScope = false; if (context.scope.scopetype == scriptfiles.ASScopeType.Class) { validScope = true; } // If we're inside the actual function declaration that's fine too else if (context.scope.scopetype == scriptfiles.ASScopeType.Function) { if (context.statement && context.statement.ast && context.statement.ast.type == scriptfiles.node_types.FunctionDecl) { validScope = true; } } if (!validScope) return; let foundOverrides = new Set<string>(); for (let checktype of typeOfScope.getInheritanceTypes()) { for (let method of checktype.methods) { if (checktype.isUnrealType() && !method.isEvent) continue; if (foundOverrides.has(method.name)) continue; // Ignore methods we've already overridden let existingSymbol = typeOfScope.findFirstSymbol(method.name, typedb.DBAllowSymbol.FunctionOnly); if (!existingSymbol || !existingSymbol.containingType) continue; if (existingSymbol.containingType == typeOfScope) continue; // Ignore private methods if (method.isPrivate) continue; foundOverrides.add(method.name); if (method.isFinal) continue; context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorRewrite, title: "Override: "+method.name+"()", source: "angelscript", data: { uri: context.module.uri, type: "methodOverride", inside: method.containingType.typename, name: method.name, position: context.module.getPosition(context.range_start), } }); } } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveMethodOverrideSnippet(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let insideType = typedb.GetType(data.inside); if (!insideType) return; let method = insideType.getMethod(data.name); if (!method) return; let offset = asmodule.getOffset(data.position); let scope = asmodule.getScopeAt(offset); let scopeType = scope ? scope.getParentType() : null; let [insertPosition, indent, prefix, suffix] = FindInsertPositionForGeneratedMethod(asmodule, data.position); let snippet = ""; snippet += prefix; if (method.isEvent) snippet += indent+"UFUNCTION(BlueprintOverride)\n"; snippet += GenerateMethodHeaderString("", indent, data.name, method.returnType, method.args); if (method.isConst) snippet += " const" if (!method.isEvent) snippet += " override"; if (!method.isEvent && method.isProperty && method.declaredModule) snippet += " property"; snippet += "\n"; snippet += indent+"{\n"; if (scopeType) { let parentType = typedb.GetType(scopeType.supertype); if (parentType) { let parentMethod = parentType.findFirstSymbol(method.name, typedb.DBAllowSymbol.FunctionOnly); if (parentMethod instanceof typedb.DBMethod && parentMethod.declaredModule && !parentMethod.isEmpty) { if (!method.returnType || method.returnType == "void") { snippet += indent+indent+"Super::"+method.name+"("; for (let i = 0; i < method.args.length; ++i) { if (i != 0) snippet += ", "; snippet += method.args[i].name; } snippet += ");\n"; } } } } snippet += indent+"}\n"; snippet += suffix; action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(insertPosition, snippet) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function GetTypeFromExpressionIgnoreNullptr(scope : scriptfiles.ASScope, node : any) : typedb.DBType { if (node && node.type == scriptfiles.node_types.ConstNullptr) return null; return scriptfiles.ResolveTypeFromExpression(scope, node); }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddCastHelpers(context : CodeActionContext) { if (!context.scope) return; if (!context.statement) return; if (!context.statement.ast) return; let statement = context.statement; let scope = context.scope; let leftType : typedb.DBType = null; let rightType : typedb.DBType = null; if (statement.ast.type == scriptfiles.node_types.Assignment) { let leftNode = statement.ast.children[0]; let rightNode = statement.ast.children[1]; if (!leftNode || !rightNode) return; leftType = scriptfiles.ResolveTypeFromExpression(scope, leftNode); rightType = GetTypeFromExpressionIgnoreNullptr(scope, rightNode); } else if (statement.ast.type == scriptfiles.node_types.VariableDecl) { if (statement.ast.typename) leftType = typedb.GetType(statement.ast.typename.value); if (statement.ast.expression) rightType = GetTypeFromExpressionIgnoreNullptr(scope, statement.ast.expression); } else if (statement.ast.type == scriptfiles.node_types.ReturnStatement) { let dbFunc = scope.getDatabaseFunction(); if (dbFunc && dbFunc.returnType) leftType = typedb.GetType(dbFunc.returnType); if (statement.ast.children && statement.ast.children[0]) rightType = GetTypeFromExpressionIgnoreNullptr(scope, statement.ast.children[0]); } if (!leftType || !rightType) return; // Don't care about primitives if (leftType.isPrimitive || rightType.isPrimitive) return; // Don't care about structs if (leftType.isStruct || rightType.isStruct) return; // Maybe we can implicitly convert if (rightType.inheritsFrom(leftType.typename)) return; // Cast needs to make sense if (!leftType.inheritsFrom(rightType.typename)) return; context.actions.push(<CodeAction> { kind: CodeActionKind.QuickFix, title: "Cast to "+leftType.typename, source: "angelscript", data: { uri: context.module.uri, type: "addCast", castTo: leftType.typename, position: context.module.getPosition(context.range_start), } }); }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveCastHelper(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let offset = asmodule.getOffset(data.position); let scope = asmodule.getScopeAt(offset); if (!scope) return; let statement = asmodule.getStatementAt(offset); if (!statement) return; if (!statement.ast) return; let rightNode : any = null; if (statement.ast.type == scriptfiles.node_types.Assignment) { rightNode = statement.ast.children[1]; } else if (statement.ast.type == scriptfiles.node_types.VariableDecl) { rightNode = statement.ast.expression; } else if (statement.ast.type == scriptfiles.node_types.ReturnStatement) { if (statement.ast.children && statement.ast.children[0]) rightNode = statement.ast.children[0] } if (!rightNode) return; action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; action.edit.changes[asmodule.displayUri] = [ TextEdit.insert( asmodule.getPosition(statement.start_offset + rightNode.start), "Cast<"+data.castTo+">("), TextEdit.insert( asmodule.getPosition(statement.start_offset + rightNode.end), ")"), ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddSuperCallHelper(context : CodeActionContext) { for (let diag of context.diagnostics) { let data = diag.data as any; if (data && data.type == "superCall") { context.actions.push(<CodeAction> { kind: CodeActionKind.QuickFix, title: "Add call to Super::"+data.name+"(...)", source: "angelscript", diagnostics: [diag], isPreferred: true, data: { uri: context.module.uri, type: "superCall", name: data.name, inType: data.inType, position: context.module.getPosition(context.range_end), } }); } } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveSuperCallHelper(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let offset = asmodule.getOffset(data.position); let scope = asmodule.getScopeAt(offset) if (!scope) return; let scopeFunc = scope.getParentFunction(); if (!scopeFunc) return; let superType = typedb.GetType(data.inType); if (!superType) return; let superMethod = superType.findFirstSymbol(data.name, typedb.DBAllowSymbol.FunctionOnly); if (!superMethod) return; if (!(superMethod instanceof typedb.DBMethod)) return; let [insertPosition, indent, prefix, suffix] = FindInsertPositionFunctionStart(scope); let callString = prefix+indent+"Super::"+superMethod.name+"("; if (scopeFunc.args) { for (let i = 0; i < scopeFunc.args.length; ++i) { if (i != 0) callString += ", "; callString += scopeFunc.args[i].name; } } callString += ");"+suffix; action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(insertPosition, callString) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function FindInsertPositionFunctionStart(scope : scriptfiles.ASScope) : [Position, string, string, string] { let indent : string = null; let prefix : string = ""; let suffix : string = ""; // Find the first line in the class that has content, and base indentation on that let endLine = scope.module.getPosition(scope.end_offset).line; let curLine = scope.module.getPosition(scope.declaration.end_offset).line + 1; while (curLine < endLine) { let lineText = scope.module.getLineText(curLine); if (!/^[\r\n]*$/.test(lineText)) { indent = ""; for (let i = 0; i < lineText.length; ++i) { let curchar = lineText[i]; if (curchar == ' ' || curchar == '\t') { indent += curchar; } else if (curchar == '\n' || curchar == '\r') { continue; } else if (curchar == '#') { indent = null; break; } else { break; } } if (indent != null) break; } } if(indent == null) { // Double the class indent let [subPos, subIndent, subPrefix, subSuffix] = FindInsertPositionForGeneratedMethod( scope.module, scope.module.getPosition(scope.declaration.end_offset)); indent = subIndent + subIndent; } if (indent == null) indent = "\t\t"; let headPos = scope.module.getPosition(scope.declaration.end_offset); prefix += "\n"; return [Position.create(headPos.line, 100000), indent, prefix, suffix]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddAutoActions(context : CodeActionContext) { for (let symbol of context.module.symbols) { if (!symbol.isAuto) continue; if (!symbol.overlapsRange(context.range_start, context.range_end)) continue; let realTypename = symbol.symbol_name; if (realTypename.startsWith("__")) realTypename = realTypename.substr(2); let dbtype = typedb.GetType(realTypename); if (!dbtype) continue; context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: "Change auto to "+dbtype.getDisplayName(), source: "angelscript", isPreferred: true, data: { uri: context.module.uri, type: "materializeAuto", typename: realTypename, symbol: symbol, } }); } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveAutoAction(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let symbol = data.symbol as scriptfiles.ASSymbol; let typename = data.typename; action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; action.edit.changes[asmodule.displayUri] = [ TextEdit.replace( asmodule.getRange(symbol.start, symbol.end), typename, ) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddVariablePromotionHelper(context : CodeActionContext) { if (!context.scope) return; if (!context.statement) return; let codeNode = context.statement.ast; if (!codeNode) return; if (codeNode.type == scriptfiles.node_types.Assignment) { let leftNode = codeNode.children[0]; if (!leftNode || leftNode.type != scriptfiles.node_types.Identifier) return; // If the left side is a known variable we can't provide this action let lvalueType = scriptfiles.ResolveTypeFromExpression(context.scope, leftNode); if (lvalueType) return; // If we don't know what type is on the right we can't provide this action let rvalueType = scriptfiles.ResolveTypeFromExpression(context.scope, codeNode.children[1]); if(!rvalueType) return; let variableName = leftNode.value; context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Promote ${variableName} to member variable`, source: "angelscript", isPreferred: true, data: { uri: context.module.uri, type: "variablePromotion", variableName: variableName, variableType: rvalueType.typename, position: context.range_start, } }); } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function FindInsertPositionForGeneratedMemberVariable(asmodule : scriptfiles.ASModule, classScope : scriptfiles.ASScope, anchor_offset : number = -1) : [Position, string] { let indent : string = null; let prefix : string = ""; let suffix : string = ""; // Find the first line in the class that has content, and base indentation on that for (let statement of classScope.statements) { let lines = statement.content.split("\n"); for (let line of lines) { if (!/^[ \t\r\n]*$/.test(line)) { indent = ""; for (let i = 0; i < line.length; ++i) { let curchar = line[i]; if (curchar == ' ' || curchar == '\t') { indent += curchar; } else if (curchar == '\n' || curchar == '\r') { continue; } else if (curchar == '#') { indent = null; break; } else { break; } } break; } } if (indent) break; } if (!indent) indent = "\t"; // Check if we have a member variable that anchors this one let anchoredVariable : string = null; if (anchor_offset != -1) { let subScope = classScope.getScopeAt(anchor_offset); if (subScope) { for (let statement of subScope.statements) { if (!statement) continue; if (!statement.ast) continue; if (statement.end_offset >= anchor_offset) continue; if (statement.ast.type == scriptfiles.node_types.Assignment) { if (statement.ast.children[0] && statement.ast.children[0].type == scriptfiles.node_types.Identifier) { let varName = statement.ast.children[0].value; if (classScope.variablesByName.has(varName)) anchoredVariable = varName; } } } } } // Collect data about where stuff is in the class let lastDefaultLineOffset = -1; let lastMemberVariableOffset = -1; let anchoredMemberVariableOffset = -1; for (let statement of classScope.statements) { if (!statement.ast) continue; if (statement.ast.type == scriptfiles.node_types.VariableDecl) { if (anchoredVariable && statement.ast.name && statement.ast.name.value == anchoredVariable) anchoredMemberVariableOffset = statement.end_offset; if (statement.end_offset > lastMemberVariableOffset) lastMemberVariableOffset = statement.end_offset; } else if (statement.ast.type == scriptfiles.node_types.DefaultStatement) { if (statement.end_offset > lastDefaultLineOffset) lastDefaultLineOffset = statement.end_offset; } } let afterPos : Position = null; if (anchoredMemberVariableOffset != -1) { // Insert after the member variable that was most recently assigned afterPos = asmodule.getPosition(anchoredMemberVariableOffset); } else if (lastMemberVariableOffset != -1) { // Insert after the last member variable declaration afterPos = asmodule.getPosition(lastMemberVariableOffset); } else if (lastDefaultLineOffset != -1) { // Insert after the last default statement afterPos = asmodule.getPosition(lastDefaultLineOffset); } else { // Insert at the top of the class afterPos = asmodule.getPosition(classScope.declaration.end_offset); } afterPos.line += 1; afterPos.character = 0; return [afterPos, indent]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveVariablePromotionHelper(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let variableName : string = data.variableName; let variableType : string = data.variableType; let position : number = data.position; let scope = asmodule.getScopeAt(position); if (!scope) return; let classScope = scope.getParentTypeScope(); if (!classScope) return; let [insertPosition, indent] = FindInsertPositionForGeneratedMemberVariable(asmodule, classScope, position); action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; let declarationString = `${indent}${variableType} ${variableName};\n`; action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(insertPosition, declarationString) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddMemberActions(context : CodeActionContext) { if (!context.scope) return; if (!context.statement) return; if (!context.statement.ast) return; let dbType = context.scope.getParentType(); if (context.statement.ast.type == scriptfiles.node_types.FunctionDecl && context.statement.ast.name && !context.statement.ast.macro) { if (!dbType || dbType.isNamespaceOrGlobalScope() || !dbType.isStruct) { let isOverrideEvent = false; if (dbType) { let superType = typedb.GetType(dbType.supertype); if (superType) { let superFunc = superType.findFirstSymbol(context.statement.ast.name.value, typedb.DBAllowSymbol.FunctionOnly); if (superFunc && superFunc instanceof typedb.DBMethod) { if (superFunc.isEvent) isOverrideEvent = true; } } } if (isOverrideEvent) { context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add UFUNCTION(BlueprintOverride)`, source: "angelscript", data: { uri: context.module.uri, type: "insertMacro", macro: "UFUNCTION(BlueprintOverride)", position: context.range_start, } }); } else { if (dbType) { let scopeFunc = dbType.getMethod(context.statement.ast.name.value); if (scopeFunc && scopeFunc.isConst && scopeFunc.returnType && scopeFunc.returnType != "void") { context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add UFUNCTION(BlueprintPure)`, source: "angelscript", data: { uri: context.module.uri, type: "insertMacro", macro: "UFUNCTION(BlueprintPure)", position: context.range_start, } }); } } context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add UFUNCTION()`, source: "angelscript", data: { uri: context.module.uri, type: "insertMacro", macro: "UFUNCTION()", position: context.range_start, } }); } } } else if (context.statement.ast.type == scriptfiles.node_types.VariableDecl && context.statement.ast.name && !context.statement.ast.macro) { if (dbType && !dbType.isNamespaceOrGlobalScope() && context.scope.scopetype == scriptfiles.ASScopeType.Class) { let variableName = context.statement.ast.name.value; let varType = typedb.GetType(context.statement.ast.typename.value); if (varType && varType.inheritsFrom("UActorComponent") && !dbType.isStruct && dbType.inheritsFrom("AActor")) { context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add UPROPERTY(DefaultComponent)`, source: "angelscript", data: { uri: context.module.uri, type: "insertMacro", macro: "UPROPERTY(DefaultComponent)", position: context.range_start, } }); } context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add UPROPERTY()`, source: "angelscript", data: { uri: context.module.uri, type: "insertMacro", macro: "UPROPERTY()", position: context.range_start, } }); } } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveInsertMacro(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let position : number = data.position; let macro : string = data.macro; let statement = asmodule.getStatementAt(position); if (!statement) return; if (!statement.ast) return; let scope = asmodule.getScopeAt(position); if (!scope) return; let classScope = scope.getParentTypeScope(); if (!classScope) return; let [_, indent] = FindInsertPositionForGeneratedMemberVariable(asmodule, classScope, position); action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; let macroString = `${indent}${macro}\n`; let insertPosition : Position = null; if (statement.ast.name) { insertPosition = asmodule.getPosition(statement.start_offset + statement.ast.name.start); insertPosition.character = 0; } else { insertPosition = asmodule.getPosition(position); insertPosition.character = 0; } action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(insertPosition, macroString) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function AddSwitchCaseActions(context : CodeActionContext) { if (!context.scope) return; // Ensure that this is a switch scope let switchBlock : scriptfiles.ASScope = null; let switchStatement : scriptfiles.ASStatement = null; if (context.statement && context.statement.ast && context.statement.ast.type == scriptfiles.node_types.SwitchStatement) { if (context.statement.next && context.statement.next instanceof scriptfiles.ASScope) { switchStatement = context.statement; switchBlock = context.statement.next; } } else if (context.scope.previous && context.scope.previous instanceof scriptfiles.ASStatement) { if (context.scope.previous.ast && context.scope.previous.ast.type == scriptfiles.node_types.SwitchStatement) { switchStatement = context.scope.previous; switchBlock = context.scope; } } if (!switchBlock) return; if (!switchBlock.parentscope) return; // Figure out what type we're switching on let switchOnType = scriptfiles.ResolveTypeFromExpression(switchBlock.parentscope, switchStatement.ast.children[0]); if (!switchOnType) return; if (!switchOnType.isEnum) return; // Find all cases that are implemented let implementedCases = new Array<string>(); let defaultStatement : scriptfiles.ASStatement = null; for (let caseStatement of switchBlock.statements) { if (!caseStatement || !caseStatement.ast) continue; if (caseStatement.ast.type == scriptfiles.node_types.DefaultCaseStatement) { defaultStatement = caseStatement; continue; } else if (caseStatement.ast.type != scriptfiles.node_types.CaseStatement) continue; let labelNode = caseStatement.ast.children[0]; if (!labelNode || labelNode.type != scriptfiles.node_types.NamespaceAccess) continue; if (!labelNode.children[0] || !labelNode.children[0].value) continue; if (!labelNode.children[1] || !labelNode.children[1].value) continue; let label = labelNode.children[0].value + "::" + labelNode.children[1].value; implementedCases.push(label); } // Check if there are any missing cases left let missingCases = new Array<string>(); for (let prop of switchOnType.properties) { if (prop.name == "MAX") continue; if (prop.name.endsWith("_MAX")) continue; let label = switchOnType.getDisplayName()+"::"+prop.name; if (!implementedCases.includes(label)) missingCases.push(label); } // Add code action for adding all missing cases if (missingCases.length >= 2) { context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add all missing ${switchOnType.getDisplayName()} cases`, source: "angelscript", data: { uri: context.module.uri, type: "insertCases", cases: missingCases, switchPosition: switchStatement.start_offset, position: context.scope.start_offset, defaultCasePosition: defaultStatement ? defaultStatement.start_offset : -1, } }); } // Add code action for adding individual missing cases for (let label of missingCases) { context.actions.push(<CodeAction> { kind: CodeActionKind.RefactorInline, title: `Add case ${label}`, source: "angelscript", data: { uri: context.module.uri, type: "insertCases", cases: [label], switchPosition: switchStatement.start_offset, position: context.scope.start_offset, defaultCasePosition: defaultStatement ? defaultStatement.start_offset : -1, } }); } }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ResolveInsertCases(asmodule : scriptfiles.ASModule, action : CodeAction, data : any) { let switchStatement = asmodule.getStatementAt(data.switchPosition); if (!switchStatement) return; if (!switchStatement.next) return; if (!(switchStatement.next instanceof scriptfiles.ASScope)) return; let switchScope : scriptfiles.ASScope = switchStatement.next; if (!switchScope) return; action.edit = <WorkspaceEdit> {}; action.edit.changes = {}; let switchIndent = GetIndentForStatement(switchStatement); let indent = GetIndentForBlock(switchScope); if (!indent) indent = ""; let insertString = ""; let cases : Array<string> = data.cases; for (let label of cases) insertString += `${indent}case ${label}:\n${indent}break;\n`; let insertPosition : Position = null; if (data.defaultCasePosition != -1) { insertPosition = asmodule.getPosition(data.defaultCasePosition); insertString = "\n" + insertString.substring(0, insertString.length-1); } else { let lastElement = switchScope.element_head; while (lastElement && lastElement.next) lastElement = lastElement.next; while (lastElement) { if (lastElement instanceof scriptfiles.ASScope) { insertPosition = asmodule.getPosition(lastElement.end_offset); insertPosition.line += 1; insertPosition.character = 0; break; } else if (lastElement instanceof scriptfiles.ASStatement) { if (lastElement && lastElement.ast) { insertPosition = asmodule.getPosition(lastElement.end_offset); insertPosition.line += 1; insertPosition.character = 0; break; } } lastElement = lastElement.previous; } if (!insertPosition) { let scopeStart = asmodule.getPosition(switchScope.start_offset); let scopeEnd = asmodule.getPosition(switchScope.end_offset); if (scopeEnd.line == scopeStart.line) { insertPosition = asmodule.getPosition(switchScope.start_offset); insertString = "\n" + insertString + switchIndent; } else if (scopeEnd.line == scopeStart.line + 1) { insertPosition = asmodule.getPosition(switchScope.start_offset); insertString = "\n" + insertString.trimEnd(); } else { insertPosition = asmodule.getPosition(switchScope.end_offset); insertPosition.line -= 1; insertPosition.character = 10000; insertString = insertString.substring(0, insertString.length-1).trimStart(); } } } action.edit.changes[asmodule.displayUri] = [ TextEdit.insert(insertPosition, insertString) ]; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function GetIndentForStatement(statement : scriptfiles.ASStatement) : string { let indent : string = null; let lines = statement.content.split("\n"); for (let line of lines) { if (!/^[ \t\r\n]*$/.test(line)) { indent = ""; for (let i = 0; i < line.length; ++i) { let curchar = line[i]; if (curchar == ' ' || curchar == '\t') { indent += curchar; } else if (curchar == '\n' || curchar == '\r') { continue; } else if (curchar == '#') { indent = null; break; } else { break; } } break; } } return indent; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function GetIndentForBlock(scope : scriptfiles.ASScope) : string { if (scope.statements.length != 0 && scope.statements[0]) { for (let statement of scope.statements) { if (!statement) continue; let statementIndent = GetIndentForStatement(statement); if (statementIndent != null) return statementIndent; } } else { if (scope.previous && scope.previous instanceof scriptfiles.ASStatement) { let statementIndent = GetIndentForStatement(scope.previous); if (statementIndent != null) { return ExtendIndent(statementIndent); } } } return null; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
function ExtendIndent(indent : string) : string { if (!indent || indent.length == 0) return "\t"; if (indent.includes("\t")) return indent + "\t"; else return indent + " "; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
ClassDeclaration
class CodeActionContext { range_start : number; range_end : number; module : scriptfiles.ASModule; scope : scriptfiles.ASScope; statement : scriptfiles.ASStatement; diagnostics : Array<Diagnostic>; actions : Array<CodeAction>; }
AOOSG/vscode-unreal-angelscript
language-server/src/code_actions.ts
TypeScript
FunctionDeclaration
export function isLocationLink(thing: any): thing is LocationLink { return thing && URI.isUri((thing as LocationLink).uri) && Range.isIRange((thing as LocationLink).range) && (Range.isIRange((thing as LocationLink).originSelectionRange) || Range.isIRange((thing as LocationLink).targetSelectionRange)); }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The hover provider interface defines the contract between extensions and * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface HoverProvider { /** * Provide a hover for the given position and document. Multiple hovers at the same * position will be merged by the editor. A hover can have a range which defaults * to the word range at the position when omitted. */ provideHover(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Hover>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * A completion item represents a text snippet that is * proposed to complete text that is being typed. */ export interface CompletionItem { /** * The label of this completion item. By default * this is also the text that is inserted when selecting * this completion. */ label: string; /** * The kind of this completion item. Based on the kind * an icon is chosen by the editor. */ kind: CompletionItemKind; /** * A human-readable string with additional information * about this item, like type or symbol information. */ detail?: string; /** * A human-readable string that represents a doc-comment. */ documentation?: string | IMarkdownString; /** * A string that should be used when comparing this item * with other items. When `falsy` the [label](#CompletionItem.label) * is used. */ sortText?: string; /** * A string that should be used when filtering a set of * completion items. When `falsy` the [label](#CompletionItem.label) * is used. */ filterText?: string; /** * Select this item when showing. *Note* that only one completion item can be selected and * that the editor decides which item that is. The rule is that the *first* item of those * that match best is selected. */ preselect?: boolean; /** * A string or snippet that should be inserted in a document when selecting * this completion. * is used. */ insertText: string; /** * Addition rules (as bitmask) that should be applied when inserting * this completion. */ insertTextRules?: CompletionItemInsertTextRule; /** * A range of text that should be replaced by this completion item. * * Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the * current position. * * *Note:* The range must be a [single line](#Range.isSingleLine) and it must * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems). */ range: IRange; /** * An optional set of characters that when pressed while this completion is active will accept it first and * then type that character. *Note* that all commit characters should have `length=1` and that superfluous * characters will be ignored. */ commitCharacters?: string[]; /** * An optional array of additional text edits that are applied when * selecting this completion. Edits must not overlap with the main edit * nor with themselves. */ additionalTextEdits?: model.ISingleEditOperation[]; /** * A command that should be run upon acceptance of this item. */ command?: Command; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface CompletionList { suggestions: CompletionItem[]; incomplete?: boolean; dispose?(): void; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * Contains additional information about the context in which * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered. */ export interface CompletionContext { /** * How the completion was triggered. */ triggerKind: CompletionTriggerKind; /** * Character that triggered the completion item provider. * * `undefined` if provider was not triggered by a character. */ triggerCharacter?: string; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The completion item provider interface defines the contract between extensions and * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense). * * When computing *complete* completion items is expensive, providers can optionally implement * the `resolveCompletionItem`-function. In that case it is enough to return completion * items with a [label](#CompletionItem.label) from the * [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently, * when a completion item is shown in the UI and gains focus this provider is asked to resolve * the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail). */ export interface CompletionItemProvider { triggerCharacters?: string[]; /** * Provide completion items for the given position and document. */ provideCompletionItems(model: model.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>; /** * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation) * or [details](#CompletionItem.detail). * * The editor will only resolve a completion item once. */ resolveCompletionItem?(model: model.ITextModel, position: Position, item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The code action interface defines the contract between extensions and * the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature. * @internal */ export interface CodeActionProvider { /** * Provide commands for the given document and range. */ provideCodeActions(model: model.ITextModel, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<CodeAction[]>; /** * Optional list of CodeActionKinds that this provider returns. */ providedCodeActionKinds?: ReadonlyArray<string>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * Represents a parameter of a callable-signature. A parameter can * have a label and a doc-comment. */ export interface ParameterInformation { /** * The label of this signature. Will be shown in * the UI. */ label: string | [number, number]; /** * The human-readable doc-comment of this signature. Will be shown * in the UI but can be omitted. */ documentation?: string | IMarkdownString; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface SignatureHelpContext { readonly triggerKind: SignatureHelpTriggerKind; readonly triggerCharacter?: string; readonly isRetrigger: boolean; readonly activeSignatureHelp?: SignatureHelp; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The signature help provider interface defines the contract between extensions and * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature. */ export interface SignatureHelpProvider { readonly signatureHelpTriggerCharacters?: ReadonlyArray<string>; readonly signatureHelpRetriggerCharacters?: ReadonlyArray<string>; /** * Provide help for the signature at the given position and document. */ provideSignatureHelp(model: model.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The document highlight provider interface defines the contract between extensions and * the word-highlight-feature. */ export interface DocumentHighlightProvider { /** * Provide a set of document highlights, like all occurrences of a variable or * all exit-points of a function. */ provideDocumentHighlights(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The reference provider interface defines the contract between extensions and * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature. */ export interface ReferenceProvider { /** * Provide a set of project-wide references for the given position and document. */ provideReferences(model: model.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface LocationLink { /** * A range to select where this link originates from. */ originSelectionRange?: IRange; /** * The target uri this link points to. */ uri: URI; /** * The full range this link points to. */ range: IRange; /** * A range to select this link points to. Must be contained * in `LocationLink.range`. */ targetSelectionRange?: IRange; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The definition provider interface defines the contract between extensions and * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition) * and peek definition features. */ export interface DefinitionProvider { /** * Provide the definition of the symbol at the given position and document. */ provideDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The definition provider interface defines the contract between extensions and * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition) * and peek definition features. */ export interface DeclarationProvider { /** * Provide the declaration of the symbol at the given position and document. */ provideDeclaration(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The implementation provider interface defines the contract between extensions and * the go to implementation feature. */ export interface ImplementationProvider { /** * Provide the implementation of the symbol at the given position and document. */ provideImplementation(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The type definition provider interface defines the contract between extensions and * the go to type definition feature. */ export interface TypeDefinitionProvider { /** * Provide the type definition of the symbol at the given position and document. */ provideTypeDefinition(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The document symbol provider interface defines the contract between extensions and * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_goto-symbol)-feature. */ export interface DocumentSymbolProvider { displayName?: string; /** * Provide symbol information for the given document. */ provideDocumentSymbols(model: model.ITextModel, token: CancellationToken): ProviderResult<DocumentSymbol[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The document formatting provider interface defines the contract between extensions and * the formatting-feature. */ export interface DocumentFormattingEditProvider { /** * Provide formatting edits for a whole document. */ provideDocumentFormattingEdits(model: model.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The document formatting provider interface defines the contract between extensions and * the formatting-feature. */ export interface DocumentRangeFormattingEditProvider { /** * Provide formatting edits for a range in a document. * * The given range is a hint and providers can decide to format a smaller * or larger range. Often this is done by adjusting the start and end * of the range to full syntax nodes. */ provideDocumentRangeFormattingEdits(model: model.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * The document formatting provider interface defines the contract between extensions and * the formatting-feature. */ export interface OnTypeFormattingEditProvider { autoFormatTriggerCharacters: string[]; /** * Provide formatting edits after a character has been typed. * * The given position and character should hint to the provider * what range the position to expand to, like find the matching `{` * when `}` has been entered. */ provideOnTypeFormattingEdits(model: model.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * A provider of links. */ export interface LinkProvider { provideLinks(model: model.ITextModel, token: CancellationToken): ProviderResult<ILink[]>; resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult<ILink>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * A provider of colors for editor models. */ export interface DocumentColorProvider { /** * Provides the color ranges for a specific model. */ provideDocumentColors(model: model.ITextModel, token: CancellationToken): ProviderResult<IColorInformation[]>; /** * Provide the string representations for a color. */ provideColorPresentations(model: model.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult<IColorPresentation[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface SelectionRange { kind: string; range: IRange; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface SelectionRangeProvider { /** * Provide ranges that should be selected from the given position. */ provideSelectionRanges(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<SelectionRange[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
/** * A provider of colors for editor models. */ export interface FoldingRangeProvider { /** * Provides the color ranges for a specific model. */ provideFoldingRanges(model: model.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface FoldingRange { /** * The one-based start line of the range to fold. The folded area starts after the line's last character. */ start: number; /** * The one-based end line of the range to fold. The folded area ends with the line's last character. */ end: number; /** * Describes the [Kind](#FoldingRangeKind) of the folding range such as [Comment](#FoldingRangeKind.Comment) or * [Region](#FoldingRangeKind.Region). The kind is used to categorize folding ranges and used by commands * like 'Fold all comments'. See * [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds. */ kind?: FoldingRangeKind; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface ResourceFileEdit { oldUri: URI; newUri: URI; options: { overwrite?: boolean, ignoreIfNotExists?: boolean, ignoreIfExists?: boolean, recursive?: boolean }; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface WorkspaceEdit { edits: Array<ResourceTextEdit | ResourceFileEdit>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface Rejection { rejectReason?: string; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript
InterfaceDeclaration
export interface RenameProvider { provideRenameEdits(model: model.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit & Rejection>; resolveRenameLocation?(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult<RenameLocation & Rejection>; }
brasten/vscode
src/vs/editor/common/modes.ts
TypeScript