GithubHelp home page GithubHelp logo

vsc-cpp-folding's Introduction

Development Requirements

  • node.js
  • git
  • python2?

Development Notes

node-gyp rebuild needs to be run to compile the native code. This isn't directly available at the command line by default. So either npm install to indirectly trigger it to or npm install -g node-gyp to install it for direct use.
https://nodejs.org/dist/latest/docs/api/addons.html#addons_building https://github.com/nodejs/node-addon-api

I haven't taken the time to figure out how to debug native extensions directly.
https://medium.com/@atulanand94/debugging-nodejs-c-addons-using-vs-code-27e9940fc3ad

Publishing an extension:

  • npm install -g vsce
  • vsce package
  • code --install-extension path/to/ext.vsix

https://code.visualstudio.com/api/working-with-extensions/publishing-extension

Current State

Folding is in good working condition. Folding is determined entirely from tokens rather than from the AST. LibClang gives up building the AST when an unknown symbol is encountered (the symbol and its lexical children will be skipped and the parent scope will appear as a CompoundStmt). I haven't tested LibTooling to see what it does because the current solution appears to be very nearly as good as using the AST anyway.

Blocks are folded using curly braces, block comments, and preprocessor blocks (#if and friends). Care is taken to fold the braces up onto the preceding line they are associated with (e.g. the function declaration, for keyword, etc). With closing braces it feels better to leave the brace exposed. This means most things fold into two lines: one with keyword/declaration and a trailing '...' and one with the closing brace '}'. I couldn't find compelling enough cases to justify folding things like function and template parameters (when spread across multiple lines). There might be room to do a token-AST hybrid approach (when the AST is actually available) where function calls that span multiple lines are folded, but that would introduce quite a lot of complexity and it just doesn't feel worth it.

Currently #defines do not fold. This should be reasonably straight forward, I just haven't gotten around to it.

To Do

  • Get LibTooling working and evaluate its capabilities
  • Set folding range kind
  • Consider folding #defines
  • Ensure errors propagate somewhere visible
  • Reduce the final vsix size
  • Avoid copying file contents into a std::string (get the underlying v8 string)
  • Avoid copying errors to an intermediate buffer
  • Test performance
  • Consider avoiding re-parsing when files have not changed

vsc-cpp-folding's People

Contributors

akbyrd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.