Giter VIP home page Giter VIP logo

vscode-cmantic's Introduction

vscode-cmantic's People

Contributors

bigbahss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vscode-cmantic's Issues

C++ code is not detected.

I'm using PlatformIO which uses .cpp and .h files
I click in a .h file, select a field invoke c-mantic generate getters and setters and I get "Detected language is not C++, cannot create
image
a member"

It should work, it's C++.

Thank you,
Adrian

Macros can affect parsing

This probably goes without saying, but I thought I would formalize this with an issue (maybe someone can offer ideas). Certain 'disruptive' macros can affect C-mantic's parsing. The language server does a lot of the heavy-lifting, but C-mantic still has to do some parsing of it's own.

Examples of disruptive macros would be ones that insert keywords, such as public or override. In these cases, C-mantic might fail to place a new member function in public-access will insert a redundant public: before a new member function, or fail to remove override when creating a function definition. This problem is solvable by having C-mantic resolve the definitions of macros. But, this is sub-optimal because it would require resolving every identifier that is not defined in the language, which goes against the idea of "Don't pay for what you don't use".

It's possible that this is not a significant problem (in the examples I gave it's more of a mild inconvenience if anything). If you find this to be a problem, up-vote this or post a comment.

Create matching header/source if not found

Right now if I use the "switch header/source in workspace" command and no matching header was found, then the extension will helpfully throw an error saying "no matching header/source found".

It would be better if there was an option to create the missing header or source file and switching to that instead.

Open header/source to the side

A nice addition to the 'Switch Header/Source in Workspace' command would be to optionally open the matching header/source file in a new editor column, next to the current file.

[Feature Request] CopyConstructor / assigment operator

Hi,

first of all, thank you for your extension.

I have two suggestions for new features :

Given a class like that :

class Test 
{
  public:
  Test( void );
  Test( const Test & src );
  ~Test( void );

  Test & operator=( const Test & src );

  private: 

  std::string _value;
  std::string _value2;
};

It would be nice to have possibility to create definition for copy constructor and operator= :

Test::Test( const Test& src )
    : _value( src._value ),
      _value2( src._value2 )
{
}

And :

Test& Test::operator=( const Test& src )
{
  if ( this != &src )
  {
    _value  = src._value;
    _value2 = src._value2;
  }

  return *this;
}

These operations are frequently error prone (missing argument, wrong initialization) and may be encountered frequently in old project (prior to C++11).

Yours.

Improving the locality of Switch Source/Header.

Most of C++ projects either have the Cpp/header files in the same directory or in a separate src*/inc* folders in the same parent directory.

I suggest altering the searching techniques to first the parent directory, then the whole workspace folders if not found.
This will boost the search especially in remotely edited workspaces. ( Our projects are on linux servers in HQ, while we access remotely via VPN - due to COVID).

'Add Definition' sometimes doesn't reveal the function

The 'Add Definition' commands sometimes don't properly reveal the inserted function (The editor doesn't scroll all the way to where the function was inserted). This seems to only happen for large files with a lot of DocumentSymbols, and it is unclear why. I've spent a good amount of time trying to debug and fix this problem, and it doesn't seem to be a problem in the C-mantic code. The Range passed to TextEditor.revealRange() is always correct, but the editor doesn't always scroll to that range. The editor does scroll in the direction of the function, but only a little bit. I haven't found consistent setup to reproduce the problem, other than that it only happens for large files. Also, this happens for ms-vscode.cpptools, clangd, and ccls, so it doesn't seem to be a problem with the language server. I'm considering opening an issue with vscode. If I do I'll link it here.

Availability in gitpod - not registered at open-vsx.org

Hi there!

I'm investigating using your plugin for improved productivity in C++ in a cloud environment - gitpod.io.

However, gitpod only supports extensions that are uploaded to the openvsx registry [1] [2].

Do you have any plans on adding this extension to Open VSX Registry? [3]

Cheers!

Links

1 OpenVSX registry - https://open-vsx.org/
2 GitPod FAQ on VS Code Extension support - https://www.gitpod.io/docs/references/ides-and-editors/vscode-extensions#where-do-i-find-extensions
3 How to register at OpenVSX - https://github.com/eclipse/openvsx/wiki/Publishing-Extensions

Generate Getter/Setter performance regression

I've noticed a regression in the amount of time it takes to generate getters and setters (even with C_mantic.cpp.resolveTypes disabled). It used to be very quick, and now it seems to hang for a couple seconds (sometimes more) before they are generated. I'm not sure what could be causing this, since it's the only feature that is having this problem. This "slowness" is also independent of the language server, so it must be something in the C-mantic code (In general, clangd is much faster than cpptools, which is usually a good indication of whether a problem exists with C-mantic or the language server. This is not the case here).

For reference, the GIF in the README was real-time performance of generating a getter and setter, and that was with C_mantic.cpp.resolveTypes enabled. Trying it on the same code now takes 2-3 seconds on my machine. With C_mantic.cpp.resolveTypes disabled it's about 1-2 seconds, still noticeably slower.

[BUG] Update function declaration doesn't follow `using` declarations.

\\ .cpp file
namespace NamespaceA {
  using NamespaceB::RetType;
  RetType ClassA::func() {
    ...
  }
}

\\ .hpp file
namespace NamespaceA {
  class ClassA {
  public:
    NamespaceB::RetType func();
  }
}

If I want to update the function declaration from the .cpp PoV then it will remove NamespaceB, but it will be incorrect from header file PoV.

Problems with overloaded functions on cpptools

C-mantic experiences some problems with overloaded functions when using cpptools. This is a result of how cpptools provides definitions for overloaded functions. For instance, say you have an overload set of 4 functions, 1 of which is already defined, the others are not. If you try 'Go to Definition' on any of the undefined declarations, cpptools will go to the overload that is defined (which is not the same function). This affects C-mantic, as you will not be able to use 'Add Definition' on any of the undefined functions, since it thinks a definitions already exists (since cpptools is incorrectly providing a definition for it). I'm not sure what the best way to handle this is, besides getting cpptools to change this behavior, because frankly, it's the job of the language server to understand overloads and know that one function is different from another.

[Bug] If I use the terminal after installing the extension, CPU usage increases abnormally.

Hello. I am a Korean developer who loves programming. After installing the extension cmantic, if i compile using gcc/g++ in the terminal, rg.exe runs infinitely and uses the cpu abnormally. To be honest, I'm not sure which extension conflicts with this problem, but below are extensions related to C/C++ that I use.

C snippets
C/C++ Extension Pack
C/C++
CMake
CMake Tools
C-mantic (here)

I hope this gets resolved and I'm wondering if anyone else has the same problems as me.
This is article that i wrote about problem
https://pgh268400.tistory.com/551

Add missing members to the initializer list

This would be a very neat feature. Add a member, forget it in an initializer list and get an option to add it, no more going through the list and find the one that is missing.

Not sure how everyone is doing the formatting, we use clang-format on save, so just pasting it anywhere in the list would be fine as it would get moved accordingly on save.

Add completion suggestions for 'Add Include'

It would be nice to add completion suggestions for the 'Add Include' command. Although, this doesn't seem straightforward with the current implementation that uses the input box.

One idea is that 'Add Include' could open a small CodeLens to the spot where the new include would be added, in which case auto-completions would be provided automatically by other extensions. I think I like this idea, except in order to place includes based on if they are a system header (#include <...>) or a project header (#include "...") it would probably require 2 different commands in order to automatically place the starting #include prompt in the right spot. I'm not a big fan of requiring 2 different commands since it seems a little clunky, but (counterintuitively) this might be mitigated by having a third command that just goes to the end largest block of includes, not caring if they are system or project headers.

Also, I have no experience with the CodeLens api, so I don't know how easy this would be. Suggestions on how to implement this are welcome.

Whitespace alignment for 'Add Definition'

It seems like 'Add Definition' has had a regression of how it adjusts whitespace alignment for multi-lined declarations. In particular, when it removes leading keywords (like virtual, static, etc.), the definition in will no longer be aligned properly.

Weird double lines when using CRLF line endings

When using \r\n line endings, a lot of excess lines appear.
It turns out, that there is a bug in the formatting function, adding \t in between and after \r\n line endings.
This results in vscode replacing \r and \n into \r\n respectivly, so the total replacement will be \r\n\t\r\n\t instead of \r\n\t
I have created a pull-request, as a proposal to fix this issue.

100% of all cpu cores

Type: Bug

open c++ file

Extension version: 0.9.0
VS Code version: Code 1.87.2 (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:14:59.643Z)
OS version: Linux x64 5.4.0-144-generic
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz (4 x 2999)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 5, 5, 6
Memory (System) 7.47GB (3.63GB free)
Process Argv . --crash-reporter-id c0a30e7b-e08e-4e61-93bf-39b3792e40bf
Screen Reader no
VM 0%
DESKTOP_SESSION cinnamon
XDG_CURRENT_DESKTOP X-Cinnamon
XDG_SESSION_DESKTOP cinnamon
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
ccp2r3:30993541
dsvsc020:30976470
pythonait:31006305
gee8j676:31009558
dsvsc021:30996838
gd77d436:30999572

Getter/setter customization

It would be very useful if alternative naming styles would be supported. Currently the extension always uses getSomething and setSomething, but other styles are used as well, for instance get_something/set_something.

Raw string literals

Currently, C-mantic does not account for raw string literals. This might impact parsing if they are present, and support should be added for them.

"Add definition in xxx.cpp" doesn't work for template functions

There is a file1.cpp and a file1.h in my workspace.
For normal function, it works fine as follows:

1659156326890.mp4

But the plugin only provides Add definition in this file for the template function:

1659156445281.mp4

The c++ intellisense plugin I used was clangd.

Thanks for your efforts.

Pragma block for selected statements

How about the ability to add a suppression pragmas around selected rows?

  1. Select some rows
  2. Hit the suppress shortcut
  3. Tool generates the correct #pragma for compiler leaving the user with the cursor where to write the warning to suppress
  4. User enters the warning

If current row is already in a block a new suppression is added and we go to point 4

No language server detected after 30 seconds.

Hi,

Using with the default Microsoft C++ extension; I think cpptools is installed and working properly (1.19.9), I can see the process in top - but all I see in the logs output from C-mantic is the below:

[18:00:48  Info] C-mantic extension activated.
[18:01:19  Warn] No language server detected after 30 seconds.

Anything I can do to find out more? Would it also be possible to log more when the server isn't detected?

Thanks!

'Move Definition' doesn't account for changes in scope

Currently, 'Move Definition' is basically a copy-and-paste after smart-placement is determined. It does not account for changes in scope at the target position. For instance, if the definition exists within a namespace block, and the target position is not within that same namespace, the definition will be lacking scope-resolution.
For instance:

namespace foo {
    int bar() {
        return 42;
    }
}

If bar is moved to a position that is not within namespace foo, the definition should become:

int foo::bar() {
    return 42;
}

This is something I did not account for when I created the command, and it is being worked on. This will probably be fixed in the next feature release which will add moving a definition into/out of a class body (which also needs to account for the same thing, but with the class name).

'Add definition in this file' should not always add 'inline' when declaration is in CPP

'Add definition in this file' always add the 'inline' keyword.

For header declarations, where the definition will be placed also in the header, this is correct.
But if the declaration is in the implementation file, it is not required.

In general, it would be nice to add an option to not adding the inline keyword if the declaration does not contain 'inline', so we can control if it should be generated or not.

By the way, great tool! vscode absolutely needed something like this!

Better handling of templates

Currently, C-mantic's template support is incomplete. For instance, adding definitions for member functions of a class template will generate incorrect code. The definitions will be missing the template statement, and the scope resolution will be missing the template parameter(s). Additionally, 'Add Definition' should not allow adding definitions in source files for function templates (I've realized that the 'add_definition.gif' in the readme does this, which is more embarrassing than anything).

Add setting to customize getter/setter prefix

Right now the getters and setters are generated with names like foo and setFoo, respectively.

My workplace requires the "get" prefix, so it would be nice to be able to generate getters with names like getFoo.

Allow adding header guard relative to repo

As a feature request, it would be helpful if the Header Guard format could also have variables for the path relative to its source git (or other source control repo) repo. So something like ${REPO_REL_PATH}. Thanks!

Turn off suggested refactorings (light-bulb menu)

I can imagine that some users might want to turn off the light-bulb menu for C-mantic, because it might be annoying. Of course, the light-bulb menu can be turned off entirely in VS Code's settings, but this affects all extensions and might not be what the user is looking for.

VS Code's API does not appear to offer extensions a way to provide refactorings without them being auto-suggested in the light-bulb menu. Ideally, the user could control whether refactorings are suggested, while still being available in the Refactor... menu either way. It seems like the best that could be done would to to disable refactorings entirely for users that just want to use the commands directly.

A potential workaround I can think of would be to change provided refactorings into source actions, which would then be available in the Source Actions... menu and would not be suggested in the light-bulb menu. That feels kind of messy though. Maybe this is a non-issue though, and users that want to disable refactorings wouldn't care if they are also removed from the Refactor... menu.

Add case statements for enumeration in switch

I'd love to see a feature which generates all cases for a switch statement for all enumeration values.

So if you have:

enum class IicChannel
{
    Iic1,
    Iic2,
    Iic3
};

And write something along the lines of:

IicChannel channel = GetChannel();
switch (channel)
{

}

Have a hint to generate all case statements like:

switch (channel)
{
case IicChannel::Iic1:
    /* code */
    break;
case IicChannel::Iic2:
    /* code */
    break;
case IicChannel::Iic3:
    /* code */
    break;
default:
    break;
}

This would be awesome, I used that feature on ReSharper a lot. Not sure if the parsing you are doing is extensive enough to be able to do this.

'Add Definition' on a constructor not working for ccls

I was testing on ccls and I noticed that Add Definition isn't working for constructors. The reason is that when invoking Go to Definition on an undefined constructor, ccls goes to the name of the class itself. I'm thinking this must be a regression in ccls, because I'm 99% sure I've tested this before and it was working.

Getter/setter customization

I found #11, but it does not work for me.
my code is like this:
class WatchData {
public:
std::string GetSubscribeName() const { return SubscribeName; }
void SetSubscribeName(const std::string &subscribeName) {
mSubscribeName = subscribeName;
}

private:
std::string mSubscribeName;
};

however, when use the plugin, i cannot generate code above.
Is there any way to generate code for customization

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.