public LexScanner(LexController controller) { Line = controller.Line; Column = controller.Column; Index = controller.Index; _content = controller.Content; _startPos = new DocPos(Line, Column); }
public CompletionItem[] GetCompletion(DocPos pos, bool immediate) { if (_scope == null) { return(_completionItems); } return(_scope.GetCompletion(_deltinScript, pos, immediate, _getter)); }
public SignatureHelp GetSignatureHelp(DocPos caretPos) { // Get the active parameter. int activeParameter = -1; if (ParameterRanges != null) { // Loop through parameter ranges while activeParameter is -1. for (int i = 0; i < ParameterRanges.Length && activeParameter == -1; i++) { // If the proved caret position is inside the parameter range, set it as the active parameter. if (ParameterRanges[i] != null && ParameterRanges[i].IsInside(caretPos)) { activeParameter = i; } } } // Get the signature information. SignatureInformation[] overloads = new SignatureInformation[AllOverloads.Length]; for (int i = 0; i < overloads.Length; i++) { // Get the parameter information for the signature. var parameters = new ParameterInformation[AllOverloads[i].Parameters.Length]; // Convert parameters to parameter information. for (int p = 0; p < parameters.Length; p++) { parameters[p] = new ParameterInformation() { // Get the label to show in the signature. Label = AllOverloads[i].Parameters[p].GetLabel(false), // Get the documentation. Documentation = Extras.GetMarkupContent(AllOverloads[i].Parameters[p].Documentation) } } ; // Create the signature information. overloads[i] = new SignatureInformation() { Label = AllOverloads[i].GetLabel(false), Parameters = parameters, Documentation = AllOverloads[i].Documentation }; } return(new SignatureHelp() { ActiveParameter = activeParameter, ActiveSignature = Array.IndexOf(AllOverloads, Overload), Signatures = overloads }); } }
public (IDeclarationKey key, DocRange range) KeyFromPosition(DocPos position) { foreach (var callList in _declarationCalls) { foreach (var pair in callList.Value) { if (pair.CallRange.IsInside(position)) { return(new(callList.Key, pair.CallRange)); } } } return(new(null, null)); }
public void UpdatePosition(DocPos pos, int index) { pos.Line = GetLine(index); pos.Character = GetColumn(index); }
public int IndexOf(DocPos pos) => GetLineIndex(pos.Line) + pos.Character;
public bool IsInside(DocPos pos) => (Start.Line < pos.Line || (Start.Line == pos.Line && pos.Character >= Start.Character)) && (End.Line > pos.Line || (End.Line == pos.Line && pos.Character <= End.Character));
public DocRange(DocPos start, DocPos end) { Start = start; End = end; }
private bool WasScopedAtPosition(IScopeable element, DocPos pos, Scope getter) { return((pos == null || element.DefinedAt == null || element.WholeContext || element.DefinedAt.range.Start <= pos) && (getter == null || getter.AccessorMatches(element))); }
public CompletionItem[] GetCompletion(DocPos pos, bool immediate, Scope getter = null) { var completions = new List <CompletionItem>(); // The list of completion items in this scope. // Get the functions. var batches = new List <FunctionBatch>(); IterateParents(scope => { // Iterate through each group. foreach (var group in scope._methodGroups) { // Iterate through each function in the group. foreach (var func in group.Functions) { // If the function is scoped at pos, // add it to a batch. if (scope.WasScopedAtPosition(func, pos, getter)) { bool batchFound = false; // Determines if a batch was found for the function. // Iterate through each existing batch. foreach (var batch in batches) { // If the current batch's name is equal to the function's name, add it to the batch. if (batch.Name == func.Name) { batch.Add(); batchFound = true; break; } } // If no batch was found for the function name, create a new batch. if (!batchFound) { batches.Add(new FunctionBatch(func.Name, func)); } } } } // Add the variables. foreach (var variable in scope._variables) { if (variable is MethodGroup == false && scope.WasScopedAtPosition(variable, pos, getter)) { completions.Add(variable.GetCompletion()); } } return(scope.CompletionCatch); }); // Get the batch completion. foreach (var batch in batches) { completions.Add(batch.GetCompletion()); } return(completions.ToArray()); }
public CompletionItem[] GetCompletion(DocPos pos, bool immediate) { return(Scope?.GetCompletion(pos, immediate, Getter) ?? CompletionItems); }
public TypeCastInfo(IParseType castingTo, DocPos startPosition) { CastingTo = castingTo; StartPosition = startPosition; }
public SignatureHelp GetSignatureHelp(DocPos caretPos) { // Get the active parameter. int activeParameter = -1; // Comma with no proceeding value. if (_extraneousParameterRange != null && (_extraneousParameterRange.Start + CallRange.End).IsInside(caretPos)) { activeParameter = _providedParameterCount; } // Parameter else if (ParameterResults != null) { // Loop through parameter ranges while activeParameter is -1. for (int i = 0; i < ParameterResults.Length && activeParameter == -1; i++) { // If the proved caret position is inside the parameter range, set it as the active parameter. if (ParameterResults[i].ParameterRange != null && ParameterResults[i].ParameterRange.IsInside(caretPos)) { activeParameter = i; } } } // Get the signature information. SignatureInformation[] signatureInformations = new SignatureInformation[_matches.Length]; int activeSignature = -1; for (int i = 0; i < signatureInformations.Length; i++) { var match = _matches[i]; var overload = match.Option; // If the chosen overload matches the overload being iterated upon, set the active signature. if (Overload == overload.Value) { activeSignature = i; } // Get the parameter information for the signature. var parameters = new ParameterInformation[overload.Parameters.Length]; // Convert parameters to parameter information. for (int p = 0; p < parameters.Length; p++) { parameters[p] = new ParameterInformation() { // Get the label to show in the signature. Label = overload.Parameters[p].GetLabel(_parseInfo.TranslateInfo, new AnonymousLabelInfo(match.TypeArgLinker)), // Get the documentation. Documentation = overload.Parameters[p].Documentation } } ; // Create the signature information. signatureInformations[i] = new SignatureInformation() { Label = overload.GetLabel(_parseInfo.TranslateInfo, new LabelInfo() { IncludeDocumentation = false, IncludeParameterNames = true, IncludeParameterTypes = true, IncludeReturnType = true, AnonymousLabelInfo = new AnonymousLabelInfo(match.TypeArgLinker) }), Parameters = parameters, Documentation = overload.Documentation }; } return(new SignatureHelp() { ActiveParameter = activeParameter, ActiveSignature = activeSignature, Signatures = signatureInformations }); } }
public ValueInArrayInfo(IParseExpression index, DocPos endPosition) { Index = index; EndPosition = endPosition; }