[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
//===--- Selection.h - What's under the cursor? -------------------*-C++-*-===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Many features are triggered at locations/ranges and operate on AST nodes.
|
|
|
|
// (e.g. go-to-definition or code tweaks).
|
|
|
|
// At a high level, such features need to work out which node is the correct
|
|
|
|
// target.
|
|
|
|
//
|
|
|
|
// There are a few levels of ambiguity here:
|
|
|
|
//
|
|
|
|
// Which tokens are included:
|
|
|
|
// int x = one + two; // what should "go to definition" do?
|
|
|
|
// ^^^^^^
|
|
|
|
//
|
|
|
|
// Same token means multiple things:
|
|
|
|
// string("foo") // class string, or a constructor?
|
|
|
|
// ^
|
|
|
|
//
|
|
|
|
// Which level of the AST is interesting?
|
|
|
|
// if (err) { // reference to 'err', or operator bool(),
|
|
|
|
// ^ // or the if statement itself?
|
|
|
|
//
|
|
|
|
// Here we build and expose a data structure that allows features to resolve
|
|
|
|
// these ambiguities in an appropriate way:
|
|
|
|
// - we determine which low-level nodes are partly or completely covered
|
|
|
|
// by the selection.
|
|
|
|
// - we expose a tree of the selected nodes and their lexical parents.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SELECTION_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SELECTION_H
|
|
|
|
#include "clang/AST/ASTTypeTraits.h"
|
|
|
|
#include "clang/AST/PrettyPrinter.h"
|
[clangd] Ignore semicolons, whitespace, and comments in SelectionTree.
Summary:
Whitespace and comments are a clear bugfix: selecting some
comments/space near a statement doesn't mean you're selecting the
surrounding block.
Semicolons are less obvious, but for similar reasons: these tokens
aren't actually claimed by any AST node (usually), so an AST-based model
like SelectionTree shouldn't take them into account.
Callers may still sometimes care about semis of course:
- when the selection is an expr with a non-expr parent, selection of
the semicolon indicates intent to select the statement.
- when a statement with a trailing semi is selected, we need to know
its range to ensure it can be removed.
SelectionTree may or may not play a role here, but these are separate questions
from its core function of describing which AST nodes were selected.
The mechanism here is the TokenBuffer from syntax-trees. We use it in a
fairly low-level way (just to get boundaries of raw spelled tokens). The
actual mapping of AST nodes to coordinates continues to use the (fairly
mature) SourceLocation based logic. TokenBuffer/Syntax trees
don't currently offer an alternative to getFileRange(), I think.
Reviewers: SureYeaah, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65486
llvm-svn: 367453
2019-08-01 01:52:40 +08:00
|
|
|
#include "clang/Tooling/Syntax/Tokens.h"
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace clangd {
|
|
|
|
class ParsedAST;
|
|
|
|
|
|
|
|
// A selection can partially or completely cover several AST nodes.
|
|
|
|
// The SelectionTree contains nodes that are covered, and their parents.
|
|
|
|
// SelectionTree does not contain all AST nodes, rather only:
|
|
|
|
// Decl, Stmt, TypeLoc, NestedNamespaceSpecifierLoc, CXXCtorInitializer.
|
|
|
|
// (These are the nodes with source ranges that fit in DynTypedNode).
|
|
|
|
//
|
|
|
|
// Usually commonAncestor() is the place to start:
|
|
|
|
// - it's the simplest answer to "what node is under the cursor"
|
|
|
|
// - the selected Expr (for example) can be found by walking up the parent
|
|
|
|
// chain and checking Node->ASTNode.
|
|
|
|
// - if you want to traverse the selected nodes, they are all under
|
|
|
|
// commonAncestor() in the tree.
|
|
|
|
//
|
[clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with other containers.
Summary:
Previously TranslationUnitDecl would never be selected.
This means root() is never null, and returns a reference.
commonAncestor() is in principle never null also, but returning TUDecl
here requires tweaks to be careful not to traverse it (this was already
possible when selecting multiple top-level decls, and there are associated bugs!)
Instead, never allow commonAncestor() to return TUDecl, return null instead.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65101
llvm-svn: 366893
2019-07-24 20:14:56 +08:00
|
|
|
// SelectionTree tries to behave sensibly in the presence of macros, but does
|
|
|
|
// not model any preprocessor concepts: the output is a subset of the AST.
|
[clangd] Ignore semicolons, whitespace, and comments in SelectionTree.
Summary:
Whitespace and comments are a clear bugfix: selecting some
comments/space near a statement doesn't mean you're selecting the
surrounding block.
Semicolons are less obvious, but for similar reasons: these tokens
aren't actually claimed by any AST node (usually), so an AST-based model
like SelectionTree shouldn't take them into account.
Callers may still sometimes care about semis of course:
- when the selection is an expr with a non-expr parent, selection of
the semicolon indicates intent to select the statement.
- when a statement with a trailing semi is selected, we need to know
its range to ensure it can be removed.
SelectionTree may or may not play a role here, but these are separate questions
from its core function of describing which AST nodes were selected.
The mechanism here is the TokenBuffer from syntax-trees. We use it in a
fairly low-level way (just to get boundaries of raw spelled tokens). The
actual mapping of AST nodes to coordinates continues to use the (fairly
mature) SourceLocation based logic. TokenBuffer/Syntax trees
don't currently offer an alternative to getFileRange(), I think.
Reviewers: SureYeaah, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65486
llvm-svn: 367453
2019-08-01 01:52:40 +08:00
|
|
|
//
|
|
|
|
// Comments, directives and whitespace are completely ignored.
|
|
|
|
// Semicolons are also ignored, as the AST generally does not model them well.
|
[clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with other containers.
Summary:
Previously TranslationUnitDecl would never be selected.
This means root() is never null, and returns a reference.
commonAncestor() is in principle never null also, but returning TUDecl
here requires tweaks to be careful not to traverse it (this was already
possible when selecting multiple top-level decls, and there are associated bugs!)
Instead, never allow commonAncestor() to return TUDecl, return null instead.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65101
llvm-svn: 366893
2019-07-24 20:14:56 +08:00
|
|
|
//
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
// The SelectionTree owns the Node structures, but the ASTNode attributes
|
|
|
|
// point back into the AST it was constructed with.
|
|
|
|
class SelectionTree {
|
|
|
|
public:
|
|
|
|
// Creates a selection tree at the given byte offset in the main file.
|
|
|
|
// This is approximately equivalent to a range of one character.
|
|
|
|
// (Usually, the character to the right of Offset, sometimes to the left).
|
[clangd] Ignore semicolons, whitespace, and comments in SelectionTree.
Summary:
Whitespace and comments are a clear bugfix: selecting some
comments/space near a statement doesn't mean you're selecting the
surrounding block.
Semicolons are less obvious, but for similar reasons: these tokens
aren't actually claimed by any AST node (usually), so an AST-based model
like SelectionTree shouldn't take them into account.
Callers may still sometimes care about semis of course:
- when the selection is an expr with a non-expr parent, selection of
the semicolon indicates intent to select the statement.
- when a statement with a trailing semi is selected, we need to know
its range to ensure it can be removed.
SelectionTree may or may not play a role here, but these are separate questions
from its core function of describing which AST nodes were selected.
The mechanism here is the TokenBuffer from syntax-trees. We use it in a
fairly low-level way (just to get boundaries of raw spelled tokens). The
actual mapping of AST nodes to coordinates continues to use the (fairly
mature) SourceLocation based logic. TokenBuffer/Syntax trees
don't currently offer an alternative to getFileRange(), I think.
Reviewers: SureYeaah, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65486
llvm-svn: 367453
2019-08-01 01:52:40 +08:00
|
|
|
SelectionTree(ASTContext &AST, const syntax::TokenBuffer &Tokens,
|
|
|
|
unsigned Offset);
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
// Creates a selection tree for the given range in the main file.
|
|
|
|
// The range includes bytes [Start, End).
|
|
|
|
// If Start == End, uses the same heuristics as SelectionTree(AST, Start).
|
[clangd] Ignore semicolons, whitespace, and comments in SelectionTree.
Summary:
Whitespace and comments are a clear bugfix: selecting some
comments/space near a statement doesn't mean you're selecting the
surrounding block.
Semicolons are less obvious, but for similar reasons: these tokens
aren't actually claimed by any AST node (usually), so an AST-based model
like SelectionTree shouldn't take them into account.
Callers may still sometimes care about semis of course:
- when the selection is an expr with a non-expr parent, selection of
the semicolon indicates intent to select the statement.
- when a statement with a trailing semi is selected, we need to know
its range to ensure it can be removed.
SelectionTree may or may not play a role here, but these are separate questions
from its core function of describing which AST nodes were selected.
The mechanism here is the TokenBuffer from syntax-trees. We use it in a
fairly low-level way (just to get boundaries of raw spelled tokens). The
actual mapping of AST nodes to coordinates continues to use the (fairly
mature) SourceLocation based logic. TokenBuffer/Syntax trees
don't currently offer an alternative to getFileRange(), I think.
Reviewers: SureYeaah, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65486
llvm-svn: 367453
2019-08-01 01:52:40 +08:00
|
|
|
SelectionTree(ASTContext &AST, const syntax::TokenBuffer &Tokens,
|
|
|
|
unsigned Start, unsigned End);
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
|
|
|
|
// Describes to what extent an AST node is covered by the selection.
|
|
|
|
enum Selection {
|
|
|
|
// The AST node owns no characters covered by the selection.
|
|
|
|
// Note that characters owned by children don't count:
|
|
|
|
// if (x == 0) scream();
|
|
|
|
// ^^^^^^
|
|
|
|
// The IfStmt would be Unselected because all the selected characters are
|
|
|
|
// associated with its children.
|
|
|
|
// (Invisible nodes like ImplicitCastExpr are always unselected).
|
|
|
|
Unselected,
|
|
|
|
// The AST node owns selected characters, but is not completely covered.
|
|
|
|
Partial,
|
|
|
|
// The AST node owns characters, and is covered by the selection.
|
|
|
|
Complete,
|
|
|
|
};
|
|
|
|
// An AST node that is implicated in the selection.
|
|
|
|
// (Either selected directly, or some descendant is selected).
|
|
|
|
struct Node {
|
|
|
|
// The parent within the selection tree. nullptr for TranslationUnitDecl.
|
|
|
|
Node *Parent;
|
|
|
|
// Direct children within the selection tree.
|
|
|
|
llvm::SmallVector<const Node *, 8> Children;
|
|
|
|
// The corresponding node from the full AST.
|
|
|
|
ast_type_traits::DynTypedNode ASTNode;
|
|
|
|
// The extent to which this node is covered by the selection.
|
|
|
|
Selection Selected;
|
2019-07-12 00:04:18 +08:00
|
|
|
// Walk up the AST to get the DeclContext of this Node,
|
|
|
|
// which is not the node itself.
|
|
|
|
const DeclContext& getDeclContext() const;
|
2019-07-24 17:39:11 +08:00
|
|
|
// Printable node kind, like "CXXRecordDecl" or "AutoTypeLoc".
|
|
|
|
std::string kind() const;
|
2019-07-26 23:29:52 +08:00
|
|
|
// If this node is a wrapper with no syntax (e.g. implicit cast), return
|
|
|
|
// its contents. (If multiple wrappers are present, unwraps all of them).
|
|
|
|
const Node& ignoreImplicit() const;
|
2019-08-10 07:40:54 +08:00
|
|
|
// If this node is inside a wrapper with no syntax (e.g. implicit cast),
|
|
|
|
// return that wrapper. (If multiple are present, unwraps all of them).
|
|
|
|
const Node& outerImplicit() const;
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
};
|
|
|
|
// The most specific common ancestor of all the selected nodes.
|
[clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with other containers.
Summary:
Previously TranslationUnitDecl would never be selected.
This means root() is never null, and returns a reference.
commonAncestor() is in principle never null also, but returning TUDecl
here requires tweaks to be careful not to traverse it (this was already
possible when selecting multiple top-level decls, and there are associated bugs!)
Instead, never allow commonAncestor() to return TUDecl, return null instead.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65101
llvm-svn: 366893
2019-07-24 20:14:56 +08:00
|
|
|
// Returns nullptr if the common ancestor is the root.
|
|
|
|
// (This is to avoid accidentally traversing the TUDecl and thus preamble).
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
const Node *commonAncestor() const;
|
|
|
|
// The selection node corresponding to TranslationUnitDecl.
|
[clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with other containers.
Summary:
Previously TranslationUnitDecl would never be selected.
This means root() is never null, and returns a reference.
commonAncestor() is in principle never null also, but returning TUDecl
here requires tweaks to be careful not to traverse it (this was already
possible when selecting multiple top-level decls, and there are associated bugs!)
Instead, never allow commonAncestor() to return TUDecl, return null instead.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65101
llvm-svn: 366893
2019-07-24 20:14:56 +08:00
|
|
|
const Node &root() const { return *Root; }
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::deque<Node> Nodes; // Stable-pointer storage.
|
|
|
|
const Node *Root;
|
|
|
|
clang::PrintingPolicy PrintPolicy;
|
|
|
|
|
|
|
|
void print(llvm::raw_ostream &OS, const Node &N, int Indent) const;
|
|
|
|
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
|
|
|
|
const SelectionTree &T) {
|
[clangd] SelectionTree treats TranslationUnitDecl (mostly) consistently with other containers.
Summary:
Previously TranslationUnitDecl would never be selected.
This means root() is never null, and returns a reference.
commonAncestor() is in principle never null also, but returning TUDecl
here requires tweaks to be careful not to traverse it (this was already
possible when selecting multiple top-level decls, and there are associated bugs!)
Instead, never allow commonAncestor() to return TUDecl, return null instead.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65101
llvm-svn: 366893
2019-07-24 20:14:56 +08:00
|
|
|
T.print(OS, T.root(), 1);
|
[clangd] Lib to compute and represent selection under cursor.
Summary:
The primary problem this solves is to expose the codeAction selection to
AST-based refactorings in a way that makes it easy and efficient for them to
bind to the right parts of the AST.
It should also allow us to make XRefs based features (textDocument/definition)
more robust, more easily implement textDocument/typeDefinition etc.
As an example, template parameter references can be identified without special
handling.
There should be slight speedup too: we can prune most of the AST traversal
in most cases.
Elephant in the room: this is similar-but-different to Tooling/Refactoring/ASTSelection.
That captures a smaller set of AST nodes, has a slightly different way of
representing selections, and generally has mare features and does more work.
The overall shape is pretty similar, and yet I can't quite get to behave as I
expect.
Reviewers: ilya-biryukov, kadircet
Subscribers: mgorny, ioeric, MaskRay, jkorous, mgrang, arphaman
Tags: #clang
Differential Revision: https://reviews.llvm.org/D57562
llvm-svn: 352874
2019-02-01 23:05:11 +08:00
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace clangd
|
|
|
|
} // namespace clang
|
|
|
|
#endif
|