# HG changeset patch # Parent cc6f367083afa62b963996c5f329957d231b2de8 # User Ralph Benjamin Ruijs # Parent fa3c5baf37e796f5385a764267a3b8534cd455fb imported patch FU2 diff --git a/java.source.base/nbproject/project.properties b/java.source.base/nbproject/project.properties --- a/java.source.base/nbproject/project.properties +++ b/java.source.base/nbproject/project.properties @@ -47,7 +47,7 @@ javadoc.title=Java Source Base javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml -spec.version.base=2.3 +spec.version.base=2.4 test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/nb-javac-api.jar test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\ ${o.n.core.dir}/lib/boot.jar:\ diff --git a/java.source.base/src/org/netbeans/api/java/source/ClassIndex.java b/java.source.base/src/org/netbeans/api/java/source/ClassIndex.java --- a/java.source.base/src/org/netbeans/api/java/source/ClassIndex.java +++ b/java.source.base/src/org/netbeans/api/java/source/ClassIndex.java @@ -431,6 +431,36 @@ } }); } + + /** + * Returns a set of source and binary files containing reference(s) to given type element. + * @param element the {@link ElementHandle} of a {@link TypeElement} for which usages should be found + * @param searchKind type of reference, {@see SearchKind} + * @param scope to search in {@see SearchScope} + * @return set of {@link FileObject}s containing the reference(s) + * It may return null when the caller is a CancellableTask<CompilationInfo> and is cancelled + * inside call of this method. + */ + public @NullUnknown Set getBinaryResources ( + final @NonNull ElementHandle element, + final @NonNull Set searchKind, + final @NonNull Set scope) { + return searchImpl( + element, + searchKind, + scope, + new Convertor>() { + @NonNull + @Override + public Convertor convert(@NonNull final ClassIndexImpl p) { + final FileObject[] binaryRoots = p.getBinaryRoots(); + final FileObject[] sourceRoots = p.getSourceRoots(); + FileObject[] roots = Arrays.copyOf(sourceRoots, sourceRoots.length + binaryRoots.length); + System.arraycopy(binaryRoots, 0, roots, sourceRoots.length, binaryRoots.length); + return DocumentUtil.fileObjectConvertor (roots); + } + }); + } @NullUnknown private Set searchImpl( diff --git a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java b/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java --- a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java +++ b/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java @@ -115,7 +115,6 @@ import org.netbeans.modules.java.source.transform.ImmutableDocTreeTranslator; import org.netbeans.modules.java.source.transform.ImmutableTreeTranslator; import org.netbeans.modules.java.source.transform.TreeDuplicator; -import org.netbeans.modules.parsing.api.Snapshot; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.NbBundle; diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java b/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java --- a/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java +++ b/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java @@ -177,7 +177,7 @@ private static final String JCOMPONENT = javax.swing.JComponent.class.getName(); static final String OBJECT = Object.class.getName(); - private static boolean FULL_INDEX = Boolean.getBoolean("org.netbeans.modules.java.source.usages.BinaryAnalyser.fullIndex"); //NOI18N + private static boolean FULL_INDEX = true; //Boolean.getBoolean("org.netbeans.modules.java.source.usages.BinaryAnalyser.fullIndex"); //NOI18N private final ClassIndexImpl.Writer writer; private final File cacheRoot; diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassIndexImpl.java b/java.source.base/src/org/netbeans/modules/java/source/usages/ClassIndexImpl.java --- a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassIndexImpl.java +++ b/java.source.base/src/org/netbeans/modules/java/source/usages/ClassIndexImpl.java @@ -162,6 +162,8 @@ public abstract FileObject[] getSourceRoots (); + public abstract FileObject[] getBinaryRoots (); + public abstract BinaryAnalyser getBinaryAnalyser (); public abstract SourceAnalyzerFactory.StorableAnalyzer getSourceAnalyser (); diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/DocumentUtil.java b/java.source.base/src/org/netbeans/modules/java/source/usages/DocumentUtil.java --- a/java.source.base/src/org/netbeans/modules/java/source/usages/DocumentUtil.java +++ b/java.source.base/src/org/netbeans/modules/java/source/usages/DocumentUtil.java @@ -492,6 +492,9 @@ if (FileObjects.JAVA.equalsIgnoreCase(child.getExt()) && name.equals(child.getName())) { return child; } + if (FileObjects.CLASS.equalsIgnoreCase(child.getExt()) && name.equals(child.getName())) { + return child; + } } return null; } diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java b/java.source.base/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java --- a/java.source.base/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java +++ b/java.source.base/src/org/netbeans/modules/java/source/usages/PersistentClassIndex.java @@ -165,6 +165,15 @@ } @Override + public FileObject[] getBinaryRoots() { + FileObject[] rootFos = new FileObject[0]; + if(getType() == Type.BINARY) { + rootFos = new FileObject[] {URLMapper.findFileObject (this.root)}; + } + return rootFos; + } + + @Override public String getSourceName (final String binaryName) throws IOException, InterruptedException { try { final Query q = DocumentUtil.binaryNameQuery(binaryName); diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/classfile/CodeGeneratorTest.java b/java.source/test/unit/src/org/netbeans/modules/java/classfile/CodeGeneratorTest.java rename from java.source.base/test/unit/src/org/netbeans/modules/java/classfile/CodeGeneratorTest.java rename to java.source/test/unit/src/org/netbeans/modules/java/classfile/CodeGeneratorTest.java diff --git a/refactoring.api/src/org/netbeans/modules/refactoring/api/WhereUsedQuery.java b/refactoring.api/src/org/netbeans/modules/refactoring/api/WhereUsedQuery.java --- a/refactoring.api/src/org/netbeans/modules/refactoring/api/WhereUsedQuery.java +++ b/refactoring.api/src/org/netbeans/modules/refactoring/api/WhereUsedQuery.java @@ -67,6 +67,11 @@ public static final String SEARCH_IN_COMMENTS = "SEARCH_IN_COMMENTS"; // NOI18N /** * key for {@link #getBooleanValue()} + * is search in binary requested? + */ + public static final String SEARCH_IN_BINARY = "SEARCH_IN_BINARY"; // NOI18N + /** + * key for {@link #getBooleanValue()} * is find references requested? */ public static final String FIND_REFERENCES = "FIND_REFERENCES"; // NOI18N diff --git a/refactoring.java/nbproject/project.xml b/refactoring.java/nbproject/project.xml --- a/refactoring.java/nbproject/project.xml +++ b/refactoring.java/nbproject/project.xml @@ -58,6 +58,15 @@ + org.netbeans.libs.javacimpl + + + + 1 + + + + org.netbeans.modules.editor.lib @@ -129,6 +138,15 @@ + org.netbeans.modules.java.platform + + + + 1 + 1.35 + + + org.netbeans.modules.java.project diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/RefactoringUtils.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/RefactoringUtils.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/RefactoringUtils.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/RefactoringUtils.java @@ -1006,7 +1006,7 @@ boolean inTest = false; if (cp != null) { FileObject root = cp.findOwnerRoot(file); - if (UnitTestForSourceQuery.findSources(root).length > 0) { + if (root != null && UnitTestForSourceQuery.findSources(root).length > 0) { inTest = true; } } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/WhereUsedElement.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/WhereUsedElement.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/WhereUsedElement.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/WhereUsedElement.java @@ -44,17 +44,34 @@ package org.netbeans.modules.refactoring.java; import com.sun.source.tree.*; -import com.sun.source.tree.Tree.Kind; import com.sun.source.util.SourcePositions; import com.sun.source.util.TreePath; import com.sun.source.util.Trees; +import java.awt.Color; +import java.io.CharConversionException; +import java.util.Iterator; +import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.Name; +import javax.lang.model.element.TypeElement; +import javax.lang.model.element.TypeParameterElement; +import javax.lang.model.element.VariableElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.TypeKind; +import javax.lang.model.type.TypeMirror; import javax.swing.Icon; +import javax.swing.UIManager; import javax.swing.text.Position.Bias; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.java.source.ClasspathInfo; import org.netbeans.api.java.source.CompilationInfo; +import org.netbeans.api.java.source.ElementHandle; import org.netbeans.api.java.source.TreeUtilities; +import org.netbeans.api.java.source.TypeUtilities; import org.netbeans.modules.refactoring.java.plugins.JavaWhereUsedQueryPlugin; import org.netbeans.modules.refactoring.java.spi.JavaWhereUsedFilters; import org.netbeans.modules.refactoring.java.spi.JavaWhereUsedFilters.ReadWrite; @@ -77,17 +94,26 @@ import org.openide.util.NbBundle; import org.openide.util.lookup.Lookups; import static org.netbeans.modules.refactoring.java.Bundle.*; +import org.openide.xml.XMLUtil; @NbBundle.Messages({"WARN_ElementNotFound=The destination was not found."}) public class WhereUsedElement extends SimpleRefactoringElementImplementation implements FiltersManager.Filterable { - private PositionBounds bounds; - private String htmlText; - private String elementText; - private FileObject parentFile; + private final PositionBounds bounds; + private final String htmlText; + private final String elementText; + private final FileObject parentFile; private final JavaWhereUsedFilters.ReadWrite access; private final boolean inComment; private final boolean inImport; + private final boolean inBinary; private final boolean inTestclass; + private final ClasspathInfo cpInfo; + private final ElementHandle handle; + + private static final String INHERITED_COLOR_KEY = "nb.navigator.inherited.color"; //NOI18N + private static final String TYPE_COLOR_KEY = "nb.navigator.type.color"; //NOI18N + private static final Color DEFAULT_TYPE_COLOR = new Color(0x70,0x70,0x70); //NOI18N + private static final Color DEFAULT_INHERITED_COLOR = new Color(0x7D,0x69, 0x4A); //NOI18N // public WhereUsedElement(PositionBounds bounds, String htmlText, FileObject parentFile, TreePath tp, CompilationInfo info) { // this(bounds, htmlText, parentFile, tp, info, null, false, true); @@ -97,7 +123,7 @@ // this(bounds, htmlText, parentFile, tp, info, access, false, false); // } - public WhereUsedElement(PositionBounds bounds, String htmlText, String elementText, FileObject parentFile, TreePath tp, CompilationInfo info, ReadWrite access, boolean inTestclass, boolean inComment, boolean inImport) { + public WhereUsedElement(PositionBounds bounds, String htmlText, String elementText, FileObject parentFile, TreePath tp, CompilationInfo info, ReadWrite access, boolean inTestclass, boolean inBinary, boolean inComment, boolean inImport) { this.bounds = bounds; this.htmlText = htmlText; this.elementText = elementText; @@ -108,10 +134,28 @@ ElementGripFactory.getDefault().put(parentFile, inTestclass); this.access = access; this.inTestclass = inTestclass; + this.inBinary = inBinary; this.inComment = inComment; this.inImport = inImport; + this.cpInfo = null; + this.handle = null; } - + + public WhereUsedElement(ClasspathInfo cpInfo, ElementHandle handle, FileObject fo) { + final String name = "Found possible usages in Binary"; //NOI18N + this.htmlText = "" + name + ""; //NOI18N + this.elementText = name; + this.access = null; + this.inComment = false; + this.inTestclass = false; + this.inBinary = true; + this.inImport = false; + this.parentFile = fo; + this.bounds = null; + this.cpInfo = cpInfo; + this.handle = handle; + } + @Override public String getDisplayText() { return htmlText; @@ -119,7 +163,10 @@ @Override public Lookup getLookup() { - Object composite = ElementGripFactory.getDefault().get(parentFile, bounds.getBegin().getOffset()); + Object composite = null; + if(bounds != null) { + composite = ElementGripFactory.getDefault().get(parentFile, bounds.getBegin().getOffset()); + } if (composite==null) { composite = parentFile; } @@ -170,22 +217,280 @@ @Override public FileObject getParentFile() { - return parentFile; + return parentFile; } public JavaWhereUsedFilters.ReadWrite getAccess() { return access; } - public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, boolean inTest) { - return create(compiler, tree, null, inTest, new AtomicBoolean()); + @NonNull + private static String getHtmlColor(@NonNull final Color c) { + final int r = c.getRed(); + final int g = c.getGreen(); + final int b = c.getBlue(); + final StringBuilder result = new StringBuilder(); + result.append ("#"); //NOI18N + final String rs = Integer.toHexString (r); + final String gs = Integer.toHexString (g); + final String bs = Integer.toHexString (b); + if (r < 0x10) { + result.append('0'); + } + result.append(rs); + if (g < 0x10) { + result.append ('0'); + } + result.append(gs); + if (b < 0x10) { + result.append ('0'); + } + result.append(bs); + return result.toString(); } - public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, boolean inTest, AtomicBoolean inImport) { - return create(compiler, tree, null, inTest, inImport); + @NonNull + String getInheritedColor(Color inheritedColor) { + return getHtmlColor( + inheritedColor == null ? + DEFAULT_INHERITED_COLOR : + inheritedColor); } - public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, JavaWhereUsedFilters.ReadWrite access, boolean inTest, AtomicBoolean inImport) { + @NonNull + String getTypeColor(Color typeColor) { + return getHtmlColor( + typeColor == null ? + DEFAULT_TYPE_COLOR : + typeColor); + } + + /** Creates HTML display name of the Executable element */ + private String createHtmlHeader(CompilationInfo info, ExecutableElement e, Color inheritedColor, Color typeColor, boolean isDeprecated,boolean isInherited, boolean fqn ) { + + StringBuilder sb = new StringBuilder(); + if ( isDeprecated ) { + sb.append(""); // NOI18N + } + if( isInherited ) { + sb.append(""); // NOI18N + } + Name name = e.getKind() == ElementKind.CONSTRUCTOR ? e.getEnclosingElement().getSimpleName() : e.getSimpleName(); + sb.append(escape(name.toString())); + if ( isDeprecated ) { + sb.append(""); // NOI18N + } + + sb.append("("); // NOI18N + + List params = e.getParameters(); + for( Iterator it = params.iterator(); it.hasNext(); ) { + VariableElement param = it.next(); + sb.append(""); // NOI18N + final boolean vararg = !it.hasNext() && e.isVarArgs(); + sb.append(printArg(info, param.asType(),vararg, fqn)); + sb.append(""); // NOI18N + sb.append(" "); // NOI18N + sb.append(escape(param.getSimpleName().toString())); + if ( it.hasNext() ) { + sb.append(", "); // NOI18N + } + } + + + sb.append(")"); // NOI18N + + if ( e.getKind() != ElementKind.CONSTRUCTOR ) { + TypeMirror rt = e.getReturnType(); + if ( rt.getKind() != TypeKind.VOID ) { + sb.append(" : "); // NOI18N + sb.append(""); // NOI18N + sb.append(print(info, e.getReturnType(), fqn)); + sb.append(""); // NOI18N + } + } + + return sb.toString(); + } + + private String createHtmlHeader(CompilationInfo info, VariableElement e, Color inheritedColor, Color typeColor, boolean isDeprecated, boolean isInherited, boolean fqn) { + + StringBuilder sb = new StringBuilder(); + + if ( isDeprecated ) { + sb.append(""); // NOI18N + } + if( isInherited ) { + sb.append(""); // NOI18N + } + sb.append(escape(e.getSimpleName().toString())); + if ( isDeprecated ) { + sb.append(""); // NOI18N + } + + if ( e.getKind() != ElementKind.ENUM_CONSTANT ) { + sb.append( " : " ); // NOI18N + sb.append(""); // NOI18N + sb.append(print(info, e.asType(), fqn)); + sb.append(""); // NOI18N + } + + return sb.toString(); + } + + private String createHtmlHeader(CompilationInfo info, TypeElement e, Color inheritedColor, Color typeColor, boolean isDeprecated, boolean isInherited, boolean fqn) { + + StringBuilder sb = new StringBuilder(); + if ( isDeprecated ) { + sb.append(""); // NOI18N + } + if( isInherited ) { + sb.append(""); // NOI18N + } + sb.append(escape( + fqn? + e.getQualifiedName().toString(): + e.getSimpleName().toString())); + if ( isDeprecated ) { + sb.append(""); // NOI18N + } + // sb.append(print(info, e.asType())); + List typeParams = e.getTypeParameters(); + + //System.out.println("Element " + e + "type params" + typeParams.size() ); + + if ( typeParams != null && !typeParams.isEmpty() ) { + sb.append("<"); // NOI18N + + for( Iterator it = typeParams.iterator(); it.hasNext(); ) { + TypeParameterElement tp = it.next(); + sb.append( escape(tp.getSimpleName().toString()) ); + try { // XXX Verry ugly -> file a bug against Javac? + List bounds = tp.getBounds(); + //System.out.println( tp.getSimpleName() + " bounds size " + bounds.size() ); + if ( !bounds.isEmpty() ) { + sb.append(printBounds(info, bounds, fqn)); + } + } + catch ( NullPointerException npe ) { + System.err.println("El " + e ); + npe.printStackTrace(); + } + if ( it.hasNext() ) { + sb.append(", "); // NOI18N + } + } + + sb.append(">"); // NOI18N + } + + // Add superclass and implemented interfaces + + TypeMirror sc = e.getSuperclass(); + String scName = print(info, sc, fqn); + + if ( sc == null || + e.getKind() == ElementKind.ENUM || + e.getKind() == ElementKind.ANNOTATION_TYPE || + "Object".equals(scName) || // NOI18N + "".equals(scName)) { // NOI18N + scName = null; + } + + List ifaces = e.getInterfaces(); + + if ( ( scName != null || !ifaces.isEmpty() ) && + e.getKind() != ElementKind.ANNOTATION_TYPE ) { + sb.append( " :: " ); // NOI18N + if (scName != null) { + sb.append(""); // NOI18N + sb.append( scName ); + sb.append(""); // NOI18N + } + if ( !ifaces.isEmpty() ) { + if ( scName != null ) { + sb.append( " : " ); // NOI18N + } + for (Iterator it = ifaces.iterator(); it.hasNext();) { + TypeMirror typeMirror = it.next(); + sb.append(""); // NOI18N + sb.append( print(info, typeMirror, fqn) ); + sb.append(""); // NOI18N + if ( it.hasNext() ) { + sb.append(", "); // NOI18N + } + } + + } + } + + return sb.toString(); + } + + private String printBounds(CompilationInfo info, List bounds, boolean fqn) { + if ( bounds.size() == 1 && "java.lang.Object".equals( bounds.get(0).toString() ) ) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + + sb.append( " extends " ); // NOI18N + + for (Iterator it = bounds.iterator(); it.hasNext();) { + TypeMirror bound = it.next(); + sb.append(print(info, bound, fqn)); + if ( it.hasNext() ) { + sb.append(" & " ); // NOI18N + } + + } + + return sb.toString(); + } + + private String printArg(CompilationInfo info, final TypeMirror tm, final boolean varArg, boolean fqn) { + if (varArg) { + if (tm.getKind() == TypeKind.ARRAY) { + final ArrayType at = (ArrayType)tm; + final StringBuilder sb = new StringBuilder( print(info, at.getComponentType(), fqn) ); + sb.append("..."); //NOI18N + return sb.toString(); + } else { + assert false : "Expected array: " + tm.toString() + " ( " +tm.getKind() + " )"; //NOI18N + } + } + return print(info, tm, fqn); + } + + private String print(CompilationInfo info, TypeMirror tm, boolean fqn) { + return escape(fqn ? info.getTypeUtilities().getTypeName(tm, TypeUtilities.TypeNameOptions.PRINT_FQN).toString() + : info.getTypeUtilities().getTypeName(tm).toString()); + } + + @CheckForNull + private static String escape(@NonNull final String s) { + if (s != null) { + try { + return XMLUtil.toAttributeValue(s); + } catch (CharConversionException ex) { + } + } + return null; + } + + public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, boolean inTest) { + return create(compiler, tree, inTest, false); + } + + public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, boolean inTest, boolean inBinary) { + return create(compiler, tree, null, inTest, inBinary, new AtomicBoolean()); + } + + public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, boolean inTest, boolean inBinary, AtomicBoolean inImport) { + return create(compiler, tree, null, inTest, inBinary, inImport); + } + + public static WhereUsedElement create(CompilationInfo compiler, TreePath tree, JavaWhereUsedFilters.ReadWrite access, boolean inTest, boolean inBinary, AtomicBoolean inImport) { CompilationUnitTree unit = tree.getCompilationUnit(); CharSequence content = compiler.getSnapshot().getText(); SourcePositions sp = compiler.getTrees().getSourcePositions(); @@ -344,7 +649,11 @@ start==end && anonClassNameBug128074 ? NbBundle.getMessage(WhereUsedPanel.class, "LBL_AnonymousClass"):content.subSequence((int)sta, (int)en).toString().trim(), compiler.getFileObject(), tr, - compiler, access, inTest, false, elementInImport); + compiler, access, inTest, inBinary, false, elementInImport); + } + + public static WhereUsedElement createBinary(ClasspathInfo cpInfo, ElementHandle handle, FileObject fo) { + return new WhereUsedElement(cpInfo, handle, fo); } private static String trimStart(String s) { @@ -369,7 +678,7 @@ return ""; } - public static WhereUsedElement create(int start, int end, CompilationInfo compiler, boolean inTest) { + public static WhereUsedElement create(int start, int end, CompilationInfo compiler, boolean inTest, boolean inBinary) { CharSequence content = compiler.getSnapshot().getText(); LineMap lm = compiler.getCompilationUnit().getLineMap(); long line = lm.getLineNumber(start); @@ -397,7 +706,7 @@ PositionBounds bounds = new PositionBounds(ref1, ref2); return new WhereUsedElement(bounds, sb.toString().trim(), content.subSequence((int)sta, (int)en).toString(), - compiler.getFileObject(), null, compiler, null, inTest, true, false); + compiler.getFileObject(), null, compiler, null, inTest, inBinary, true, false); } private static TreePath getEnclosingImportTree(TreePath tp) { @@ -424,17 +733,18 @@ @Override public boolean filter(FiltersManager manager) { - if((!inTestclass && manager.isSelected(JavaWhereUsedFilters.SOURCEFILE.getKey())) || - (inTestclass && (inTestclass && manager.isSelected(JavaWhereUsedFilters.TESTFILE.getKey())))) { - if (access != null) { - return manager.isSelected(access.getKey()); - } else if (inComment) { - return manager.isSelected(JavaWhereUsedFilters.COMMENT.getKey()); - } else if (inImport) { - return manager.isSelected(JavaWhereUsedFilters.IMPORT.getKey()); - } else { - return true; - } + if(inBinary && manager.isSelected(JavaWhereUsedFilters.BINARYFILE.getKey()) || + (!inBinary && !inTestclass && manager.isSelected(JavaWhereUsedFilters.SOURCEFILE.getKey())) || + (!inBinary && inTestclass && (inTestclass && manager.isSelected(JavaWhereUsedFilters.TESTFILE.getKey())))) { + if (access != null) { + return manager.isSelected(access.getKey()); + } else if (inComment) { + return manager.isSelected(JavaWhereUsedFilters.COMMENT.getKey()); + } else if (inImport) { + return manager.isSelected(JavaWhereUsedFilters.IMPORT.getKey()); + } else { + return true; + } } else { return false; } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java @@ -351,7 +351,7 @@ Set relevantFiles = null; if (!isCanceled()) { relevantFiles = JavaWhereUsedQueryPlugin.getRelevantFiles( - sourceToQuery, cpInfo, false, false, false, false, true, null, isCanceled); + sourceToQuery, cpInfo, false, false, false, false, true, false, null, isCanceled); if (SourceUtils.isScanInProgress()) { elmDesc.setIncomplete(true); } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java @@ -69,6 +69,7 @@ import org.netbeans.modules.refactoring.java.spi.JavaWhereUsedFilters; import org.netbeans.modules.refactoring.java.spi.ToPhaseException; import org.openide.ErrorManager; +import org.openide.filesystems.FileObject; import org.openide.util.Exceptions; /** @@ -83,8 +84,9 @@ private boolean findInComments = false; private final boolean isSearchOverloadedMethods; private final boolean fromTestRoot; + private final boolean fromBinary; private final AtomicBoolean inImport; - private Boolean usagesInComments; + private boolean usagesInComments; private final AtomicBoolean isCancelled; private List methods; @@ -93,10 +95,10 @@ } public FindUsagesVisitor(CompilationController workingCopy, AtomicBoolean isCancelled, boolean findInComments, boolean isSearchOverloadedMethods) { - this(workingCopy, isCancelled, findInComments, isSearchOverloadedMethods, RefactoringUtils.isFromTestRoot(workingCopy.getFileObject(), workingCopy.getClasspathInfo().getClassPath(PathKind.SOURCE)), new AtomicBoolean()); + this(workingCopy, isCancelled, findInComments, isSearchOverloadedMethods, RefactoringUtils.isFromTestRoot(workingCopy.getFileObject(), workingCopy.getClasspathInfo().getClassPath(PathKind.SOURCE)), false, new AtomicBoolean()); } - public FindUsagesVisitor(CompilationController workingCopy, AtomicBoolean isCancelled, boolean findInComments, boolean isSearchOverloadedMethods, boolean fromTestRoot, AtomicBoolean inImport) { + public FindUsagesVisitor(CompilationController workingCopy, AtomicBoolean isCancelled, boolean findInComments, boolean isSearchOverloadedMethods, boolean fromTestRoot, boolean fromBinary, AtomicBoolean inImport) { try { setWorkingCopy(workingCopy); } catch (ToPhaseException ex) { @@ -105,16 +107,21 @@ this.findInComments = findInComments; this.isSearchOverloadedMethods = isSearchOverloadedMethods; this.fromTestRoot = fromTestRoot; + this.fromBinary = fromBinary; this.inImport = inImport; this.isCancelled = isCancelled; this.methods = new LinkedList<>(); } - // @Override public Tree visitCompilationUnit(CompilationUnitTree node, Element p) { if (findInComments) { - String originalName = p.getSimpleName().toString(); + String originalName; + if(p.getKind() == ElementKind.CONSTRUCTOR) { + originalName = p.getEnclosingElement().getSimpleName().toString(); + } else { + originalName = p.getSimpleName().toString(); + } TokenSequence ts = workingCopy.getTokenHierarchy().tokenSequence(JavaTokenId.language()); while (ts.moveNext()) { @@ -126,12 +133,11 @@ if (t.id() == JavaTokenId.BLOCK_COMMENT || t.id() == JavaTokenId.LINE_COMMENT || t.id() == JavaTokenId.JAVADOC_COMMENT) { Scanner tokenizer = new Scanner(t.text().toString()); tokenizer.useDelimiter("[^a-zA-Z0-9_]"); //NOI18N - while (tokenizer.hasNext()) { String current = tokenizer.next(); if (current.equals(originalName)) { WhereUsedElement comment = WhereUsedElement.create(ts.offset() + tokenizer.match().start(), - ts.offset() + tokenizer.match().end(), workingCopy, fromTestRoot); + ts.offset() + tokenizer.match().end(), workingCopy, fromTestRoot, fromBinary); elements.add(comment); usagesInComments = true; } @@ -155,7 +161,6 @@ } return super.visitCompilationUnit(node, p); } - // private void addIfMatch(TreePath path, Tree tree, Element elementToFind) { if(isCancelled.get()) { @@ -345,7 +350,7 @@ protected void addUsage(TreePath tp, JavaWhereUsedFilters.ReadWrite access) { assert tp != null; - elements.add(WhereUsedElement.create(workingCopy, tp, access, fromTestRoot, inImport)); + elements.add(WhereUsedElement.create(workingCopy, tp, access, fromTestRoot, fromBinary, inImport)); usages.add(tp); } @@ -355,7 +360,7 @@ protected void addUsage(TreePath tp) { assert tp != null; - elements.add(WhereUsedElement.create(workingCopy, tp, fromTestRoot, inImport)); + elements.add(WhereUsedElement.create(workingCopy, tp, fromTestRoot, fromBinary, inImport)); usages.add(tp); } @@ -431,6 +436,6 @@ } public boolean usagesInComments() { - return Boolean.TRUE == usagesInComments; + return usagesInComments; } } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavaWhereUsedQueryPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavaWhereUsedQueryPlugin.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavaWhereUsedQueryPlugin.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/JavaWhereUsedQueryPlugin.java @@ -47,6 +47,7 @@ import com.sun.source.tree.Tree; import com.sun.source.util.TreePath; import java.io.IOException; +import java.net.URL; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import javax.lang.model.element.Element; @@ -54,8 +55,10 @@ import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.Modifier; import javax.lang.model.element.TypeElement; +import javax.swing.Icon; import org.netbeans.api.fileinfo.NonRecursiveFolder; import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.api.java.source.*; import org.netbeans.api.java.source.ClassIndex.SearchScopeType; import org.netbeans.modules.refactoring.api.*; @@ -68,13 +71,18 @@ import org.netbeans.modules.refactoring.java.spi.JavaWhereUsedFilters; import org.netbeans.modules.refactoring.java.spi.JavaWhereUsedFilters.ReadWrite; import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; +import org.netbeans.modules.refactoring.spi.ui.ExpandableTreeElement; import org.netbeans.modules.refactoring.spi.ui.FiltersDescription; +import org.netbeans.modules.refactoring.spi.ui.TreeElement; +import org.netbeans.spi.java.classpath.support.ClassPathSupport; import org.openide.ErrorManager; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; import org.openide.text.CloneableEditorSupport; import org.openide.util.ImageUtilities; import org.openide.util.NbBundle; +import org.openide.util.Pair; /** * @@ -170,14 +178,16 @@ } else { cpath = RefactoringUtils.getClasspathInfoFor(false, customScope.getSourceRoots().toArray(new FileObject[0])); } - fileSet.addAll(getRelevantFiles(tph, + Set relevantFiles = getRelevantFiles(tph, cpath, isFindSubclasses(), isFindDirectSubclassesOnly(), isFindOverridingMethods(), isSearchOverloadedMethods(), isFindUsages(), - null, cancelRequested)); + isSearchBinaries(), + null, cancelRequested); + fileSet.addAll(relevantFiles); } Map> folders = new HashMap<>(); @@ -201,13 +211,14 @@ } else { cpath = RefactoringUtils.getClasspathInfoFor(false, sourceRoot); } - fileSet.addAll(getRelevantFiles(tph, + Set relevantFiles = getRelevantFiles(tph, cpath, isFindSubclasses(), isFindDirectSubclassesOnly(), isFindOverridingMethods(), isSearchOverloadedMethods(), - isFindUsages(), packages, cancelRequested)); + isFindUsages(), isSearchBinaries(), packages, cancelRequested); + fileSet.addAll(relevantFiles); } } return fileSet; @@ -220,6 +231,7 @@ isFindOverridingMethods(), isSearchOverloadedMethods(), isFindUsages(), + isSearchBinaries(), null, cancelRequested); } @@ -230,10 +242,10 @@ final TreePathHandle tph, final ClasspathInfo cpInfo, final boolean isFindSubclasses, final boolean isFindDirectSubclassesOnly, final boolean isFindOverridingMethods, final boolean isSearchOverloadedMethods, - final boolean isFindUsages, final Set folders, + final boolean isFindUsages, final boolean isIncludeDependencies, final Set folders, final AtomicBoolean cancel) { final ClassIndex idx = cpInfo.getClassIndex(); - final Set set = new TreeSet<>(new FileComparator()); + final Set sourceSet = new TreeSet<>(new FileComparator()); final Set packages = (folders == null)? Collections.emptySet() : folders; final FileObject file = tph.getFileObject(); @@ -255,53 +267,59 @@ throw new NullPointerException(String.format("#145291: Cannot resolve handle: %s\n%s", tph, info.getClasspathInfo())); // NOI18N } Set searchScopeType = new HashSet<>(1); - if (packages.isEmpty()) { - searchScopeType.add(ClassIndex.SearchScope.SOURCE); - } else { - final Set packageSet = new HashSet<>(packages.size()); - for (NonRecursiveFolder nonRecursiveFolder : packages) { - String resourceName = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE).getResourceName(nonRecursiveFolder.getFolder()); - if(resourceName != null) { - packageSet.add(resourceName.replace('/', '.')); - } + final Set packageSet = new HashSet<>(packages.size()); + for (NonRecursiveFolder nonRecursiveFolder : packages) { + String resourceName = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE).getResourceName(nonRecursiveFolder.getFolder()); + packageSet.add(resourceName.replace('/', '.')); + } + searchScopeType.add(new SearchScopeType() { + @Override + public Set getPackages() { + return packageSet.isEmpty() ? null : packageSet; } - searchScopeType.add(new SearchScopeType() { - @Override - public Set getPackages() { - return packageSet; - } - @Override - public boolean isSources() { - return true; - } + @Override + public boolean isSources() { + return true; + } - @Override - public boolean isDependencies() { - return false; - } - }); - } + @Override + public boolean isDependencies() { + return true; + } + }); if (cancel != null && cancel.get()) { - set.clear(); + sourceSet.clear(); return; } if (el.getKind().isField()) { //get field references from index - set.addAll(idx.getResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.FIELD_REFERENCES), searchScopeType)); + if(isIncludeDependencies) { + sourceSet.addAll(idx.getBinaryResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.FIELD_REFERENCES), searchScopeType)); + } else { + sourceSet.addAll(idx.getResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.FIELD_REFERENCES), searchScopeType)); + } } else if (el.getKind().isClass() || el.getKind().isInterface()) { if (isFindSubclasses || isFindDirectSubclassesOnly) { if (isFindDirectSubclassesOnly) { //get direct implementors from index EnumSet searchKind = EnumSet.of(ClassIndex.SearchKind.IMPLEMENTORS); - set.addAll(idx.getResources(ElementHandle.create((TypeElement) el), searchKind, searchScopeType)); + if(isIncludeDependencies) { + sourceSet.addAll(idx.getBinaryResources(ElementHandle.create((TypeElement) el), searchKind, searchScopeType)); + } else { + sourceSet.addAll(idx.getResources(ElementHandle.create((TypeElement) el), searchKind, searchScopeType)); + } } else { //itererate implementors recursively - set.addAll(getImplementorsRecursive(idx, cpInfo, (TypeElement) el, cancel)); + sourceSet.addAll(getImplementorsRecursive(idx, cpInfo, (TypeElement) el, cancel)); } } else { //get type references from index - set.addAll(idx.getResources(ElementHandle.create((TypeElement) el), EnumSet.of(ClassIndex.SearchKind.TYPE_REFERENCES, ClassIndex.SearchKind.IMPLEMENTORS), searchScopeType)); + if(isIncludeDependencies) { + sourceSet.addAll(idx.getBinaryResources(ElementHandle.create((TypeElement) el), EnumSet.of(ClassIndex.SearchKind.TYPE_REFERENCES, ClassIndex.SearchKind.IMPLEMENTORS), searchScopeType)); + } else { + sourceSet.addAll(idx.getResources(ElementHandle.create((TypeElement) el), EnumSet.of(ClassIndex.SearchKind.TYPE_REFERENCES, ClassIndex.SearchKind.IMPLEMENTORS), searchScopeType)); + } } } else if (el.getKind() == ElementKind.METHOD) { ExecutableElement method = (ExecutableElement) el; @@ -319,14 +337,14 @@ } if (isFindOverridingMethods) { //Find overriding methods - set.addAll(getImplementorsRecursive(idx, cpInfo, enclosingTypeElement, cancel)); + sourceSet.addAll(getImplementorsRecursive(idx, cpInfo, enclosingTypeElement, cancel)); } if (isFindUsages) { //get method references for method and for all it's overriders Set> s = RefactoringUtils.getImplementorsAsHandles(idx, cpInfo, (TypeElement) method.getEnclosingElement(), cancel); for (ElementHandle eh : s) { if (cancel != null && cancel.get()) { - set.clear(); + sourceSet.clear(); return; } TypeElement te = eh.resolve(info); @@ -337,19 +355,31 @@ if (e.getKind() == ElementKind.METHOD || e.getKind() == ElementKind.CONSTRUCTOR) { for (ExecutableElement executableElement : methods) { if (info.getElements().overrides((ExecutableElement) e, executableElement, te)) { - set.addAll(idx.getResources(ElementHandle.create(te), EnumSet.of(ClassIndex.SearchKind.METHOD_REFERENCES), searchScopeType)); + if(!isIncludeDependencies) { + sourceSet.addAll(idx.getResources(ElementHandle.create(te), EnumSet.of(ClassIndex.SearchKind.METHOD_REFERENCES), searchScopeType)); + } else { + sourceSet.addAll(idx.getBinaryResources(ElementHandle.create(te), EnumSet.of(ClassIndex.SearchKind.METHOD_REFERENCES), searchScopeType)); + } } } } } } - set.addAll(idx.getResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.METHOD_REFERENCES), searchScopeType)); //????? + if(!isIncludeDependencies) { + sourceSet.addAll(idx.getResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.METHOD_REFERENCES), searchScopeType)); //????? + } else { + sourceSet.addAll(idx.getBinaryResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.METHOD_REFERENCES), searchScopeType)); //????? + } } } else if (el.getKind() == ElementKind.CONSTRUCTOR) { - set.addAll(idx.getResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.TYPE_REFERENCES, ClassIndex.SearchKind.IMPLEMENTORS), searchScopeType)); + if(isIncludeDependencies) { + sourceSet.addAll(idx.getBinaryResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.TYPE_REFERENCES, ClassIndex.SearchKind.IMPLEMENTORS), searchScopeType)); + } else { + sourceSet.addAll(idx.getResources(ElementHandle.create((TypeElement) el.getEnclosingElement()), EnumSet.of(ClassIndex.SearchKind.TYPE_REFERENCES, ClassIndex.SearchKind.IMPLEMENTORS), searchScopeType)); + } } else if((el.getKind().equals(ElementKind.LOCAL_VARIABLE) || el.getKind().equals(ElementKind.PARAMETER)) || el.getModifiers().contains(Modifier.PRIVATE)) { - set.add(file); + sourceSet.add(file); } } }; @@ -358,18 +388,22 @@ } catch (IOException ioe) { throw new RuntimeException(ioe); } + Set result = sourceSet; // filter out files that are not on source path - Set set2 = new HashSet<>(set.size()); - ClassPath cp = cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE); - for (FileObject fo : set) { - if (cp.contains(fo)) { - set2.add(fo); + if(!isIncludeDependencies) { + Set filteredSources = new HashSet<>(sourceSet.size()); + ClassPath cp = cpInfo.getClassPath(ClasspathInfo.PathKind.SOURCE); + for (FileObject fo : sourceSet) { + if (cp.contains(fo)) { + filteredSources.add(fo); + } + if (cancel != null && cancel.get()) { + return Collections.emptySet(); + } } - if (cancel != null && cancel.get()) { - return Collections.emptySet(); - } + result = filteredSources; } - return set2; + return result; } private static Collection getImplementorsRecursive(ClassIndex idx, ClasspathInfo cpInfo, TypeElement el, AtomicBoolean cancel) { @@ -395,7 +429,6 @@ return set2; } - //@Override @Override public Problem prepare(final RefactoringElementsBag elements) { fireProgressListenerStart(ProgressEvent.START, -1); @@ -476,6 +509,9 @@ private boolean isSearchFromBaseClass() { return refactoring.getBooleanValue(WhereUsedQueryConstants.SEARCH_FROM_BASECLASS); } + private boolean isSearchBinaries() { + return true; + } @Override public void addFilters(FiltersDescription filtersDescription) { @@ -493,6 +529,8 @@ ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/java/resources/found_item_source.png", false)); filtersDescription.addFilter(JavaWhereUsedFilters.TESTFILE.getKey(), "Test filter", true, ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/java/resources/found_item_test.png", false)); + filtersDescription.addFilter(JavaWhereUsedFilters.BINARYFILE.getKey(), "Binary filter", true, + ImageUtilities.loadImageIcon("org/netbeans/modules/refactoring/java/resources/found_item_binary.gif", false)); } private final EnumSet usedAccessFilters = EnumSet.noneOf(JavaWhereUsedFilters.ReadWrite.class); @@ -506,18 +544,17 @@ filtersDescription.enable(string); } } - + private class FindTask implements CancellableTask { private final RefactoringElementsBag elements; private volatile AtomicBoolean cancelled; public FindTask(RefactoringElementsBag elements) { - super(); this.elements = elements; this.cancelled = new AtomicBoolean(false); } - + @Override public void cancel() { cancelled.set(true); @@ -526,29 +563,51 @@ @Override public void run(CompilationController compiler) throws IOException { if (cancelled.get()) { - return ; + return; } if (compiler.toPhase(JavaSource.Phase.RESOLVED)!=JavaSource.Phase.RESOLVED) { return; } - CompilationUnitTree cu = compiler.getCompilationUnit(); - if (cu == null) { - ErrorManager.getDefault().log(ErrorManager.ERROR, "compiler.getCompilationUnit() is null " + compiler); // NOI18N - return; - } TreePathHandle handle = refactoring.getRefactoringSource().lookup(TreePathHandle.class); Element element = handle.resolveElement(compiler); if (element==null) { ErrorManager.getDefault().log(ErrorManager.ERROR, "element is null for handle " + handle); // NOI18N return; } - - final boolean fromTestRoot = RefactoringUtils.isFromTestRoot(compiler.getFileObject(), compiler.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE)); + CompilationUnitTree cu = compiler.getCompilationUnit(); + if (cu == null) { + FileObject fo = compiler.getFileObject(); + FileObject binaryRoot = null; + String resourceName = null; + ClassPath cp = ClassPath.getClassPath(fo, ClassPath.COMPILE); + if (cp == null || (binaryRoot = cp.findOwnerRoot(fo))==null) { + cp = ClassPath.getClassPath(fo, ClassPath.EXECUTE); + if (cp != null) { + resourceName = cp.getResourceName(fo,'.',false); //NOI18N + } + } else if (binaryRoot != null) { + resourceName = cp.getResourceName(fo,'.',false); //NOI18N + } + if (cancelled.get()) { + return; + } + final ElementHandle elHandle = resourceName != null ? ElementHandle.createTypeElementHandle(ElementKind.CLASS, resourceName.replace('/', '.')) : null; + elements.add(refactoring, WhereUsedElement.createBinary(compiler.getClasspathInfo(), elHandle, fo)); + usedFilters.add(JavaWhereUsedFilters.BINARYFILE.getKey()); + return; + } + final boolean fromBinary; + ClassPath srcPath = compiler.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE); + FileObject ownerRoot = srcPath.findOwnerRoot(compiler.getFileObject()); + fromBinary = ownerRoot == null || FileUtil.isArchiveFile(ownerRoot); + final boolean fromTestRoot = !fromBinary && RefactoringUtils.isFromTestRoot(compiler.getFileObject(), srcPath); AtomicBoolean inImport = new AtomicBoolean(); if (isFindUsages()) { - FindUsagesVisitor findVisitor = new FindUsagesVisitor(compiler, cancelled, refactoring.getBooleanValue(WhereUsedQuery.SEARCH_IN_COMMENTS), isSearchOverloadedMethods(), fromTestRoot, inImport); - findVisitor.scan(compiler.getCompilationUnit(), element); - Collection foundElements = findVisitor.getElements(); + Collection foundElements; + FindUsagesVisitor findVisitor = new FindUsagesVisitor(compiler, cancelled, refactoring.getBooleanValue(WhereUsedQuery.SEARCH_IN_COMMENTS), isSearchOverloadedMethods(), fromTestRoot, fromBinary, inImport); + findVisitor.scan(cu, element); + foundElements = findVisitor.getElements(); + boolean usagesInComments = findVisitor.usagesInComments(); for (WhereUsedElement el : foundElements) { final ReadWrite access = el.getAccess(); if(access != null) { @@ -560,12 +619,15 @@ if(fromTestRoot) { usedFilters.add(JavaWhereUsedFilters.TESTFILE.getKey()); } - if(!fromTestRoot) { + if(!fromTestRoot && !fromBinary) { usedFilters.add(JavaWhereUsedFilters.SOURCEFILE.getKey()); } - if(findVisitor.usagesInComments()) { + if(usagesInComments) { usedFilters.add(JavaWhereUsedFilters.COMMENT.getKey()); } + if(fromBinary) { + usedFilters.add(JavaWhereUsedFilters.BINARYFILE.getKey()); + } } } Collection result = new ArrayList<>(); @@ -580,16 +642,23 @@ result.addAll(subtypes.getUsages()); } for (TreePath tree : result) { - elements.add(refactoring, WhereUsedElement.create(compiler, tree, fromTestRoot, inImport)); + elements.add(refactoring, WhereUsedElement.create(compiler, tree, fromTestRoot, fromBinary, inImport)); } - if(fromTestRoot && !result.isEmpty()) { - usedFilters.add(JavaWhereUsedFilters.TESTFILE.getKey()); - } - if(!fromTestRoot && !result.isEmpty()) { - usedFilters.add(JavaWhereUsedFilters.SOURCEFILE.getKey()); - } - if(inImport.get()) { - usedFilters.add(JavaWhereUsedFilters.IMPORT.getKey()); + if(!result.isEmpty()) { + if(fromBinary) { + usedFilters.add(JavaWhereUsedFilters.BINARYFILE.getKey()); + } else { + if(fromTestRoot) { + usedFilters.add(JavaWhereUsedFilters.TESTFILE.getKey()); + } + if(!fromTestRoot) { + usedFilters.add(JavaWhereUsedFilters.SOURCEFILE.getKey()); + } + } + if(inImport.get()) { + usedFilters.add(JavaWhereUsedFilters.IMPORT.getKey()); + } + } fireProgressListenerStep(); } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/resources/found_item_binary.gif b/refactoring.java/src/org/netbeans/modules/refactoring/java/resources/found_item_binary.gif new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..56d4425d9430ac760f1015fc0018ba74468298de GIT binary patch literal 572 zc$@(|0>k}@P)>fb_e*gN(z{<+Xke6i3uwl1f|5Vgl5lg z4`**9B`lu*abP%mco8E&0D)cb?8Vz{q7nfN-+%rhO0&14Hp9xTcfo9c00JBE`}a=< z2gd-yY2n0ihQu%naAI1r;Tl*BAb?mPar}$n;nTN-{r~qbI5A}u&tPEs`??e)1`t5t zFfg!+B`Ga1{e4?{{?zt4K)oLT0tjpXFcyqS%*CJp_yE!i5MTg;Ql@l{jX^d50000< KMNUMnLSTZYj`02f diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaRefactoringPlugin.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaRefactoringPlugin.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaRefactoringPlugin.java @@ -45,27 +45,36 @@ import com.sun.source.tree.CompilationUnitTree; import java.io.IOException; +import java.net.URL; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeKind; import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.java.classpath.ClassPath; +import org.netbeans.api.java.platform.JavaPlatformManager; +import org.netbeans.api.java.queries.SourceForBinaryQuery; +import org.netbeans.api.java.source.*; import org.netbeans.api.java.source.ModificationResult.Difference; -import org.netbeans.api.java.source.*; import org.netbeans.modules.refactoring.api.AbstractRefactoring; import org.netbeans.modules.refactoring.api.Problem; import org.netbeans.modules.refactoring.java.RefactoringUtils; import org.netbeans.modules.refactoring.java.api.JavaRefactoringUtils; import org.netbeans.modules.refactoring.java.plugins.FindVisitor; import org.netbeans.modules.refactoring.java.plugins.JavaPluginUtils; +import org.netbeans.modules.refactoring.spi.ProgressProviderAdapter; import org.netbeans.modules.refactoring.spi.RefactoringCommit; -import org.netbeans.modules.refactoring.spi.ProgressProviderAdapter; import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; import org.netbeans.modules.refactoring.spi.RefactoringPlugin; import org.netbeans.modules.refactoring.spi.Transaction; +import org.netbeans.spi.java.classpath.support.ClassPathSupport; import org.openide.ErrorManager; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.filesystems.URLMapper; import org.openide.util.Exceptions; import org.openide.util.NbBundle; @@ -225,11 +234,11 @@ } } - private Iterable> groupByRoot (Iterable data) { - Map> result = new HashMap> (); - for (FileObject file : data) { + private Map> groupByRoot (Set sourceFiles) { + Map> result = new LinkedHashMap<> (); // Keep order, sources first! + for (FileObject file : sourceFiles) { if (cancelRequested.get()) { - return Collections.emptyList(); + return Collections.emptyMap(); } ClassPath cp = ClassPath.getClassPath(file, ClassPath.SOURCE); if (cp != null) { @@ -237,15 +246,27 @@ if (root != null) { List subr = result.get (root); if (subr == null) { - subr = new LinkedList(); + subr = new LinkedList<>(); result.put (root,subr); } subr.add (file); } + } else { + FileObject root = FileUtil.getArchiveFile(file); + if (root != null) { + List subr = result.get (root); + if (subr == null) { + subr = new LinkedList<>(); + result.put (root,subr); + } + subr.add(file); + } } } - return result.values(); - } + return result; + } + + private static final Logger LOG = Logger.getLogger(JavaRefactoringPlugin.class.getName()); protected final Collection processFiles(Set files, CancellableTask task) throws IOException { return processFiles(files, task, null); @@ -258,28 +279,61 @@ protected final void queryFiles(Set files, CancellableTask task) throws java.io.IOException { processFiles(files, task, null, false); } + + private static final ClassPath EMPTY_PATH = ClassPathSupport.createClassPath(new URL[0]); - private Collection processFiles(Set files, CancellableTask task, ClasspathInfo info, boolean modification) throws IOException { + private Collection processFiles(Set sourceFiles, CancellableTask task, ClasspathInfo info, boolean modification) throws IOException { currentTask = task; - Collection results = new LinkedList(); + Collection results = new LinkedList<>(); try { - Iterable> work = groupByRoot(files); - for (List fos : work) { - if (cancelRequested.get()) { - return Collections.emptyList(); - } - final JavaSource javaSource = JavaSource.create(info==null?ClasspathInfo.create(fos.get(0)):info, fos); - if (modification) { - results.add(javaSource.runModificationTask((CancellableTask)task)); // can throw IOException - } else { - javaSource.runUserActionTask(currentTask, true); - } - } + Map> work = groupByRoot(sourceFiles); + processFiles(work, info, modification, results, task); } finally { currentTask = null; } return results; } + + private void processFiles(Map> work, ClasspathInfo info, boolean modification, Collection results, CancellableTask task) throws IOException, IllegalArgumentException { + for (Map.Entry> entry : work.entrySet()) { + if (cancelRequested.get()) { + results.clear(); + return; + } + final FileObject root = entry.getKey(); + if (info == null) { + ClassPath bootPath = ClassPath.getClassPath(root, ClassPath.BOOT); + if (bootPath == null) { + //javac requires at least java.lang + bootPath = JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(); + } + ClassPath compilePath = ClassPath.getClassPath(root, ClassPath.COMPILE); + if (compilePath == null) { + compilePath = EMPTY_PATH; + } + ClassPath executePath = ClassPath.getClassPath(root, ClassPath.EXECUTE); + if (executePath == null) { + executePath = EMPTY_PATH; + } + ClassPath srcPath = ClassPath.getClassPath(root, ClassPath.SOURCE); + if (srcPath == null) { + srcPath = EMPTY_PATH; + } + info = ClasspathInfo.create( + bootPath, + ClassPathSupport.createProxyClassPath(compilePath,executePath), + srcPath); + } + final JavaSource javaSource = JavaSource.create(info, entry.getValue()); + if (modification) { + results.add(javaSource.runModificationTask((CancellableTask)task)); // can throw IOException + } else { + javaSource.runUserActionTask(currentTask, true); + } + } + } + + public static final String CLASS_MIME_TYPE = "application/x-class-file"; //NOI18N protected final Problem createAndAddElements(Set files, CancellableTask task, RefactoringElementsBag elements, AbstractRefactoring refactoring, ClasspathInfo info) { try { diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaWhereUsedFilters.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaWhereUsedFilters.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaWhereUsedFilters.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/JavaWhereUsedFilters.java @@ -55,7 +55,11 @@ /** * @since 1.54 */ - SOURCEFILE("filter-sourcefile"); + SOURCEFILE("filter-sourcefile"), + /** + * @since XXX + */ + BINARYFILE("filter-binaryfile"); private final String key; private JavaWhereUsedFilters(String key) { diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedPanel.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedPanel.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedPanel.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedPanel.java @@ -314,6 +314,10 @@ public boolean isSearchInComments() { return panel.isSearchInComments(); } + + public boolean isSearchInBinary() { + return true; + } @Override public Component getComponent() { diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/WhereUsedQueryUI.java @@ -138,6 +138,7 @@ @Override public org.netbeans.modules.refactoring.api.Problem setParameters() { query.putValue(WhereUsedQuery.SEARCH_IN_COMMENTS, panel.isSearchInComments()); + query.putValue(WhereUsedQuery.SEARCH_IN_BINARY, panel.isSearchInBinary()); // query.putValue(query., name); Scope customScope = panel.getCustomScope(); if (customScope != null) { diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FileTreeElement.java @@ -46,20 +46,26 @@ import java.awt.Image; import java.beans.BeanInfo; +import java.net.URISyntaxException; +import java.net.URL; import javax.swing.Icon; import javax.swing.ImageIcon; import org.netbeans.api.actions.Openable; +import org.netbeans.api.java.platform.JavaPlatform; +import org.netbeans.api.java.platform.JavaPlatformManager; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.modules.refactoring.spi.ui.TreeElement; import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; import org.openide.text.Line; import org.openide.text.NbDocument; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; +import org.openide.util.Utilities; /** * @@ -72,14 +78,53 @@ this.fo = fo; } - @Override public TreeElement getParent(boolean isLogical) { if (isLogical) { + if(FileUtil.isArchiveFile(fo)) { + FileObject root = FileUtil.getArchiveRoot(fo); + JavaPlatformManager manager = JavaPlatformManager.getDefault(); + for (JavaPlatform javaPlatform : manager.getInstalledPlatforms()) { + if(javaPlatform.getSourceFolders().contains(root) || + javaPlatform.getStandardLibraries().contains(root) || + javaPlatform.getBootstrapLibraries().contains(root)) { + return TreeElementFactory.getTreeElement(javaPlatform); + } + } + return TreeElementFactory.getTreeElement(FileOwnerQuery.getOwner(fo)); + } else { + return TreeElementFactory.getTreeElement(fo.getParent()); + } + } else { + if(FileUtil.isArchiveFile(fo)) { + FileObject root = FileUtil.getArchiveRoot(fo); + JavaPlatformManager manager = JavaPlatformManager.getDefault(); + for (JavaPlatform javaPlatform : manager.getInstalledPlatforms()) { + if(javaPlatform.getSourceFolders().contains(root) || + javaPlatform.getStandardLibraries().contains(root) || + javaPlatform.getBootstrapLibraries().contains(root)) { + return TreeElementFactory.getTreeElement(javaPlatform); + } + } + } + if(FileUtil.getArchiveFile(fo) != null) { + return TreeElementFactory.getTreeElement(FileUtil.getArchiveFile(fo)); + } + Project p = FileOwnerQuery.getOwner(fo); + if(p != null) { + return TreeElementFactory.getTreeElement(p); + } + Object orig = fo.getAttribute("orig-file"); + if(orig != null && orig instanceof URL) { + URL root = FileUtil.getArchiveFile((URL) orig); + try { + FileObject arch = FileUtil.toFileObject(Utilities.toFile(root.toURI())); + return TreeElementFactory.getTreeElement(arch); + } catch (URISyntaxException ex) { + return TreeElementFactory.getTreeElement(fo.getParent()); + } + } return TreeElementFactory.getTreeElement(fo.getParent()); - } else { - Project p = FileOwnerQuery.getOwner(fo); - return TreeElementFactory.getTreeElement(p != null ? p : fo.getParent()); } } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FolderTreeElement.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FolderTreeElement.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FolderTreeElement.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/FolderTreeElement.java @@ -76,6 +76,10 @@ if (sg!=null) { return TreeElementFactory.getTreeElement(sg); } else { + FileObject arch = FileUtil.getArchiveFile(fo); + if(arch != null) { + return TreeElementFactory.getTreeElement(arch); + } return null; } } else { @@ -83,6 +87,10 @@ if (p!=null) { return TreeElementFactory.getTreeElement(p); } else { + FileObject arch = FileUtil.getArchiveFile(fo); + if(arch != null) { + return TreeElementFactory.getTreeElement(arch); + } return null; } } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/SourceGroupTreeElement.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/JavaPlatformTreeElement.java copy from refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/SourceGroupTreeElement.java copy to refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/JavaPlatformTreeElement.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/SourceGroupTreeElement.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/JavaPlatformTreeElement.java @@ -44,52 +44,35 @@ package org.netbeans.modules.refactoring.java.ui.tree; -import java.awt.Image; -import java.beans.BeanInfo; -import java.lang.ref.WeakReference; import javax.swing.Icon; import javax.swing.ImageIcon; -import org.netbeans.api.project.FileOwnerQuery; -import org.netbeans.api.project.SourceGroup; +import org.netbeans.api.java.platform.JavaPlatform; import org.netbeans.modules.refactoring.spi.ui.TreeElement; -import org.netbeans.modules.refactoring.spi.ui.TreeElementFactory; -import org.openide.filesystems.FileObject; -import org.openide.loaders.DataObject; -import org.openide.loaders.DataObjectNotFoundException; import org.openide.util.ImageUtilities; /** * - * @author Jan Becicka + * @author Ralph Benjamin Ruijs */ -public class SourceGroupTreeElement implements TreeElement { +public class JavaPlatformTreeElement implements TreeElement { - private WeakReference sg; - private FileObject dir; - private Icon icon; - private String displayName; + private final JavaPlatform platform; + private final Icon icon; + private final String displayName; - private static String PACKAGE_BADGE = "org/netbeans/spi/java/project/support/ui/packageBadge.gif"; // NOI18N + private static final String PLATFORM_ICON = "org/netbeans/modules/java/platform/resources/platform.gif"; //NOI18N +// private static String PACKAGE_BADGE = "org/netbeans/spi/java/project/support/ui/packageBadge.gif"; // NOI18N - SourceGroupTreeElement(SourceGroup sg) { - this.sg = new WeakReference(sg); - dir = sg.getRootFolder(); - - icon = sg.getIcon(false); - if ( icon == null ) { - try { - Image image = DataObject.find(sg.getRootFolder()).getNodeDelegate().getIcon(BeanInfo.ICON_COLOR_16x16); - image = ImageUtilities.mergeImages( image, ImageUtilities.loadImage(PACKAGE_BADGE), 7, 7 ); - icon = new ImageIcon(image); - } catch (DataObjectNotFoundException d) { - } - } - displayName = sg.getDisplayName(); + JavaPlatformTreeElement(JavaPlatform platform) { + this.platform = platform; + + icon = new ImageIcon(ImageUtilities.loadImage(PLATFORM_ICON)); + displayName = platform.getDisplayName(); } @Override public TreeElement getParent(boolean isLogical) { - return TreeElementFactory.getTreeElement(FileOwnerQuery.getOwner(dir)); + return null; } @Override @@ -104,11 +87,7 @@ @Override public Object getUserObject() { - SourceGroup s = sg.get(); - if (s==null) { - s = FolderTreeElement.getSourceGroup(dir); - } - return s; + return platform; } } diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/TreeElementFactoryImpl.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/TreeElementFactoryImpl.java --- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/TreeElementFactoryImpl.java +++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/tree/TreeElementFactoryImpl.java @@ -46,12 +46,14 @@ import java.util.Map; import java.util.WeakHashMap; +import org.netbeans.api.java.platform.JavaPlatform; import org.netbeans.api.project.Project; import org.netbeans.api.project.SourceGroup; import org.netbeans.modules.refactoring.api.RefactoringElement; import org.netbeans.modules.refactoring.spi.ui.TreeElement; import org.netbeans.modules.refactoring.spi.ui.TreeElementFactoryImplementation; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; /** * @@ -104,6 +106,9 @@ result = new RefactoringTreeElement(refactoringElement); } } + else if (o instanceof JavaPlatform) { + result = new JavaPlatformTreeElement((JavaPlatform) o); + } if (result != null) { if (o instanceof SourceGroup) { map.put(((SourceGroup)o).getRootFolder(), result); diff --git a/refactoring.java/test/unit/data/SimpleJ2SEApp/build.xml b/refactoring.java/test/unit/data/SimpleJ2SEApp/build.xml --- a/refactoring.java/test/unit/data/SimpleJ2SEApp/build.xml +++ b/refactoring.java/test/unit/data/SimpleJ2SEApp/build.xml @@ -51,8 +51,7 @@ -init-macrodef-junit: defines macro for junit execution -init-macrodef-debug: defines macro for class debugging -init-macrodef-java: defines macro for class execution - -do-jar-with-manifest: JAR building (if you are using a manifest) - -do-jar-without-manifest: JAR building (if you are not using a manifest) + -do-jar: JAR building run: execution of project -javadoc-build: Javadoc generation test-report: JUnit report generation diff --git a/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/build-impl.xml b/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/build-impl.xml --- a/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/build-impl.xml +++ b/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/build-impl.xml @@ -12,14 +12,21 @@ - execution - debugging - javadoc - - junit compilation - - junit execution - - junit debugging + - test compilation + - test execution + - test debugging - applet - cleanup --> + + + + + + + @@ -144,19 +243,24 @@ - + + + - - + + - + + + + @@ -165,11 +269,55 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -186,44 +334,390 @@ Must set javac.includes - + + + - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + @@ -275,9 +769,13 @@ + + + + @@ -294,10 +792,15 @@ + + + + + @@ -310,20 +813,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + @@ -346,12 +919,18 @@ - + + + + + + + @@ -384,57 +963,67 @@ - - + + + - - + + + - - - - - - - To run this application from the command line without Ant, try: + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + - java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" + + + + + + - + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + - + - + + + + + + + + + + + + - + + + + + + + + + + + @@ -524,7 +1233,7 @@ @@ -537,8 +1246,8 @@ - - + + @@ -552,10 +1261,10 @@ - + Must select some files in the IDE or set javac.includes - + @@ -567,17 +1276,17 @@ - + - Some tests failed; see details above. + Some tests failed; see details above. @@ -587,39 +1296,40 @@ Must select some files in the IDE or set test.includes - + - Some tests failed; see details above. + Some tests failed; see details above. - + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + - + Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + - + + @@ -656,14 +1366,48 @@ CLEANUP SECTION =============== --> - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + diff --git a/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/genfiles.properties b/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/genfiles.properties --- a/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/genfiles.properties +++ b/refactoring.java/test/unit/data/SimpleJ2SEApp/nbproject/genfiles.properties @@ -1,8 +1,8 @@ build.xml.data.CRC32=407247cb -build.xml.script.CRC32=713af83b -build.xml.stylesheet.CRC32=958a1d3e@1.23.0.45 +build.xml.script.CRC32=f341e4b9 +build.xml.stylesheet.CRC32=8064a381@1.75.0.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=407247cb -nbproject/build-impl.xml.script.CRC32=fd053a58 -nbproject/build-impl.xml.stylesheet.CRC32=944d6f46@1.23.0.45 +nbproject/build-impl.xml.script.CRC32=8d7437a2 +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.0.48 diff --git a/refactoring.java/test/unit/data/SimpleJ2SEAppChild/build.xml b/refactoring.java/test/unit/data/SimpleJ2SEAppChild/build.xml --- a/refactoring.java/test/unit/data/SimpleJ2SEAppChild/build.xml +++ b/refactoring.java/test/unit/data/SimpleJ2SEAppChild/build.xml @@ -51,8 +51,7 @@ -init-macrodef-junit: defines macro for junit execution -init-macrodef-debug: defines macro for class debugging -init-macrodef-java: defines macro for class execution - -do-jar-with-manifest: JAR building (if you are using a manifest) - -do-jar-without-manifest: JAR building (if you are not using a manifest) + -do-jar: JAR building run: execution of project -javadoc-build: Javadoc generation test-report: JUnit report generation diff --git a/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/build-impl.xml b/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/build-impl.xml --- a/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/build-impl.xml +++ b/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/build-impl.xml @@ -12,9 +12,9 @@ - execution - debugging - javadoc - - junit compilation - - junit execution - - junit debugging + - test compilation + - test execution + - test debugging - applet - cleanup @@ -54,6 +54,7 @@ + @@ -71,16 +72,20 @@ - + - - + + + - - - + + + + + + @@ -91,12 +96,6 @@ - - - - - - @@ -115,24 +114,12 @@ - + - + - - - - - - - - - - - - @@ -156,6 +143,7 @@ + @@ -185,7 +173,15 @@ - + + + + + + + + + @@ -200,6 +196,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -253,6 +270,7 @@ + @@ -292,6 +310,7 @@ + @@ -332,11 +351,57 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -344,33 +409,277 @@ + + + - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -385,6 +694,7 @@ + @@ -401,10 +711,13 @@ - + Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + @@ -462,6 +775,7 @@ + @@ -478,6 +792,7 @@ + @@ -485,6 +800,7 @@ + @@ -511,12 +827,15 @@ + + + - - + + @@ -528,7 +847,7 @@ - + @@ -556,7 +875,7 @@ - + - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - + - + - + - + + + + + + @@ -693,23 +997,41 @@ - + To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" - + + + + + + + + + + + + + + + + + - + + - + + - + + + This target only works when run from inside the NetBeans IDE. @@ -787,8 +1113,9 @@ - + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. @@ -796,12 +1123,8 @@ - - + + This target only works when run from inside the NetBeans IDE. @@ -813,12 +1136,8 @@ - - + + This target only works when run from inside the NetBeans IDE. @@ -841,23 +1160,71 @@ + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + - + + + + + + + + + + + + - + + @@ -874,7 +1241,7 @@ @@ -917,14 +1284,14 @@ - + Some tests failed; see details above. @@ -937,39 +1304,40 @@ Must select some files in the IDE or set test.includes - + Some tests failed; see details above. + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + - + Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + @@ -1027,6 +1395,7 @@ + @@ -1041,9 +1410,12 @@ - - - + + + + + + diff --git a/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/genfiles.properties b/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/genfiles.properties --- a/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/genfiles.properties +++ b/refactoring.java/test/unit/data/SimpleJ2SEAppChild/nbproject/genfiles.properties @@ -1,8 +1,8 @@ build.xml.data.CRC32=25215185 -build.xml.script.CRC32=0fd72701 -build.xml.stylesheet.CRC32=28e38971@1.45.0.45 +build.xml.script.CRC32=8415a762 +build.xml.stylesheet.CRC32=8064a381@1.75.0.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=25215185 -nbproject/build-impl.xml.script.CRC32=fc65da55 -nbproject/build-impl.xml.stylesheet.CRC32=cfcde7f8@1.45.0.45 +nbproject/build-impl.xml.script.CRC32=7095e719 +nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.0.48 diff --git a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/FindUsagesFilterTest.java b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/FindUsagesFilterTest.java --- a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/FindUsagesFilterTest.java +++ b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/FindUsagesFilterTest.java @@ -266,7 +266,7 @@ Element el = javac.getTrees().getElement(tp); AtomicBoolean isCancelled = new AtomicBoolean(); AtomicBoolean inImport = new AtomicBoolean(); - r[0] = new FindUsagesVisitor(javac, isCancelled, searchInComments, false, false, inImport); + r[0] = new FindUsagesVisitor(javac, isCancelled, searchInComments, false, false, false, inImport); r[0].scan(cut, el); } }, true);