Community
Participate
Working Groups
First of all sorry for my english. Example: class Class { private: int y; bool operator == (const Class & rhs) const { return (x == rhs. ); // ^ // | Press Ctrl + Space here } private: int x; }; struct Struct { int x; bool operator == (const Struct & rhs) const { return (x == rhs. ); // ^ // | Press Ctrl + Space here } int y; }; int main () { return 0; }
Is there an index query that we can do to get content that is defined further down in the file?
I guess it could. We'd have to be smarter in this situation to know to go look up the fields in the class in the index. Something for the future.
Created attachment 24984 [details] code completion works strange
Actually, the too many completions is a separate problem that probably could use a new bugzilla entry. There are too many because I am searching for all members of all classes, probably a bad idea. Maybe I shouldn't include members in the search side of things.
Still an issue. Returning to pool.
*** Bug 185652 has been marked as a duplicate of this bug. ***
*** Bug 283847 has been marked as a duplicate of this bug. ***
*** Bug 107149 has been marked as a duplicate of this bug. ***
*** Bug 295034 has been marked as a duplicate of this bug. ***
*** Bug 300023 has been marked as a duplicate of this bug. ***
*** Bug 302547 has been marked as a duplicate of this bug. ***
*** Bug 307658 has been marked as a duplicate of this bug. ***
Hallo everybody, I stumble over this "feature" quite often and am really annoyed by it. Googleing for it brought me to this bug report as well as the following conversation: http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg16345.html However they don't seem to get to a solution. As this bug has been around for several years now: Is there any progress being made? Do you need further information on the issue, or is it just, that noone feels the need to fix it himself? Regards, Lars
This bug is pretty high on my priority list, but it's a hard one. Fixing it requires a deep change in the way parsing for code completion is done. My first attempt to approach it failed, but I'm going to try again. Hope to work on it after CDT 7.0 goes out.
Created attachment 170217 [details] a simple way to fix the issue Sergey, I have a simple idea on how to solve the issue. The patch basically uses the information from the index to fill in the missing members. The only interesting change are 15 lines added to CPPSemantics. The rest deals with providing the information whether the AST is for content assist or not. Due to its simplicity we can consider this patch for 7.0, what do you think?
(In reply to comment #15) This is great! We should definitely include it in 7.0.
Created attachment 170313 [details] testcase + fix Added a test-case and marked an existing one as passing.
Sergey, thanks for the review. Fixed in 7.0 > 20100528.
*** cdt cvs genie on behalf of mschorn *** Bug 103857: Content assist for fields declared below point of completion. [*] CompletionTests.java 1.49 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests.java?root=Tools_Project&r1=1.48&r2=1.49 [*] CPPSemantics.java 1.164 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java?root=Tools_Project&r1=1.163&r2=1.164 [*] CPPNodeFactory.java 1.15 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNodeFactory.java?root=Tools_Project&r1=1.14&r2=1.15 [*] CPreprocessor.java 1.64 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java?root=Tools_Project&r1=1.63&r2=1.64 [*] Lexer.java 1.22 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java?root=Tools_Project&r1=1.21&r2=1.22 [*] CNodeFactory.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CNodeFactory.java?root=Tools_Project&r1=1.7&r2=1.8 [*] ASTTranslationUnit.java 1.15 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java?root=Tools_Project&r1=1.14&r2=1.15 [*] TranslationUnit.java 1.110 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java?root=Tools_Project&r1=1.109&r2=1.110
Hi, Markus: This fix is great, but it doesn't work well for a header file. If I create a .h file with the example code, the content assist problem still exists. I will ask Vivian to reopen the defect, could you please take a look at it? Thanks.
Reopening bug for John
(In reply to comment #20) Could you please provide an example that doesn't work with the current fix and steps to reproduce the problem.
(In reply to comment #22) > (In reply to comment #20) > Could you please provide an example that doesn't work with the current fix and > steps to reproduce the problem. Sure, just create a .h file using Nikolay's example code and test the content assist at the locations marked in the comments, you will see this bug's problem is still there for the header file.
(In reply to comment #23) > (In reply to comment #22) > > (In reply to comment #20) > > Could you please provide an example that doesn't work with the current fix and > > steps to reproduce the problem. > > Sure, just create a .h file using Nikolay's example code and test the content > assist at the locations marked in the comments, you will see this bug's problem > is still there for the header file. I can confirm this bug still exist in header files.
(In reply to comment #24) > (In reply to comment #23) > > (In reply to comment #22) > > > (In reply to comment #20) > > > Could you please provide an example that doesn't work with the current fix and > > > steps to reproduce the problem. > > > > Sure, just create a .h file using Nikolay's example code and test the content > > assist at the locations marked in the comments, you will see this bug's problem > > is still there for the header file. > > I can confirm this bug still exist in header files. BUT, If you save the header file first, then the issue is gone. So, I think there need re-parsing mode.
In order to support content assist for fields declared below the point where they are used, the class definition has to be indexed. So, if the file is a header file, what you need is the following: (1) File has to be saved, and (2a) the file must be (indirectly) included by some source file that is indexed, or (2b) the indexer preference to index all header files is set. I don't plan on improving the feature beyond that.
(In reply to comment #26) > In order to support content assist for fields declared below the point where > they are used, the class definition has to be indexed. So, if the file is a > header file, what you need is the following: > (1) File has to be saved, and > (2a) the file must be (indirectly) included by some source file that is > indexed, or > (2b) the indexer preference to index all header files is set. > I don't plan on improving the feature beyond that. Just a thought, it's not the first time I stumble over problems editing header files that no one includes yet (API first!): in addation to the preferences, would it be possible to add a header file that I open in an editor automatically to the index?
(In reply to comment #27) > Just a thought, it's not the first time I stumble over problems editing header > files that no one includes yet (API first!): in addation to the preferences, > would it be possible to add a header file that I open in an editor > automatically to the index? See bug 248853. I'm going to do something along these lines for CDT 8.0.
(In reply to comment #28) > (In reply to comment #27) > > Just a thought, it's not the first time I stumble over problems editing header > > files that no one includes yet (API first!): in addation to the preferences, > > would it be possible to add a header file that I open in an editor > > automatically to the index? > > See bug 248853. I'm going to do something along these lines for CDT 8.0. Why not just index all header files in the project by default? If the language choice for an unused header is the problem then just parse it according to the project type. Then when the header gets included for the first time check to see if the language was correct, and if not then reindex the header using the correct language. It just seems to me it would be more useful to index unused headers even if there could be problems rather than not index them at all.
The specific workflow mentioned in comment 20 is handled via bug 248853.
(In reply to comment #30) > The specific workflow mentioned in comment 20 is handled via bug 248853. Mmmh, if I create a new header file (no including source file yet), put a class into this header file and add members, I need to close and re-open it before the members are available to content assist. I need to close/re-open everytime I add a new member before it shows up in content assist. Seems that the file is added to the index when it is opened, but not re-indexed when it changes?
(In reply to comment #31) > I need to close/re-open everytime I add a new member before it shows up in > content assist. It should be sufficient to save the file. Not need to close/reopen. > Seems that the file is added to the index when it is opened, but not re-indexed > when it changes? If the header file was added in the index (due to being included, indexing of unused headers, or indexing of files opened in editor), it will be re-indexed whenever it's changed on disk.
(In reply to comment #32) > (In reply to comment #31) > > I need to close/re-open everytime I add a new member before it shows up in > > content assist. > It should be sufficient to save the file. Not need to close/reopen. No, just saving doesn't work. I need to reopen everytime I add member. "Index source files not included in build" = on "Index unused headers" = off "Index source and header files opened in editor" = on.
(In reply to comment #33) > (In reply to comment #32) > > (In reply to comment #31) > > > I need to close/re-open everytime I add a new member before it shows up in > > > content assist. > > It should be sufficient to save the file. Not need to close/reopen. > No, just saving doesn't work. I need to reopen everytime I add member. > "Index source files not included in build" = on > "Index unused headers" = off > "Index source and header files opened in editor" = on. I can reproduce the behavior. The feature of adding files opened in the editor to the index is buggy, when the file is saved it is removed from the index again. --> Please create a separate bug for that.
(In reply to comment #34) > (In reply to comment #33) ... > I can reproduce the behavior. The feature of adding files opened in the editor > to the index is buggy, when the file is saved it is removed from the index > again. --> Please create a separate bug for that. Bug 351271
It looks like there is a regression. This bug is back. I downloaded eclipse-cpp-luna-SR2-macosx-cocoa-x86_64.tar.gz, created new workspace, created new C++ project. Now if I type this: class A{ public: void foo() { this->| } void bar() { } protected: int xyz; }; And try to invoke completion, neither bar nor xyz are present in completion list.