public (List <RhetosSignature> signatures, int?activeSignature, int?activeParameter) GetSignatureHelpAtPosition(LineChr lineChr) { var analysis = GetAnalysis(lineChr); if (analysis.KeywordToken == null || analysis.IsAfterAnyErrorLine(lineChr)) { return(null, null, null); } var signaturesWithDocumentation = conceptQueries.GetSignaturesWithDocumentation(analysis.KeywordToken.Value); var validConcepts = analysis.GetValidConceptsWithActiveParameter(); if (!validConcepts.Any()) { return(signaturesWithDocumentation, null, null); } var sortedConcepts = validConcepts .Select(valid => ( valid.conceptType, valid.activeParamater, parameterCount: ConceptInfoType.GetParameters(valid.conceptType).Count, documentation: signaturesWithDocumentation.Single(sig => sig.ConceptInfoType == valid.conceptType) )) .OrderBy(valid => valid.activeParamater >= valid.parameterCount) .ThenBy(valid => valid.parameterCount) .ThenBy(valid => valid.conceptType.Name) .ToList(); var activeParameter = sortedConcepts.First().activeParamater; return(sortedConcepts.Select(sorted => sorted.documentation).ToList(), 0, activeParameter); }
private RhetosSignature CreateRhetosSignature(Type conceptInfoType) { var prefix = " "; var signature = ConceptInfoType.SignatureDescription(conceptInfoType); var documentation = $"{prefix}* defined by {conceptInfoType.FullName}"; var xmlDocumentation = xmlDocumentationProvider.GetDocumentation(conceptInfoType, prefix); if (!string.IsNullOrEmpty(xmlDocumentation)) { documentation = $"{xmlDocumentation}\n{documentation}"; } return(new RhetosSignature() { ConceptInfoType = conceptInfoType, Parameters = ConceptInfoType.GetParameters(conceptInfoType), Signature = signature, Documentation = documentation }); }