Exemple #1
0
        public static XmlDocumentSyntax Analyze(BoundSourceFileBuilder binder)
        {
            var text = binder.SourceFile.Content;
            XmlDocumentSyntax parsedXml = Parser.ParseText(text);

            Classify(binder, parsedXml);
            return(parsedXml);
        }
        public static void AddElementNameReferences(
            this BoundSourceFileBuilder binder,
            IXmlElement element,
            params ReferenceSymbol[] references)
        {
            var nameNode = element.NameNode();

            binder.AnnotateReferences(nameNode.Start, nameNode.FullWidth - nameNode.GetTrailingTriviaWidth(), references);
        }
        public static void AddAttributeValueDefinition(
            this BoundSourceFileBuilder binder,
            XmlAttributeSyntax attribute,
            DefinitionSymbol definition)
        {
            var node = attribute?.ValueNode.As <XmlStringSyntax>()?.TextTokens.Node;

            if (node != null)
            {
                binder.AnnotateDefinition(node.Start, node.FullWidth, definition);
            }
        }
        public static void AddAttributeNameReferences(
            this BoundSourceFileBuilder binder,
            XmlAttributeSyntax attribute,
            params ReferenceSymbol[] references)
        {
            var node = attribute?.NameNode;

            if (node != null)
            {
                binder.AnnotateReferences(node.Start, node.FullWidth, references);
            }
        }
        public static void AddAttributeValueReferences(
            this BoundSourceFileBuilder binder,
            XmlAttributeSyntax attribute,
            params ReferenceSymbol[] references)
        {
            var node = attribute?.ValueNode.As <XmlStringSyntax>()?.TextTokens.Node;

            if (node != null)
            {
                binder.AnnotateReferences(node.Start, node.FullWidth, references);
            }
        }
Exemple #6
0
        private static void Classify(BoundSourceFileBuilder binder, XmlDocumentSyntax parsedXml)
        {
            ClassifierVisitor.Visit(parsedXml, 0, parsedXml.FullWidth, (start, length, node, classification) =>
            {
                var leadingTriviaWidth  = node.GetLeadingTriviaWidth();
                var trailingTriviaWidth = node.GetTrailingTriviaWidth();
                start  += leadingTriviaWidth;
                length -= (leadingTriviaWidth + trailingTriviaWidth);

                binder.AnnotateClassification(start, length, ClassificationTypeNamesLookup[(int)classification]);
            });
        }
Exemple #7
0
        public DocumentAnalyzer(
            SemanticServices semanticServices,
            Document document,
            CompilationServices compilationServices,
            string logicalPath,
            AnalyzedProjectContext context,
            BoundSourceFileBuilder boundSourceFile)
        {
            _document             = document;
            CompilationServices   = compilationServices;
            _compilation          = compilationServices.Compilation;
            _analyzedProject      = context.Project;
            this.semanticServices = semanticServices;
            this.context          = context;

            references = new List <ReferenceSpan>();

            this.boundSourceFile = boundSourceFile;
        }