Esempio n. 1
0
        private void CreateAndRegisterReferenceSpan(INode node, INode bindableNode, CodexId <CodexClassification> classification = default, CodexId <CodexRefKind> referenceKind = default, bool throwOnUnknownSpan = true)
        {
            // In 'a.b' node is 'b' and bindable node is 'a.b'.
            if (node == null || node.IsInjectedForDScript())
            {
                return;
            }

            if (!m_definitionVisitor.TryGetCodexSpanFor(node, out var span))
            {
                if (throwOnUnknownSpan)
                {
                    throw Contract.AssertFailure($"Attempting to mark a span which is not a token. Node: '{node.ToDisplayString()}' at file {node.SourceFile.Path}, position {node.Pos}");
                }

                return;
            }

            if (classification.IsValid && !span.Classification.IsValid)
            {
                span.Classification = classification;
            }

            referenceKind = referenceKind.IsValid ? referenceKind : m_currentReferenceKinds.Peek();

            if (referenceKind.IsValid && !span.ReferenceKind.IsValid)
            {
                span.ReferenceKind = referenceKind;
            }

            m_codex.RegisterSymbolReference(span, bindableNode);
        }
Esempio n. 2
0
        private void RegisterLocalSymbolDefinition(IDeclaration bindableNode, CodexId <CodexClassification> classification = default)
        {
            if (bindableNode.IsInjectedForDScript())
            {
                return;
            }

            if (m_definitionVisitor.TryGetCodexSpanFor(bindableNode.Name, out var span) && !span.LocalId.IsValid)
            {
                var localId = new CodexId <object>()
                {
                    Id = m_localIdCursor++
                };
                m_codex.RegisterLocalSymbolDefinition(m_file.Path, bindableNode.GetNodeStartPositionWithoutTrivia(), localId);
                span.LocalId = localId;
                if (!span.Classification.IsValid)
                {
                    span.Classification = classification.IsValid ? classification : m_codex.Identifier;
                }
            }
            else
            {
                Contract.Assert(false, $"TODO: add message");
            }
        }