[Github-comments] [geany/geany] Enable local variable and function parameter tag reporting for C/C++ (PR #3175)

elextr notifications at github.com
Sun Apr 24 01:55:07 UTC 2022


Have tried this, and first impressions its a big improvement on previously.

> On the one hand I don't think it's so common to have a variable declared after its use 

As I said above, its allowed and somewhat common in C++ inside class declarations.

Since types must be declared before use, members that use public types need to go after that definition, and if the type is public and the data member private its a common idiom to put those data members in one private section at the end of the class declaration rather than swapping back and forth all the time.  

That means that public constructors and inline functions use the variable name before it is declared as in the example below (with comments about how well autocomplete works in various contexts).

```
class Foo {
public:
	Foo():iiiii(1){}     // autocompletes iiiii correctly
	void f(){
		int pit;
		iiiii = 2;       // autocompletes iiiii correctly
		if(p){           // autocompletes p first but with lots of C library crap
			p->i = p->j; // autocompletes ->i and j correctly
		}
		pit = 1;         // autocompletes with ctrl space after p 
		                 // but with pid_t before pit in list
	}
	struct Bar {
		int i, j;
	};
	int operator ()(){   // autocompletes operator
		return iiiii;    // autocompletes iiiii when ctrl space after just i
	                     // but with i, id, id_t before iiiii in list
	} 
	~Foo(){delete p;}
private:
	int iiiii;
	Bar *p;
};

main(){
	Foo* p;
	p->f(); // autocompletes p but with Foo first, tooltip shows for f( correctly
	Foo foo;
	foo();  // no tooltip for foo(
}
```

As noted there are some places where the sorting seems questionable.

Also constructors, `Foo()` above, should not show in . or -> completions lists (p-> in main() above), they can't be called like that.  Destructors can and show ok.

I also opened the above file in vscode and (I guess unsurprisingly) it doesn't have the noted issues.

Now for _real_ evil :imp: code ... 

note to self, don't ever autocomplete "get" :smile: 

but a big improvement, seems to not get too scrambled by templates.

I have no issue with this being merged, its a great improvement on previous capabilities.  Thanks @techee 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3175#issuecomment-1107684304
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3175/c1107684304 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20220423/e662016a/attachment.htm>


More information about the Github-comments mailing list