コード例 #1
0
ファイル: ModuleManager.cs プロジェクト: omnimark/PTVS
        public static DkmResolvedDocument[] FindDocuments(DkmModule module, DkmSourceFileId sourceFileId) {
            DkmDocumentMatchStrength matchStrength;
            if (string.Equals(module.Name, sourceFileId.DocumentName, StringComparison.OrdinalIgnoreCase)) {
                matchStrength = DkmDocumentMatchStrength.FullPath;
            } else {
                // Either the module path is relative, or it's absolute but on a different filesystem (i.e. remote debugging).
                // Walk the local filesystem up starting from source file path, matching it against the module path component
                // by component, stopping once __init__.py is no longer seen on the same level. The intent is to approximate
                // a match on module names by matching the tails of the two paths that contribute to the fully qualified names
                // of the modules.
                string sourcePath = sourceFileId.DocumentName;
                string modulePath = module.Name;
                int levels = 0;
                do {
                    try {
                        string sourceFile = Path.GetFileName(sourcePath);
                        string moduleFile = Path.GetFileName(modulePath);
                        if (!string.Equals(sourceFile, moduleFile, StringComparison.OrdinalIgnoreCase)) {
                            return new DkmResolvedDocument[0];
                        }
                        sourcePath = Path.GetDirectoryName(sourcePath);
                        modulePath = Path.GetDirectoryName(modulePath);
                    } catch (ArgumentException) {
                        return new DkmResolvedDocument[0];
                    }
                    ++levels;
                } while (File.Exists(Path.Combine(sourcePath, "__init__.py")));
                matchStrength = (levels == 1) ? DkmDocumentMatchStrength.FileName : DkmDocumentMatchStrength.SubPath;
            }

            return new[] {
                DkmResolvedDocument.Create(module, module.Name, null, matchStrength, DkmResolvedDocumentWarning.None, false, null)
            };
        }
コード例 #2
0
        public static DkmSourcePosition GetSourcePosition(DkmInstructionSymbol instruction, DkmSourcePositionFlags flags, DkmInspectionSession inspectionSession, out bool startOfLine)
        {
            var insSym = instruction as DkmCustomInstructionSymbol;
            var loc    = new SourceLocation(insSym.AdditionalData);

            startOfLine = true;
            return(DkmSourcePosition.Create(DkmSourceFileId.Create(loc.FileName, null, null, null), new DkmTextSpan(loc.LineNumber, loc.LineNumber, 0, 0)));
        }
コード例 #3
0
        public static DkmInstructionSymbol[] FindSymbols(DkmResolvedDocument resolvedDocument, DkmTextSpan textSpan, string text, out DkmSourcePosition[] symbolLocation)
        {
            var sourceFileId = DkmSourceFileId.Create(resolvedDocument.DocumentName, null, null, null);
            var resultSpan   = new DkmTextSpan(textSpan.StartLine, textSpan.StartLine, 0, 0);

            symbolLocation = new[] { DkmSourcePosition.Create(sourceFileId, resultSpan) };

            var location        = new SourceLocation(resolvedDocument.DocumentName, textSpan.StartLine);
            var encodedLocation = location.Encode();

            return(new[] { DkmCustomInstructionSymbol.Create(resolvedDocument.Module, Guids.PythonRuntimeTypeGuid, encodedLocation, 0, encodedLocation) });
        }
コード例 #4
0
ファイル: ModuleManager.cs プロジェクト: int19h/PTVS
        public static DkmResolvedDocument[] FindDocuments(DkmModule module, DkmSourceFileId sourceFileId)
        {
            DkmDocumentMatchStrength matchStrength;

            // Shortcut invalid modules.
            if (module.Name.Contains("<"))
            {
                return(new DkmResolvedDocument[0]);
            }

            if (string.Equals(module.Name, sourceFileId.DocumentName, StringComparison.OrdinalIgnoreCase))
            {
                matchStrength = DkmDocumentMatchStrength.FullPath;
            }
            else
            {
                // Either the module path is relative, or it's absolute but on a different filesystem (i.e. remote debugging).
                // Walk the local filesystem up starting from source file path, matching it against the module path component
                // by component, stopping once __init__.py is no longer seen on the same level. The intent is to approximate
                // a match on module names by matching the tails of the two paths that contribute to the fully qualified names
                // of the modules.
                string sourcePath = sourceFileId.DocumentName;
                string modulePath = module.Name;
                int    levels     = 0;
                do
                {
                    try {
                        string sourceFile = Path.GetFileName(sourcePath);
                        string moduleFile = Path.GetFileName(modulePath);
                        if (!string.Equals(sourceFile, moduleFile, StringComparison.OrdinalIgnoreCase))
                        {
                            return(new DkmResolvedDocument[0]);
                        }
                        sourcePath = Path.GetDirectoryName(sourcePath);
                        modulePath = Path.GetDirectoryName(modulePath);
                    } catch (ArgumentException) {
                        return(new DkmResolvedDocument[0]);
                    }
                    ++levels;
                } while (File.Exists(Path.Combine(sourcePath, "__init__.py")));
                matchStrength = (levels == 1) ? DkmDocumentMatchStrength.FileName : DkmDocumentMatchStrength.SubPath;
            }

            return(new[] {
                DkmResolvedDocument.Create(module, module.Name, null, matchStrength, DkmResolvedDocumentWarning.None, false, null)
            });
        }
コード例 #5
0
ファイル: LocalComponent.cs プロジェクト: krus/PTVS
        DkmResolvedDocument[] IDkmSymbolDocumentCollectionQuery.FindDocuments(DkmModule module, DkmSourceFileId sourceFileId)
        {
            if (module.CompilerId.LanguageId != Guids.PythonLanguageGuid)
            {
                Debug.Fail("Non-Python module passed to FindDocuments.");
                throw new NotSupportedException();
            }

            return(ModuleManager.FindDocuments(module, sourceFileId));
        }