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 235884

Summary: IllegalStateException: Cannot call getCompilationUnit() if current phase < JavaSource.Phase.PARSED. You must call toPhase(Phase.PARSED) first.
Product: java Reporter: aldobrucale <aldobrucale>
Component: RefactoringAssignee: Ralph Ruijs <ralphbenjamin>
Status: RESOLVED FIXED    
Severity: normal CC: aldobrucale, mkhramov
Priority: P3    
Version: 8.1   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 203815
Attachments: stacktrace
stacktrace
stacktrace
stacktrace
stacktrace

Description aldobrucale 2013-09-12 14:36:13 UTC
Build: NetBeans IDE Dev (Build 201309120002)
VM: Java HotSpot(TM) 64-Bit Server VM, 24.0-b56, Java(TM) SE Runtime Environment, 1.7.0_40-b43
OS: Linux

User Comments:
aldobrucale: tried to safely delete a local variable




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:212)
   at org.netbeans.api.java.source.CompilationInfo.getCompilationUnit(CompilationInfo.java:186)
   at org.netbeans.api.java.source.TreeUtilities.pathFor(TreeUtilities.java:256)
   at org.netbeans.api.java.source.TreePathHandle$TreeDelegate.resolvePathForPos(TreePathHandle.java:482)
   at org.netbeans.api.java.source.TreePathHandle$TreeDelegate.resolve(TreePathHandle.java:475)
   at org.netbeans.api.java.source.TreePathHandle$TreeDelegate.resolveElement(TreePathHandle.java:542)
Comment 1 aldobrucale 2013-09-12 14:36:17 UTC
Created attachment 139996 [details]
stacktrace
Comment 2 aldobrucale 2013-09-26 10:54:44 UTC
Created attachment 140502 [details]
stacktrace

Tried to safely delete a local variable
Comment 3 aldobrucale 2013-12-09 11:33:40 UTC
Created attachment 142966 [details]
stacktrace

Safely delete local variable
Comment 4 Maksim Khramov 2014-01-27 13:46:09 UTC
Created attachment 144409 [details]
stacktrace

Lookup find usages results immediately after IDE loaded
Comment 5 Maksim Khramov 2014-11-07 10:15:40 UTC
Created attachment 150338 [details]
stacktrace

Product Version: NetBeans IDE Dev (Build 201411070002)
Java: 1.8.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 25.40-b11

Steps to reproduce:

Edit this code:


package javaapplication32;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JavaApplication32 {

    static Pattern pattern = Pattern.compile("\\s*\\b\\d+,?");

    public static void main(String[] args) {
        String textToMatch = "Hello World";
        
        Matcher matcher = pattern.matcher(textToMatch);
        
        boolean isMatched = matcher.matches();
        
        if(isMatched) {
            System.out.println("Matched");
        }
    }
    
}

Invoke Refactor - Inline over isMatched symbol in if(isMatched) line.
Exception is thrown
Comment 6 Ralph Ruijs 2015-03-09 10:21:07 UTC
changeset:   eb499ffac58d
user:        Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
date:        Mon Mar 09 11:20:32 2015 +0100
summary:     #235884 - Cannot call getCompilationUnit() if current phase < JavaSource.Phase.PARSED
Comment 7 Quality Engineering 2015-03-13 03:14:31 UTC
Integrated into 'main-silver', will be available in build *201503130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/eb499ffac58d
User: Ralph Benjamin Ruijs <ralphbenjamin@netbeans.org>
Log: #235884 - Cannot call getCompilationUnit() if current phase < JavaSource.Phase.PARSED