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 271673

Summary: IllegalStateException: Cannot call getCompilationUnit() if current phase < JavaSource.Phase.PARSED. You must call toPhase(Phase.PARSED) first.
Product: editor Reporter: theshadow27 <theshadow27>
Component: Formatting & IndentationAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal CC: theshadow27
Priority: P3    
Version: 8.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 230636
Bug Depends on: 268834, 271672    
Bug Blocks:    
Attachments: stacktrace
code to reproduce the problem
stacktrace
stacktrace
stacktrace

Description theshadow27 2017-10-19 20:54:10 UTC
Build: NetBeans IDE 8.2 (Build 201609300101)
VM: Java HotSpot(TM) 64-Bit Server VM, 25.144-b01, Java(TM) SE Runtime Environment, 1.8.0_144-b01
OS: Windows 10

User Comments:
theshadow27: Pasted an enormous block of generated code, probably containing errors. See also iz #271672




Stacktrace: 
java.lang.IllegalStateException: Cannot call getCompilationUnit() if current phase < JavaSource.Phase.PARSED. You must call toPhase(Phase.PARSED) first.
   at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getCompilationUnit(CompilationInfoImpl.java:220)
   at org.netbeans.api.java.source.CompilationInfo.getCompilationUnit(CompilationInfo.java:184)
   at org.netbeans.api.java.source.TreeUtilities.pathFor(TreeUtilities.java:294)
   at org.netbeans.modules.java.source.save.Reformatter.getCommonPath(Reformatter.java:378)
   at org.netbeans.modules.java.source.save.Reformatter.reformatImpl(Reformatter.java:235)
   at org.netbeans.modules.java.source.save.Reformatter.reformat(Reformatter.java:109)
Comment 1 theshadow27 2017-10-19 20:54:12 UTC
Created attachment 165319 [details]
stacktrace
Comment 2 theshadow27 2017-10-19 20:56:03 UTC
See also iz271672 and iz268834
Comment 3 theshadow27 2017-10-19 20:59:02 UTC
Created attachment 165321 [details]
code to reproduce the problem

This is the offending file...
Comment 4 theshadow27 2017-10-19 21:02:54 UTC
Created attachment 165323 [details]
stacktrace

Using large file
Comment 5 theshadow27 2017-10-19 21:05:54 UTC
Created attachment 165324 [details]
stacktrace

Trying to autoformat.
Comment 6 Exceptions Reporter 2017-10-19 21:05:58 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=230636
Comment 7 Exceptions Reporter 2018-02-05 21:41:22 UTC
Created attachment 165624 [details]
stacktrace

Opening source code file.