public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Map the trigger point down to our buffer. SnapshotPoint? subjectTriggerPoint = session.GetTriggerPoint(textBuffer.CurrentSnapshot); if (subjectTriggerPoint.HasValue) { XmlLanguageService xls = (XmlLanguageService)this.serviceProvider.GetService(typeof(XmlLanguageService)); IVsTextView vsTextView = this.vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; int tmp = vsTextView.GetLineAndColumn(subjectTriggerPoint.Value.Position, out line, out column); XmlDocument doc = xls.GetParseTree(xls.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); //if (doc.RootNamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) //{ NodeFinder nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlAttribute) { XmlAttribute attr = (XmlAttribute)nf.Scope; XmlElement elt = (XmlElement)attr.Parent; if (elt.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { if (attr.LocalName.EndsWith("type", StringComparison.OrdinalIgnoreCase)) { string comment = GetTypeComment(attr.LiteralValue); if (comment != null) { quickInfoContent.Add(comment); applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan( subjectTriggerPoint.Value.Position - (column - attr.Value.SourceContext.StartColumn), attr.Value.SourceContext.EndColumn - attr.Value.SourceContext.StartColumn, SpanTrackingMode.EdgeInclusive); return; } } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { string comment = GetPropertyComment(typeName, attr.LiteralValue); if (comment != null) { quickInfoContent.Add(comment); applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan( subjectTriggerPoint.Value.Position - (column - attr.Value.SourceContext.StartColumn), attr.Value.SourceContext.EndColumn - attr.Value.SourceContext.StartColumn, SpanTrackingMode.EdgeInclusive); return; } } } } } } //} } applicableToSpan = null; }
public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) { XmlLanguageService xls = (XmlLanguageService)this.serviceProvider.GetService(typeof(XmlLanguageService)); IVsTextView vsTextView = this.vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; int tmp = vsTextView.GetCaretPos(out line, out column); XmlDocument doc = xls.GetParseTree(xls.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); //if (doc.RootNamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) //{ NodeFinder nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlElement) { if (nf.Scope.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { completionSets.Add(CreateCompletionSet( this.GetSnippetsCompletions(), session, true)); } } else if (nf.Scope is XmlAttribute) { //XmlSchemaAttribute sa = nf.Scope.SchemaType as XmlSchemaAttribute; //if (sa != null) //{ //if (nf.Scope.Closed) //{ XmlAttribute attr = (XmlAttribute)nf.Scope; XmlElement elt = (XmlElement)attr.Parent; if (elt.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { if (attr.LocalName.EndsWith("type", StringComparison.OrdinalIgnoreCase)) { completionSets.Add(CreateCompletionSet( GetTypeCompletions(attr.Value.Value, false), session, false)); } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { completionSets.Add(CreateCompletionSet( GetTypePropertyCompletions(typeName), session, false)); } } } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("constructor-arg", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { completionSets.Add(CreateCompletionSet( GetTypeCtorsArgsNamesCompletions(typeName), session, false)); } } } else if (attr.LocalName.Equals("value", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string propertyName = elt.GetAttribute("name"); string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName) && !String.IsNullOrWhiteSpace(propertyName)) { completionSets.Add(CreateCompletionSet( GetTypePropertyValueCompletions(typeName, propertyName, attr.Value.Value), session, false)); } } } } } }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { XmlLanguageService xls = (XmlLanguageService)this.serviceProvider.GetService(typeof(XmlLanguageService)); IVsTextView vsTextView = this.vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; int tmp = vsTextView.GetCaretPos(out line, out column); XmlDocument doc = xls.GetParseTree(xls.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); //if (doc.RootNamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) //{ NodeFinder nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlElement) { if (nf.Scope.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { completionSets.Add(CreateCompletionSet( this.GetSnippetsCompletions(), session, true)); } } else if (nf.Scope is XmlAttribute) { //XmlSchemaAttribute sa = nf.Scope.SchemaType as XmlSchemaAttribute; //if (sa != null) //{ //if (nf.Scope.Closed) //{ XmlAttribute attr = (XmlAttribute)nf.Scope; XmlElement elt = (XmlElement)attr.Parent; if (elt.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { if (attr.LocalName.EndsWith("type", StringComparison.OrdinalIgnoreCase)) { completionSets.Add(CreateCompletionSet( GetTypeCompletions(attr.Value.Value, false), session, false)); } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { completionSets.Add(CreateCompletionSet( GetTypePropertyCompletions(typeName), session, false)); } } } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("constructor-arg", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { completionSets.Add(CreateCompletionSet( GetTypeCtorsArgsNamesCompletions(typeName), session, false)); } } } else if (attr.LocalName.Equals("value", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string propertyName = elt.GetAttribute("name"); string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName) && !String.IsNullOrWhiteSpace(propertyName)) { completionSets.Add(CreateCompletionSet( GetTypePropertyValueCompletions(typeName, propertyName, attr.Value.Value), session, false)); } } } } } }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets) { // If this session has already been disposed, ignore it if (_disposed) { return; } IVsTextView vsTextView = _vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; vsTextView.GetCaretPos(out line, out column); var doc = _xmlLanguageService.GetParseTree( _xmlLanguageService.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); if (doc == null || !SupportedNamespaces.Contains(doc.RootNamespaceURI)) { return; } var nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlAttribute) { var attr = (XmlAttribute)nf.Scope; var attrName = attr.LocalName; if (SupportedAttributeNames.Contains(attrName)) { if (_entries == null) { _entries = ExcelLoader.GetIds(_serviceProvider); } var elt = (XmlElement)attr.Parent; IEnumerable <Entry> completions = null; if (elt == null) { return; } var type = elt.LocalName; if (string.IsNullOrEmpty(type)) { return; } if (type == "tab") { completions = GetEntries(type); var eltParent = elt.Parent as XmlElement; if (eltParent != null && eltParent.LocalName == "backstage") { completions = completions.Where(e => e.TabSet == "None (Backstage View)"); } else if (eltParent != null && eltParent.LocalName == "tabSet") { completions = completions.Where(e => e.TabSet != "None (Core Tab)"); } else { completions = completions.Where(e => e.TabSet == "None (Core Tab)"); } } else if (type == "tabSet") { completions = GetEntries(type); } else if (type == "group") { completions = GetEntries(type); var tabName = GetParentItemIdMso(elt, "tab"); if (!string.IsNullOrEmpty(tabName)) { completions = completions.Where(e => e.Tab == tabName); } } else if (SupportedControlsTypes.Contains(type)) { var tab = GetParentItemIdMso(elt, "tab"); var group = GetParentItemIdMso(elt, "group"); var contextMenu = GetParentItemIdMso(elt, "contextMenu"); if (attrName == "idMso") { completions = GetEntries(type); } else { completions = _entries.Where(e => SupportedControlsTypes.Contains(e.ControlType)); } if (tab == "None (Context Menu)") { if (!string.IsNullOrEmpty(contextMenu)) { completions = completions.Where(e => e.Group == contextMenu); } } else if (tab != "None (Backstage View)") { if (!string.IsNullOrEmpty(tab)) { completions = completions.Where(e => e.Tab == tab); } if (!string.IsNullOrEmpty(group)) { completions = completions.Where(e => e.Group == group); } } } else if (type == "command") { completionSets.Clear(); completions = _entries .Where(e => SupportedControlsTypes.Contains(e.ControlType)); } else if (type == "category") { completions = GetEntries(type); var tabName = GetParentItemIdMso(elt, "tab"); if (!string.IsNullOrEmpty(tabName)) { completions = completions.Where(e => e.Tab == tabName); } var taskGroupName = GetParentItemIdMso(elt, "taskGroup"); if (!string.IsNullOrEmpty(tabName)) { completions = completions.Where(e => e.Group == taskGroupName); } } else if (type == "taskFormGroup" || type == "taskGroup") { completions = GetEntries(type); var tabName = GetParentItemIdMso(elt, "tab"); if (!string.IsNullOrEmpty(tabName)) { completions = completions.Where(e => e.Tab == tabName); } } else if (type == "task") { completions = GetEntries(type); var taskGroup = GetParentItemIdMso(elt, "taskGroup"); if (!string.IsNullOrEmpty(taskGroup)) { completions = completions.Where(e => e.Group == taskGroup); } var category = GetParentItemIdMso(elt, "category"); if (!string.IsNullOrEmpty(taskGroup)) { completions = completions.Where(e => e.ParentControl == category); } } else if (type == "contextMenu") { completions = GetEntries(type); } if (completions != null) { completionSets.Clear(); completionSets.Add(new CompletionSet("idMso", "idMso", CreateTrackingSpan(session), completions.Select(e => e.Completion), null)); } } else if (attr.LocalName == "imageMso") { var completions = ImageLoader.GetMsoImages(_serviceProvider); completionSets.Clear(); completionSets.Add(new CompletionSet("imageMso", "imageMso", CreateTrackingSpan(session), completions, null)); } } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Map the trigger point down to our buffer. SnapshotPoint?subjectTriggerPoint = session.GetTriggerPoint(textBuffer.CurrentSnapshot); if (subjectTriggerPoint.HasValue) { XmlLanguageService xls = (XmlLanguageService)this.serviceProvider.GetService(typeof(XmlLanguageService)); IVsTextView vsTextView = this.vsEditorAdaptersFactoryService.GetViewAdapter(session.TextView); int line; int column; int tmp = vsTextView.GetLineAndColumn(subjectTriggerPoint.Value.Position, out line, out column); XmlDocument doc = xls.GetParseTree(xls.GetSource(vsTextView), vsTextView, line, column, Microsoft.VisualStudio.Package.ParseReason.CompleteWord); //if (doc.RootNamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) //{ NodeFinder nf = new NodeFinder(line, column); nf.Visit(doc); if (nf.Scope is XmlAttribute) { XmlAttribute attr = (XmlAttribute)nf.Scope; XmlElement elt = (XmlElement)attr.Parent; if (elt.NamespaceURI.Equals("http://www.springframework.net", StringComparison.OrdinalIgnoreCase)) { if (attr.LocalName.EndsWith("type", StringComparison.OrdinalIgnoreCase)) { string comment = GetTypeComment(attr.LiteralValue); if (comment != null) { quickInfoContent.Add(comment); applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan( subjectTriggerPoint.Value.Position - (column - attr.Value.SourceContext.StartColumn), attr.Value.SourceContext.EndColumn - attr.Value.SourceContext.StartColumn, SpanTrackingMode.EdgeInclusive); return; } } else if (attr.LocalName.Equals("name", StringComparison.OrdinalIgnoreCase) && elt.LocalName.Equals("property", StringComparison.OrdinalIgnoreCase)) { XmlElement elt2 = (XmlElement)elt.Parent; if (elt2.LocalName.Equals("object", StringComparison.OrdinalIgnoreCase)) { string typeName = elt2.GetAttribute("type"); if (!String.IsNullOrWhiteSpace(typeName)) { string comment = GetPropertyComment(typeName, attr.LiteralValue); if (comment != null) { quickInfoContent.Add(comment); applicableToSpan = subjectTriggerPoint.Value.Snapshot.CreateTrackingSpan( subjectTriggerPoint.Value.Position - (column - attr.Value.SourceContext.StartColumn), attr.Value.SourceContext.EndColumn - attr.Value.SourceContext.StartColumn, SpanTrackingMode.EdgeInclusive); return; } } } } } } //} } applicableToSpan = null; }