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.

View | Details | Raw Unified | Return to bug 234645
Collapse All | Expand All

(-)a/java.source/apichanges.xml (+14 lines)
Lines 108-113 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
    <changes>
110
    <changes>
111
        <change id="toScopeWithDisabledAccessibilityChecks">
112
            <api name="general"/>
113
            <summary>Adding <code>TreeUtilities.toScopeWithDisabledAccessibilityChecks</code> method.</summary>
114
            <version major="0" minor="129"/>
115
            <date day="20" month="8" year="2013"/>
116
            <author login="dbalek"/>
117
            <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
118
            <description>
119
                Adding the utility method to create a Scope capable to access
120
                all private methods and fields when parsing and evaluating expressions.
121
            </description>
122
            <class package="org.netbeans.api.java.source" name="TreeUtilities"/>
123
            <issue number="234645"/>
124
        </change>
111
        <change id="findBodySpan">
125
        <change id="findBodySpan">
112
             <api name="general"/>
126
             <api name="general"/>
113
             <summary>Added utility method to find span of a ClassTree's body in the source.</summary>
127
             <summary>Added utility method to find span of a ClassTree's body in the source.</summary>
(-)a/java.source/nbproject/project.properties (-1 / +1 lines)
Lines 46-52 Link Here
46
javadoc.title=Java Source
46
javadoc.title=Java Source
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
49
spec.version.base=0.128.0
49
spec.version.base=0.129.0
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/nb-javac-api.jar
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/nb-javac-api.jar
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
(-)a/java.source/src/org/netbeans/api/java/source/TreeUtilities.java (-13 / +57 lines)
Lines 88-96 Link Here
88
import org.netbeans.api.java.lexer.JavadocTokenId;
88
import org.netbeans.api.java.lexer.JavadocTokenId;
89
import org.netbeans.api.java.source.JavaSource.Phase;
89
import org.netbeans.api.java.source.JavaSource.Phase;
90
import org.netbeans.api.lexer.TokenSequence;
90
import org.netbeans.api.lexer.TokenSequence;
91
import org.netbeans.lib.nbjavac.services.NBResolve;
92
import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
91
import org.netbeans.modules.java.source.builder.CommentHandlerService;
93
import org.netbeans.modules.java.source.builder.CommentHandlerService;
92
import org.netbeans.modules.java.source.builder.CommentSetImpl;
94
import org.netbeans.modules.java.source.builder.CommentSetImpl;
93
import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
94
import org.netbeans.modules.java.source.pretty.ImportAnalysis2;
95
import org.netbeans.modules.java.source.pretty.ImportAnalysis2;
95
import org.netbeans.modules.java.source.transform.ImmutableDocTreeTranslator;
96
import org.netbeans.modules.java.source.transform.ImmutableDocTreeTranslator;
96
import org.netbeans.modules.java.source.transform.ImmutableTreeTranslator;
97
import org.netbeans.modules.java.source.transform.ImmutableTreeTranslator;
Lines 255-268 Link Here
255
        return pathFor(new TreePath(info.getCompilationUnit()), pos);
256
        return pathFor(new TreePath(info.getCompilationUnit()), pos);
256
    }
257
    }
257
258
258
    /*XXX: dbalek
259
     */
260
    public TreePath pathFor(TreePath path, int pos) {
259
    public TreePath pathFor(TreePath path, int pos) {
261
        return pathFor(path, pos, info.getTrees().getSourcePositions());
260
        return pathFor(path, pos, info.getTrees().getSourcePositions());
262
    }
261
    }
263
262
264
    /*XXX: dbalek
265
     */
266
    public TreePath pathFor(TreePath path, int pos, SourcePositions sourcePositions) {
263
    public TreePath pathFor(TreePath path, int pos, SourcePositions sourcePositions) {
267
        if (info == null || path == null || sourcePositions == null)
264
        if (info == null || path == null || sourcePositions == null)
268
            throw new IllegalArgumentException();
265
            throw new IllegalArgumentException();
Lines 636-668 Link Here
636
        return scope;
633
        return scope;
637
    }
634
    }
638
    
635
    
639
    //XXX dbalek:
636
    /**
637
     * Creates {@link Scope} capable to access all private methods and fields when
638
     * parsing and evaluating expressions. When using this Scope, the accessibility
639
     * checks would not be enforced during a tree attribution.
640
     * @param scope an existing scope
641
     * @return scope with disabled accessibility checks
642
     * @since 0.129
643
     */
644
    public Scope toScopeWithDisabledAccessibilityChecks(Scope scope) {
645
        return new NBScope((JavacScope)scope);
646
    }
647
    
640
    /**Attribute the given tree in the given context.
648
    /**Attribute the given tree in the given context.
641
     */
649
     */
642
    public TypeMirror attributeTree(Tree tree, Scope scope) {
650
    public TypeMirror attributeTree(Tree tree, Scope scope) {
643
        return info.impl.getJavacTask().attributeTree((JCTree)tree, ((JavacScope)scope).getEnv());
651
        if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) {
652
            NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
653
        }
654
        try {
655
            return info.impl.getJavacTask().attributeTree((JCTree) tree, ((JavacScope) scope).getEnv());
656
        } finally {
657
            NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
658
        }
644
    }
659
    }
645
    
660
    
646
    //XXX dbalek:
647
    /**Attribute the given tree until the given <code>to</code> tree is reached.
661
    /**Attribute the given tree until the given <code>to</code> tree is reached.
648
     * Returns scope valid at point when <code>to</code> is reached.
662
     * Returns scope valid at point when <code>to</code> is reached.
649
     */
663
     */
650
    public Scope attributeTreeTo(Tree tree, Scope scope, Tree to) {
664
    public Scope attributeTreeTo(Tree tree, Scope scope, Tree to) {
651
        return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, ((JavacScope)scope).getEnv(), (JCTree)to);
665
        if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) {
666
            NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
667
        }
668
        try {
669
            return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, ((JavacScope)scope).getEnv(), (JCTree)to);
670
        } finally {
671
            NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
672
        }
652
    }
673
    }
653
    
674
    
654
    //XXX dbalek:
655
    public TypeMirror reattributeTree(Tree tree, Scope scope) {
675
    public TypeMirror reattributeTree(Tree tree, Scope scope) {
656
        Env<AttrContext> env = ((JavacScope)scope).getEnv();
676
        Env<AttrContext> env = ((JavacScope)scope).getEnv();
657
        copyInnerClassIndexes(env.tree, tree);
677
        copyInnerClassIndexes(env.tree, tree);
658
        return info.impl.getJavacTask().attributeTree((JCTree)tree, env);
678
        if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) {
679
            NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
680
        }
681
        try {
682
            return info.impl.getJavacTask().attributeTree((JCTree)tree, env);
683
        } finally {
684
            NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
685
        }
659
    }
686
    }
660
    
687
    
661
    //XXX dbalek:
662
    public Scope reattributeTreeTo(Tree tree, Scope scope, Tree to) {
688
    public Scope reattributeTreeTo(Tree tree, Scope scope, Tree to) {
663
        Env<AttrContext> env = ((JavacScope)scope).getEnv();
689
        Env<AttrContext> env = ((JavacScope)scope).getEnv();
664
        copyInnerClassIndexes(env.tree, tree);
690
        copyInnerClassIndexes(env.tree, tree);
665
        return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, env, (JCTree)to);
691
        if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) {
692
            NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
693
        }
694
        try {
695
            return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, env, (JCTree)to);
696
        } finally {
697
            NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
698
        }
666
    }
699
    }
667
    
700
    
668
    /**Returns tokens for a given tree.
701
    /**Returns tokens for a given tree.
Lines 1525-1528 Link Here
1525
        
1558
        
1526
        return ref.paramTypes;
1559
        return ref.paramTypes;
1527
    }
1560
    }
1561
    
1562
    private static final class NBScope extends JavacScope {
1563
1564
        private NBScope(JavacScope scope) {
1565
            super(scope.getEnv());
1566
        }
1567
        
1568
        private boolean areAccessibilityChecksDisabled() {
1569
            return true;
1570
        }
1571
    }
1528
}
1572
}

Return to bug 234645