Beispiel #1
0
        /// <summary>
        /// Gets source code mapping and metadata token based on type name and line number.
        /// </summary>
        /// <param name="codeMappings">Code mappings storage.</param>
        /// <param name="typeName">Member reference name.</param>
        /// <param name="lineNumber">Line number.</param>
        /// <param name="metadataToken">Metadata token.</param>
        /// <returns></returns>
        public static SourceCodeMapping GetInstructionByLineNumber(
            this MemberMapping codeMapping,
            int lineNumber,
            out int metadataToken)
        {
            if (codeMapping == null)
            {
                throw new ArgumentException("CodeMappings storage must be valid!");
            }

            var map = codeMapping.MemberCodeMappings.Find(m => m.StartLocation.Line == lineNumber);

            if (map != null)
            {
                metadataToken = codeMapping.MetadataToken;
                return(map);
            }

            metadataToken = 0;
            return(null);
        }
Beispiel #2
0
 void ITextOutput.AddDebuggerMemberMapping(MemberMapping memberMapping)
 {
 }
Beispiel #3
0
        public void EndNode(AstNode node)
        {
            if (nodeStack.Pop() != node)
                throw new InvalidOperationException();

            var startLocation = startLocations.Pop();

            // code mappings
            if (currentMemberMapping != null) {
                var ranges = node.Annotation<List<ILRange>>();
                if (ranges != null && ranges.Count > 0) {
                    // add all ranges
                    foreach (var range in ranges) {
                        currentMemberMapping.MemberCodeMappings.Add(
                            new SourceCodeMapping {
                                ILInstructionOffset = range,
                                StartLocation = startLocation,
                                EndLocation = output.Location,
                                MemberMapping = currentMemberMapping
                            });
                    }
                }
            }

            if (node.Annotation<MemberMapping>() != null) {
                output.AddDebuggerMemberMapping(currentMemberMapping);
                currentMemberMapping = parentMemberMappings.Pop();
            }
        }
Beispiel #4
0
        public void StartNode(AstNode node)
        {
            if (nodeStack.Count == 0) {
                if (IsUsingDeclaration(node)) {
                    firstUsingDeclaration = !IsUsingDeclaration(node.PrevSibling);
                    lastUsingDeclaration = !IsUsingDeclaration(node.NextSibling);
                } else {
                    firstUsingDeclaration = false;
                    lastUsingDeclaration = false;
                }
            }
            nodeStack.Push(node);
            startLocations.Push(output.Location);

            if (node is EntityDeclaration && node.Annotation<MemberReference>() != null && node.GetChildByRole(Roles.Identifier).IsNull)
                output.WriteDefinition("", node.Annotation<MemberReference>(), false);

            MemberMapping mapping = node.Annotation<MemberMapping>();
            if (mapping != null) {
                parentMemberMappings.Push(currentMemberMapping);
                currentMemberMapping = mapping;
            }
        }