Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ public static boolean isSourceLauncherFile(FileObject file) {
return msrp != null && msrp.isSourceLauncher(file);
}

/**Returns {@code true} if and only if the given file is known as a
* file that is handled by a source file launcher, for which index is created.
*
* @param file the file to test
* @return {@code true} if and only if the file is known as a file handled by the
* source launcher. {@code false} otherwise.
*/
public static boolean isIndexedSourceLauncherFile(FileObject file) {
MultiSourceRootProvider msrp = Lookup.getDefault().lookup(MultiSourceRootProvider.class);
return msrp != null && msrp.isRegisteredSourceLauncher(file);
}

public static String joinCommandLines(Iterable<? extends String> inputLines) {
Map<String, String> joinedOptions = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ public boolean isSourceLauncher(FileObject file) {
return getSourceRoot(file) != null;
}

public boolean isRegisteredSourceLauncher(FileObject file) {
FileObject root = getSourceRoot(file);

if (root == null) {
return false;
}

synchronized (registeredRoots) {
return registeredRoots.contains(root);
}
}

private ClassPath getBootPath(FileObject file) {
if (isSourceLauncher(file)) {
return JavaPlatformManager.getDefault()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public static boolean isFileInOpenProject(FileObject file) {
public static boolean isOnSourceClasspath(FileObject fo) {
Project pr = FileOwnerQuery.getOwner(fo);
if (pr == null) {
return SourceLauncher.isSourceLauncherFile(fo);
return isIndexedSourceLauncherFile(fo);
}

//workaround for 143542
Expand All @@ -321,6 +321,11 @@ public static boolean isOnSourceClasspath(FileObject fo) {
//return ClassPath.getClassPath(fo, ClassPath.SOURCE)!=null;
}

public static boolean isIndexedSourceLauncherFile(FileObject fo) {
// TODO: don't call from this module
return SourceLauncher.isIndexedSourceLauncherFile(fo);
}

/**
* Is given file a root of source classpath?
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.datatransfer.PasteType;

import static org.netbeans.modules.refactoring.java.ui.Bundle.*;


Expand Down Expand Up @@ -185,7 +186,7 @@ public boolean canCopy(Lookup lookup) {
if (!fo.isFolder()) {
return false;
}
if (!JavaRefactoringUtils.isOnSourceClasspath(fo)) {
if (!JavaRefactoringUtils.isOnSourceClasspath(fo) || RefactoringUtils.isIndexedSourceLauncherFile(fo)) {
return false;
}
}
Expand Down Expand Up @@ -331,7 +332,7 @@ public boolean canMove(Lookup lookup) {
if (!fo.isFolder()) {
return false;
}
if (!JavaRefactoringUtils.isOnSourceClasspath(fo)) {
if (!JavaRefactoringUtils.isOnSourceClasspath(fo) || RefactoringUtils.isIndexedSourceLauncherFile(fo)) {
return false;
}

Expand All @@ -343,7 +344,8 @@ public boolean canMove(Lookup lookup) {
if (dob==null) {
return false;
}
if (!JavaRefactoringUtils.isOnSourceClasspath(dob.getPrimaryFile())) {
if (!JavaRefactoringUtils.isOnSourceClasspath(dob.getPrimaryFile())
|| RefactoringUtils.isIndexedSourceLauncherFile(dob.getPrimaryFile())) {
return false;
}
if (dob instanceof DataFolder) {
Expand Down Expand Up @@ -380,7 +382,9 @@ public boolean canMove(Lookup lookup) {
return false;
} else {
//Ctrl-X
if (!JavaRefactoringUtils.isOnSourceClasspath(dob.getPrimaryFile()) || RefactoringUtils.isClasspathRoot(dob.getPrimaryFile())) {
if (!JavaRefactoringUtils.isOnSourceClasspath(dob.getPrimaryFile())
|| RefactoringUtils.isClasspathRoot(dob.getPrimaryFile())
|| RefactoringUtils.isIndexedSourceLauncherFile(dob.getPrimaryFile())) {
return false;
} else {
LinkedList<DataFolder> folders = new LinkedList<DataFolder>();
Expand All @@ -399,7 +403,8 @@ public boolean canMove(Lookup lookup) {
}
}
}
if (!JavaRefactoringUtils.isOnSourceClasspath(dob.getPrimaryFile())) {
if (!JavaRefactoringUtils.isOnSourceClasspath(dob.getPrimaryFile())
|| RefactoringUtils.isIndexedSourceLauncherFile(dob.getPrimaryFile())) {
return false;
}
if (RefactoringUtils.isJavaFile(dob.getPrimaryFile())) {
Expand Down