예제 #1
0
        private Response GetOutliningRegions(AP.OutlingRegionsRequest request) {
            AP.OutliningTag[] tags = Array.Empty<AP.OutliningTag>();
            var bufferVersion = GetBufferVersion(request.fileId, request.bufferId);
            if (bufferVersion != null && bufferVersion.Ast != null) {
                var walker = new OutliningWalker(bufferVersion.Ast);

                bufferVersion.Ast.Walk(walker);

                tags = walker.GetTags();
            }

            return new AP.OutliningRegionsResponse() {
                tags = tags.ToArray(),
                version = bufferVersion?.Version ?? -1
            };
        }
예제 #2
0
        private void SnapshotOutlineTest(string fileContents, params ExpectedTag[] expected) {
            var snapshot = new TestUtilities.Mocks.MockTextSnapshot(new TestUtilities.Mocks.MockTextBuffer(fileContents), fileContents);
            var ast = Parser.CreateParser(new TextSnapshotToTextReader(snapshot), PythonLanguageVersion.V34).ParseFile();
            var walker = new OutliningWalker(ast);
            ast.Walk(walker);
            var protoTags = walker.GetTags();

            var tags = protoTags.Select(x =>
                OutliningTaggerProvider.OutliningTagger.GetTagSpan(
                    snapshot,
                    x.startIndex,
                    x.endIndex,
                    x.headerIndex
                )
            );
            VerifyTags(snapshot, tags, expected);
        }