예제 #1
0
파일: LocalComponent.cs 프로젝트: krus/PTVS
        DkmInstructionSymbol[] IDkmSymbolDocumentSpanQuery.FindSymbols(DkmResolvedDocument resolvedDocument, DkmTextSpan textSpan, string text, out DkmSourcePosition[] symbolLocation)
        {
            if (resolvedDocument.Module.CompilerId.LanguageId != Guids.PythonLanguageGuid)
            {
                Debug.Fail("Non-Python module passed to FindSymbols.");
                throw new NotSupportedException();
            }

            return(ModuleManager.FindSymbols(resolvedDocument, textSpan, text, out symbolLocation));
        }
예제 #2
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) });
        }
예제 #3
0
        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)
            });
        }
예제 #4
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) };
        }