public void AugmentSignatureHelpSession(ISignatureHelpSession session, IList <ISignature> signatures) { ITextSnapshot snapshot = m_textBuffer.CurrentSnapshot; int position = session.GetTriggerPoint(m_textBuffer).GetPosition(snapshot); ITrackingSpan applicableToSpan = m_textBuffer.CurrentSnapshot.CreateTrackingSpan( new Span(position, 0), SpanTrackingMode.EdgeInclusive, 0); SnapshotPoint point = session.TextView.Caret.Position.BufferPosition - 2; TextExtent extent = m_navigator.GetTextStructureNavigator(m_textBuffer).GetExtentOfWord(point); string hintfunction = extent.Span.GetText(); var knownFunctions = m_parsedProject.GetAvailableFunctionSignatures(); foreach (var func in knownFunctions) { if (!func.Name.Text.Equals(hintfunction)) { continue; } foreach (var overload in func.Overloads) { signatures.Add(CreateSignature(m_textBuffer, func.Name.Text, overload, "Documentation goes here.", applicableToSpan)); } } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan) { // Map the trigger point down to our buffer. SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(m_subjectBuffer.CurrentSnapshot); if (!subjectTriggerPoint.HasValue) { applicableToSpan = null; return; } var funclist = m_parsedProject.GetAvailableFunctionSignatures(); m_dictionary = new Dictionary <string, string>(); foreach (var func in funclist) { m_dictionary.Add(func.Name.Text, func.ToString()); } var structlist = m_parsedProject.GetAvailableStructureDefinitions(); foreach (var st in structlist) { m_dictionary.Add(st.Key, st.Value.ToString()); } var variables = GetApplicableVariables(session); foreach (var v in variables) { m_dictionary.Add(v.Name.Text, v.ToString()); } ITextSnapshot currentSnapshot = subjectTriggerPoint.Value.Snapshot; SnapshotSpan querySpan = new SnapshotSpan(subjectTriggerPoint.Value, 0); //look for occurrences of our QuickInfo words in the span ITextStructureNavigator navigator = m_provider.NavigatorService.GetTextStructureNavigator(m_subjectBuffer); TextExtent extent = navigator.GetExtentOfWord(subjectTriggerPoint.Value); string searchText = extent.Span.GetText(); foreach (string key in m_dictionary.Keys) { if (key.CompareTo(searchText) == 0) { applicableToSpan = currentSnapshot.CreateTrackingSpan(extent.Span.Start, key.Length, SpanTrackingMode.EdgeInclusive); string value; m_dictionary.TryGetValue(key, out value); if (value != null) { qiContent.Add(value); } else { qiContent.Add(""); } return; } } applicableToSpan = null; }
void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { ITrackingSpan applicableTo = null; m_completionList = new List <Completion>(); var bufferpos = session.TextView.Caret.Position.BufferPosition.Subtract(1); if (bufferpos.GetChar().Equals('.')) { applicableTo = FindTokenSpanAfterPosition(session); var memberglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupStruct, StandardGlyphItem.GlyphItemPublic); var memfunglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic); List <string> varstack = GetMemberAccessStack(bufferpos); var variables = GetApplicableVariables(session); if (varstack != null) { foreach (var v in variables) { if (v.Name.Text.Equals(varstack[0])) { var defn = m_parsedProject.GetStructureDefinition(v.Type.Name); if (defn == null) { continue; } for (int i = 1; i < varstack.Count; ++i) { if (defn == null) { break; } foreach (var m in defn.Members) { if (m.Name.Equals(varstack[i])) { defn = m_parsedProject.GetStructureDefinition(m.Type.Name); break; } } defn = null; } if (defn != null) { foreach (var m in defn.Members) { m_completionList.Add(new Completion(m.Name.Text, m.Name.Text, $"{m.Type.Name} {m.Name.Text}", memberglyph, null)); // TODO - support member functions } } } } } } else { applicableTo = FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), session); var funcList = m_parsedProject.GetAvailableFunctionSignatures(); var funcglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic); foreach (var sig in funcList) { m_completionList.Add(new Completion(sig.Name.Text, sig.Name.Text, string.Join("\r\n\r\n", sig.Overloads.Select(o => o.Format(sig.Name.Text)).ToArray()), funcglyph, null)); } var structuredefs = m_parsedProject.GetAvailableStructureDefinitions(); var structglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupType, StandardGlyphItem.GlyphItemPublic); foreach (var strdef in structuredefs) { m_completionList.Add(new Completion(strdef.Key, strdef.Key, strdef.Value.ToString(), structglyph, null)); } var udtList = m_parsedProject.GetAvailableTypeNames(); var udtglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupTypedef, StandardGlyphItem.GlyphItemPublic); foreach (string str in udtList) { m_completionList.Add(new Completion(str, str, str, udtglyph, null)); } List <string> typeList = new List <string>(); typeList.Add("boolean"); typeList.Add("buffer"); typeList.Add("integer"); typeList.Add("integer16"); typeList.Add("integer64"); typeList.Add("real"); typeList.Add("string"); var typeglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupIntrinsic, StandardGlyphItem.GlyphItemPublic); foreach (string str in typeList) { m_completionList.Add(new Completion(str, str, str, typeglyph, null)); } var keywordList = new List <string>(); keywordList.Add("ref"); keywordList.Add("else"); keywordList.Add("elseif"); keywordList.Add("if"); keywordList.Add("structure"); keywordList.Add("type"); keywordList.Add("while"); var keywordglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphKeyword, StandardGlyphItem.GlyphItemPublic); foreach (string str in keywordList) { m_completionList.Add(new Completion(str, str, str, keywordglyph, null)); } var valueList = new List <string>(); valueList.Add("true"); valueList.Add("false"); valueList.Add("nothing"); var valueglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupValueType, StandardGlyphItem.GlyphItemPublic); foreach (string str in valueList) { m_completionList.Add(new Completion(str, str, str, valueglyph, null)); } var varlist = GetApplicableVariables(session); var varglyph = m_glyphService.GetGlyph(StandardGlyphGroup.GlyphGroupVariable, StandardGlyphItem.GlyphItemPublic); foreach (var v in varlist) { m_completionList.Add(new Completion(v.Name.Text, v.Name.Text, v.Type.Name + " " + v.Name.Text, varglyph, null)); } m_completionList.Sort((a, b) => { return(a.DisplayText.CompareTo(b.DisplayText)); }); } if (m_completionList.Count > 0) { completionSets.Add(new CompletionSet("Epoch", "Epoch", applicableTo, m_completionList, null)); } }