Skip to content
  1. Jul 18, 2019
  2. Jul 15, 2019
  3. Jul 11, 2019
  4. Jul 10, 2019
  5. Jul 04, 2019
  6. Jun 10, 2019
    • Sam McCall's avatar
      [clangd] Revamp textDocument/onTypeFormatting. · 25c6257b
      Sam McCall authored
      Summary:
      The existing implementation (which triggers on }) is fairly simple and
      has flaws:
       - doesn't trigger frequently/regularly enough (particularly in editors that type the }
       for you)
       - often reformats too much code around the edit
       - has jarring cases that I don't have clear ideas for fixing
      
      This implementation is designed to trigger on newline, which feels to me more
      intuitive than } or ;.
      It does have allow for reformatting after other characters - it has a
      basic behavior and a model for adding specialized behavior for
      particular characters. But at least initially I'd stick to advertising
      \n in the capabilities.
      
      This also handles comment splitting: when you insert a line break inside
      a line comment, it will make the new line into an aligned line comment.
      
      Working on tests, but want people to patch it in and try it - it's hard to
      see if "feel" is right purely by looking at a test.
      
      Reviewers: ilya-biryukov, hokein
      
      Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D60605
      
      llvm-svn: 362939
      25c6257b
  7. Apr 29, 2019
    • Sam McCall's avatar
      [clangd] Move clangd tests to clangd directory. check-clangd is no longer part... · b804eef0
      Sam McCall authored
      [clangd] Move clangd tests to clangd directory. check-clangd is no longer part of check-clang-tools.
      
      Summary:
      Motivation:
       - this layout is a pain to work with
       - without a common root, it's painful to express things like "disable clangd" (D61122)
       - CMake/lit configs are a maintenance hazard, and the more the one-off hacks
         for various tools are entangled, the more we see apathy and non-ownership.
      
      This attempts to use the bare-minimum configuration needed (while still
      supporting the difficult cases: windows, standalone clang build, dynamic libs).
      In particular the lit.cfg.py and lit.site.cfg.py.in are merged into lit.cfg.in.
      The logic in these files is now minimal.
      
      (Much of clang-tools-extra's lit configs can probably be cleaned up by reusing
      lit.llvm.llvm_config.use_clang(), and every llvm project does its own version of
      LDPATH mangling. I haven't attempted to fix any of those).
      
      Docs are still in clang-tools-extra/docs, I don't have any plans to touch those.
      
      Reviewers: gribozavr
      
      Subscribers: mgorny, javed.absar, MaskRay, jkorous, arphaman, kadircet, jfb, cfe-commits, ilya-biryukov, thakis
      
      Tags: #clang
      
      Differential Revision: https://reviews.llvm.org/D61187
      
      llvm-svn: 359424
      b804eef0
  8. Mar 19, 2019
  9. Feb 01, 2019
    • Sam McCall's avatar
      [clangd] Implement textDocument/declaration from LSP 3.14 · 866ba2c9
      Sam McCall authored
      Summary:
      LSP now reflects the declaration/definition distinction.
      
      Language server changes:
       - textDocument/definition now returns a definition if one is found, otherwise
         the declaration. It no longer returns declaration + definition if they are
         distinct.
       - textDocument/declaration returns the best declaration we can find.
       - For macros, the active macro definition is returned for both methods.
       - For include directive, the top of the target file is returned for both.
      There doesn't appear to be a discovery mechanism (we can't return everything to
      clients that only know about definition), so this changes existing behavior.
      In practice, it should greatly reduce the fraction of the time we need to show
      the user a menu of options.
      
      C++ API changes:
       - findDefinitions is replaced by locateSymbolAt, which returns a
         vector<LocatedSymbol> - one for each symbol under the cursor.
       - this contains the preferred declaration, the definition (if found), and
         the symbol name
      This API enables some potentially-neat extensions, like swapping between decl
      and def, and exposing the symbol name to the UI in the case of multiple symbols.
      
      Reviewers: hokein
      
      Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D57388
      
      llvm-svn: 352864
      866ba2c9
  10. Jan 29, 2019
    • Ilya Biryukov's avatar
      [clangd] Interfaces for writing code tweaks · cce67a32
      Ilya Biryukov authored
      Summary:
      The code tweaks are an implementation of mini-refactorings exposed
      via the LSP code actions. They run in two stages:
        - Stage 1. Decides whether the action is available to the user and
          collects all the information required to finish the action.
          Should be cheap, since this will run over all the actions known to
          clangd on each textDocument/codeAction request from the client.
      
        - Stage 2. Uses information from stage 1 to produce the actual edits
          that the code action should perform. This stage can be expensive and
          will only run if the user chooses to perform the specified action in
          the UI.
      
      One unfortunate consequence of this change is increased latency of
      processing the textDocument/codeAction requests, which now wait for an
      AST. However, we cannot avoid this with what we have available in the LSP
      today.
      
      Reviewers: kadircet, ioeric, hokein, sammccall
      
      Reviewed By: sammccall
      
      Subscribers: mgrang, mgorny, MaskRay, jkorous, arphaman, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D56267
      
      llvm-svn: 352494
      cce67a32
  11. Sep 05, 2018
  12. Aug 15, 2018
  13. Jul 05, 2018
  14. May 15, 2018
  15. Apr 23, 2018
    • Marc-Andre Laperle's avatar
      [clangd] Implementation of workspace/symbol request · b387b6e6
      Marc-Andre Laperle authored
      Summary:
      This is a basic implementation of the "workspace/symbol" request which is
      used to find symbols by a string query. Since this is similar to code completion
      in terms of result, this implementation reuses the "fuzzyFind" in order to get
      matches. For now, the scoring algorithm is the same as code completion and
      improvements could be done in the future.
      
      The index model doesn't contain quite enough symbols for this to cover
      common symbols like methods, enum class enumerators, functions in unamed
      namespaces, etc. The index model will be augmented separately to achieve this.
      
      Reviewers: sammccall, ilya-biryukov
      
      Reviewed By: sammccall
      
      Subscribers: jkorous, hokein, simark, sammccall, klimek, mgorny, ilya-biryukov, mgrang, jkorous-apple, ioeric, MaskRay, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D44882
      
      llvm-svn: 330637
      b387b6e6
  16. Mar 26, 2018
    • Simon Marchi's avatar
      [clangd] Support incremental document syncing · 9808262e
      Simon Marchi authored
      
      
      Summary:
      This patch adds support for incremental document syncing, as described
      in the LSP spec.  The protocol specifies ranges in terms of Position (a
      line and a character), and our drafts are stored as plain strings.  So I
      see two things that may not be super efficient for very large files:
      
      - Converting a Position to an offset (the positionToOffset function)
        requires searching for end of lines until we reach the desired line.
      - When we update a range, we construct a new string, which implies
        copying the whole document.
      
      However, for the typical size of a C++ document and the frequency of
      update (at which a user types), it may not be an issue.  This patch aims
      at getting the basic feature in, and we can always improve it later if
      we find it's too slow.
      
      Signed-off-by: default avatarSimon Marchi <simon.marchi@ericsson.com>
      
      Reviewers: malaperle, ilya-biryukov
      
      Reviewed By: ilya-biryukov
      
      Subscribers: MaskRay, klimek, mgorny, ilya-biryukov, jkorous-apple, ioeric, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D44272
      
      llvm-svn: 328500
      9808262e
  17. Feb 28, 2018
  18. Feb 16, 2018
    • Marc-Andre Laperle's avatar
      [clangd] Implement textDocument/hover · 3e618ed8
      Marc-Andre Laperle authored
      Summary: Implemention of textDocument/hover as described in LSP definition.
      
      This patch adds a basic Hover implementation.  When hovering a variable,
      function, method or namespace, clangd will return a text containing the
      declaration's scope, as well as the declaration of the hovered entity.
      For example, for a variable:
      
        Declared in class Foo::Bar
      
        int hello = 2
      
      For macros, the macro definition is returned.
      
      This patch doesn't include:
      
      - markdown support (the client I use doesn't support it yet)
      - range support (optional in the Hover response)
      - comments associated to variables/functions/classes
      
      They are kept as future work to keep this patch simpler.
      
      I added tests in XRefsTests.cpp.  hover.test contains one simple
      smoketest to make sure the feature works from a black box perspective.
      
      Reviewers: malaperle, krasimir, bkramer, ilya-biryukov
      
      Subscribers: sammccall, mgrang, klimek, rwols, ilya-biryukov, arphaman, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D35894
      
      
      
      Signed-off-by: default avatarSimon Marchi <simon.marchi@ericsson.com>
      Signed-off-by: default avatarWilliam Enright <william.enright@polymtl.ca>
      llvm-svn: 325395
      3e618ed8
    • Eric Liu's avatar
      [clangd] collect symbol #include & insert #include in global code completion. · c5105f9e
      Eric Liu authored
      Summary:
      o Collect suitable #include paths for index symbols. This also does smart mapping
      for STL symbols and IWYU pragma (code borrowed from include-fixer).
      o For global code completion, add a command for inserting new #include in each code
      completion item.
      
      Reviewers: sammccall
      
      Reviewed By: sammccall
      
      Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, hintonda, cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D42640
      
      llvm-svn: 325343
      c5105f9e
  19. Feb 06, 2018
  20. Dec 12, 2017
    • Ilya Biryukov's avatar
      [clangd] Document highlights for clangd · 0e6a51f4
      Ilya Biryukov authored
      Summary: Implementation of Document Highlights Request as described in
      LSP.
      
      Contributed by William Enright (nebiroth).
      
      Reviewers: malaperle, krasimir, bkramer, ilya-biryukov
      
      Reviewed By: malaperle
      
      Subscribers: mgrang, sammccall, klimek, ioeric, rwols, cfe-commits, arphaman, ilya-biryukov
      
      Differential Revision: https://reviews.llvm.org/D38425
      
      llvm-svn: 320474
      0e6a51f4
  21. Nov 09, 2017
    • Haojian Wu's avatar
      [clangd] Add rename support. · 345099ca
      Haojian Wu authored
      Summary:
      Make clangd handle "textDocument/rename" request. The rename
      functionality comes from the "local-rename" sub-tool of clang-refactor.
      
      Currently clangd only supports local rename (only symbol occurrences in
      the main file will be renamed).
      
      Reviewers: sammccall, ilya-biryukov
      
      Reviewed By: sammccall
      
      Subscribers: cfe-commits, ioeric, arphaman, mgorny
      
      Differential Revision: https://reviews.llvm.org/D39676
      
      llvm-svn: 317780
      345099ca
  22. Nov 07, 2017
  23. Nov 06, 2017
    • Sam McCall's avatar
      Adds a json::Expr type to represent intermediate JSON expressions. · dd0566bb
      Sam McCall authored
      Summary:
      This form can be created with a nice clang-format-friendly literal syntax,
      and gets escaping right. It knows how to call unparse() on our Protocol types.
      All the places where we pass around JSON internally now use this type.
      
      Object properties are sorted (stored as std::map) and so serialization is
      canonicalized, with optional prettyprinting (triggered by a -pretty flag).
      This makes the lit tests much nicer to read and somewhat nicer to debug.
      (Unfortunately the completion tests use CHECK-DAG, which only has
      line-granularity, so pretty-printing is disabled there. In future we
      could make completion ordering deterministic, or switch to unittests).
      
      Compared to the current approach, it has some efficiencies like avoiding copies
      of string literals used as object keys, but is probably slower overall.
      I think the code/test quality benefits are worth it.
      
      This patch doesn't attempt to do anything about JSON *parsing*.
      It takes direction from the proposal in this doc[1], but is limited in scope
      and visibility, for now.
      I am of half a mind just to use Expr as the target of a parser, and maybe do a
      little string deduplication, but not bother with clever memory allocation.
      That would be simple, and fast enough for clangd...
      [1] https://docs.google.com/document/d/1OEF9IauWwNuSigZzvvbjc1cVS1uGHRyGTXaoy3DjqM4/edit
      
      +cc d0k so he can tell me not to use std::map.
      
      Reviewers: ioeric, malaperle
      
      Subscribers: bkramer, ilya-biryukov, mgorny, klimek
      
      Differential Revision: https://reviews.llvm.org/D39435
      
      llvm-svn: 317486
      dd0566bb
  24. Nov 03, 2017
    • Marc-Andre Laperle's avatar
      [clangd] Handle clangd.applyFix server-side · e7ec16aa
      Marc-Andre Laperle authored
      Summary:
      When the user selects a fix-it (or any code action with commands), it is
      possible to let the client forward the selected command to the server.
      When the clangd.applyFix command is handled on the server, it can send a
      workspace/applyEdit request to the client. This has the advantage that
      the client doesn't explicitly have to know how to handle
      clangd.applyFix. Therefore, the code to handle clangd.applyFix in the VS
      Code extension (and any other Clangd client) is not required anymore.
      
      Reviewers: ilya-biryukov, sammccall, Nebiroth, hokein
      
      Reviewed By: hokein
      
      Subscribers: ioeric, hokein, rwols, puremourning, bkramer, ilya-biryukov
      
      Tags: #clang-tools-extra
      
      Differential Revision: https://reviews.llvm.org/D39276
      
      llvm-svn: 317322
      e7ec16aa
  25. Oct 25, 2017
    • Ilya Biryukov's avatar
      [clangd] Handle exit notification (proper shutdown) · 0d9b8a3e
      Ilya Biryukov authored
      Summary:
      This changes the onShutdown handler to do essentially nothing (for now), and
      instead exits the runloop when we receive the exit notification from the client.
      
      Some clients may wait on the reply from the shutdown request before sending an
      exit notification. If we exit the runloop already in the shutdown request, a
      client might block forever.
      
      This also gives us the opportunity to do any global cleanups and/or
      serializations of PCH preambles to disk, but I've left that out for now.
      
      See the LSP protocol documentation for details.
      
      Reviewers: malaperle, krasimir, bkramer, sammccall, ilya-biryukov
      
      Reviewed By: malaperle, sammccall, ilya-biryukov
      
      Subscribers: cfe-commits
      
      Differential Revision: https://reviews.llvm.org/D38939
      
      llvm-svn: 316564
      0d9b8a3e
  26. Oct 06, 2017
  27. Sep 27, 2017
    • Marc-Andre Laperle's avatar
      [clangd] Handle InitializeParams and store rootUri · 37de9718
      Marc-Andre Laperle authored
      Summary:
      The root Uri is the workspace location and will be useful in the context of
      indexing. We could also add more things to InitializeParams in order to
      configure Clangd for C/C++ sepecific extensions.
      
      Reviewers: ilya-biryukov, bkramer, krasimir, Nebiroth
      
      Reviewed By: ilya-biryukov
      
      Subscribers: ilya-biryukov
      
      Tags: #clang-tools-extra
      
      Differential Revision: https://reviews.llvm.org/D38093
      
      llvm-svn: 314309
      37de9718
Loading