This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 258387 - Don't break "incomplete" file
Summary: Don't break "incomplete" file
Status: RESOLVED WONTFIX
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.1
Hardware: All All
: P2 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-15 17:16 UTC by Vladimir Voskresensky
Modified: 2016-07-07 16:05 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Voskresensky 2016-03-15 17:16:29 UTC
Open StmtJavaPrinter.cpp from JConvert, go to i.e. 
StmtJavaPrinter::PrintOMPExecutableDirective
start to type
"if (true ) {"
then wait => CPU is highly used + a lot of red signs appear above.
Then remove this line and you will see a lot of CPU activity as well.

Please, don't do extra work when file is known in advance to be "broken" 
i.e. when we have unbalanced {} () [] when originally file was in balanced state
Comment 1 Vladimir Voskresensky 2016-03-15 17:18:04 UTC
Alexander, can you investigate what can be done, please?
Comment 2 Alexander Simon 2016-03-18 13:00:59 UTC
What unbalanced is?

Is Code:
int main() {
#if 0
    {
#endif
    return 0;
}
unbalanced?

Is code:
int main() {
#if 0
    {
#endif
    int i = 0;
    return i;
#if 1
    }
#endif
}
balanced?
Comment 3 Vladimir Voskresensky 2016-03-18 15:05:12 UTC
How is it for formatter?
Please, use "balance" logic used by formatter.
Thanks!
Comment 4 Alexander Simon 2016-03-21 10:05:08 UTC
I do not see performance problems.
My steps:
- Open JConvert
- goto method StmtJavaPrinter::PrintOMPExecutableDirective
- insert inside the method the string "if (true ) {"
- comment inserted string
Result:
- insert took 502 ms
(diff between two logging lines:
=== Stopping parser queue stopwatch JConvert (47 files): 	 34828 ms)
- comment took 456 ms.
Comment 5 Alexander Simon 2016-03-21 11:00:54 UTC
It seems problem in "unfair" re-parse an edited file.
Go to StmtJavaPrinter::PrintOMPExecutableDirective and add new line after beginning "{".
IDE red highlight a lot of IDs in the previous unnamed namespace in each OMPClausePrinter method (except VisitOMPClauseList).

IDE does not re-parse methods created by "include inside class".
See lines inside OMPClausePrinter class:
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
#include "clang/Basic/OpenMPKinds.def"
Comment 6 Alexander Simon 2016-07-07 16:05:18 UTC
CPU activity relates with big file (5000 lines). It is expected behavior.

There is no reliable algorithm to detect "when we have unbalanced {} () []".
Do not fix.

Of course you can file separate bug described in comment #5.
You can simplify test case to:
start to type "int a;"
And see a lot of redness.