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 |
} |