/// <summary> Visit AXmlDocument </summary> public virtual void VisitDocument(AXmlDocument document) { foreach (AXmlObject child in document.Children) { child.AcceptVisitor(this); } }
/// <summary> /// Creates a new documentation element. /// </summary> public XmlDocumentationElement(AXmlDocument document, IEntity declaringEntity, Func<string, IEntity> crefResolver) { if (document == null) throw new ArgumentNullException("document"); this.xmlObject = document; this.declaringEntity = declaringEntity; this.crefResolver = crefResolver; }
/// <summary> /// Creates a new documentation element. /// </summary> public XmlDocumentationElement(AXmlDocument document, IEntity declaringEntity, Func <string, IEntity> crefResolver) { if (document == null) { throw new ArgumentNullException("document"); } this.xmlObject = document; this.declaringEntity = declaringEntity; this.crefResolver = crefResolver; }
void UpdateTree(AXmlDocument root) { if (treeView.Root == null) { treeView.Root = new XamlOutlineNode { ElementName = "Document Root", Name = Path.GetFileName(editor.FileName), Editor = editor }; } UpdateNode(treeView.Root as XamlOutlineNode, root); }
public XamlFullParseInformation(XamlUnresolvedFile unresolvedFile, AXmlDocument document, ITextSource text) : base(unresolvedFile, text.Version, true) { if (unresolvedFile == null) throw new ArgumentNullException("unresolvedFile"); if (document == null) throw new ArgumentNullException("document"); if (text == null) throw new ArgumentNullException("text"); this.document = document; this.text = text; }
void ParseInfoUpdated(object sender, ParseInformationEventArgs e) { if (this.editor == null || !FileUtility.IsEqualFileName(this.editor.FileName, e.FileName)) return; var parseInfo = e.NewParseInformation as XamlFullParseInformation; if (parseInfo != null && parseInfo.Document != null) { this.updateTreeTimer.Stop(); this.document = parseInfo.Document; this.updateTreeTimer.Start(); } }
public static XamlUnresolvedFile Create(FileName fileName, ITextSource fileContent, AXmlDocument document) { XamlUnresolvedFile file = new XamlUnresolvedFile(fileName); ReadOnlyDocument textDocument = new ReadOnlyDocument(fileContent, fileName); file.errors.AddRange(document.SyntaxErrors.Select(err => new Error(ErrorType.Error, err.Description, textDocument.GetLocation(err.StartOffset)))); var visitor = new XamlDocumentVisitor(file, textDocument); visitor.VisitDocument(document); if (visitor.TypeDefinition != null) file.topLevel = new[] { visitor.TypeDefinition }; else file.topLevel = new IUnresolvedTypeDefinition[0]; return file; }
void AddTagComments(AXmlDocument xmlDocument, ParseInformation parseInfo, ITextSource fileContent) { IDocument document = null; foreach (var tag in TreeTraversal.PreOrder<AXmlObject>(xmlDocument, node => node.Children).OfType<AXmlTag>().Where(t => t.IsComment)) { int matchLength; string commentText = fileContent.GetText(tag.StartOffset, tag.Length); int index = commentText.IndexOfAny(TaskListTokens, 0, out matchLength); if (index > -1) { if (document == null) document = fileContent as IDocument ?? new ReadOnlyDocument(fileContent, parseInfo.FileName); do { TextLocation startLocation = document.GetLocation(tag.StartOffset + index); int startOffset = index + tag.StartOffset; int endOffset = Math.Min(document.GetLineByOffset(startOffset).EndOffset, tag.EndOffset); string content = document.GetText(startOffset, endOffset - startOffset); parseInfo.TagComments.Add(new TagComment(content.Substring(0, matchLength), new DomRegion(parseInfo.FileName, startLocation.Line, startLocation.Column), content.Substring(matchLength))); index = commentText.IndexOfAny(TaskListTokens, endOffset - tag.StartOffset, out matchLength); } while (index > -1); } } }
/// <summary> Visit AXmlDocument </summary> public virtual void VisitDocument(AXmlDocument document) { foreach (AXmlObject child in document.Children) child.AcceptVisitor(this); }
public override void VisitDocument(AXmlDocument document) { currentDocument = document; AXmlElement rootElement = currentDocument.Children.OfType<AXmlElement>().FirstOrDefault(); if (rootElement != null) { string className = rootElement.GetAttributeValue(XamlConst.XamlNamespace, "Class"); string modifier = rootElement.GetAttributeValue(XamlConst.XamlNamespace, "ClassModifier"); if (className != null) { TypeDefinition = new DefaultUnresolvedTypeDefinition(className) { Kind = TypeKind.Class, UnresolvedFile = file, Accessibility = Accessibility.Public, Region = new DomRegion(file.FileName, textDocument.GetLocation(rootElement.StartOffset), textDocument.GetLocation(rootElement.EndOffset)) }; TypeDefinition.Members.Add( new DefaultUnresolvedMethod(TypeDefinition, "InitializeComponent") { Accessibility = Accessibility.Public, ReturnType = KnownTypeReference.Void }); TypeDefinition.Members.Add( new DefaultUnresolvedField(TypeDefinition, "_contentLoaded") { Accessibility = Accessibility.Private, ReturnType = KnownTypeReference.Boolean }); var connectMember = new DefaultUnresolvedMethod(TypeDefinition, "Connect") { Accessibility = Accessibility.Private, ReturnType = KnownTypeReference.Void }; connectMember.Parameters.Add(new DefaultUnresolvedParameter(KnownTypeReference.Int32, "connectionId")); connectMember.Parameters.Add(new DefaultUnresolvedParameter(KnownTypeReference.Object, "target")); TypeDefinition.Members.Add(connectMember); connectMember.ExplicitInterfaceImplementations.Add( new DefaultMemberReference(SymbolKind.Method, new GetClassTypeReference(new FullTypeName(typeof(System.Windows.Markup.IComponentConnector).FullName)), "Connect")); var browsableAttribute = new DefaultUnresolvedAttribute(new GetClassTypeReference(new FullTypeName(typeof(System.ComponentModel.EditorBrowsableAttribute).FullName))); browsableAttribute.PositionalArguments.Add( new SimpleConstantValue( new GetClassTypeReference(new FullTypeName(typeof(System.ComponentModel.EditorBrowsableAttribute).FullName)), System.ComponentModel.EditorBrowsableState.Never )); connectMember.Attributes.Add(browsableAttribute); TypeDefinition.BaseTypes.Add(CreateTypeReference(rootElement.Namespace, rootElement.LocalName)); TypeDefinition.BaseTypes.Add(new GetClassTypeReference(new FullTypeName(typeof(System.Windows.Markup.IComponentConnector).FullName))); if (modifier != null) TypeDefinition.Accessibility = ParseAccessibility(modifier); } } base.VisitDocument(document); }
public void Dispose() { SD.ParserService.ParseInformationUpdated -= ParseInfoUpdated; if (this.editor != null) { if (this.editor.Caret != null) this.editor.Caret.LocationChanged -= CaretLocationChanged; this.editor = null; } this.document = null; this.lastCaretLocation = null; this.selectedNode = null; if (this.updateTreeTimer != null) { this.updateTreeTimer.Stop(); this.updateTreeTimer.Tick -= this.UpdateTreeTimer_Tick; this.updateTreeTimer = null; } if (this.scrollToNodeTimer != null) { this.scrollToNodeTimer.Stop(); this.scrollToNodeTimer.Tick -= this.ScrollToNodeTimer_Tick; this.scrollToNodeTimer = null; } }