You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2020/09/09 16:40:46 UTC
[netbeans] branch master updated: [NETBEANS-4696] maven project
open use no-lock getModuleName
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 7ec3aac [NETBEANS-4696] maven project open use no-lock getModuleName
7ec3aac is described below
commit 7ec3aacc3c6c951b68e6924d4c3246dd7886342d
Author: Ernie Rael <er...@raelity.com>
AuthorDate: Wed Sep 2 20:58:06 2020 +0100
[NETBEANS-4696] maven project open use no-lock getModuleName
---
.../queries/UnitTestsCompilerOptionsQueryImpl.java | 36 ++--------------------
1 file changed, 2 insertions(+), 34 deletions(-)
diff --git a/java/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java b/java/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
index 2a424af..4b79aee 100644
--- a/java/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
+++ b/java/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
@@ -18,13 +18,9 @@
*/
package org.netbeans.modules.maven.queries;
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.tree.ModuleTree;
-import com.sun.source.tree.Tree;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -33,15 +29,13 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.NullAllowed;
import org.netbeans.api.java.queries.SourceLevelQuery;
-import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.SourceUtils;
import org.netbeans.modules.maven.NbMavenProjectImpl;
import org.netbeans.modules.maven.api.NbMavenProject;
import static org.netbeans.modules.maven.classpath.ClassPathProviderImpl.MODULE_INFO_JAVA;
@@ -64,7 +58,6 @@ import org.openide.util.WeakListeners;
* @see org.netbeans.modules.java.api.common.queries.UnitTestsCompilerOptionsQueryImpl
*/
public final class UnitTestsCompilerOptionsQueryImpl implements CompilerOptionsQueryImplementation {
- private static final Logger LOG = Logger.getLogger(UnitTestsCompilerOptionsQueryImpl.class.getName());
private static final SpecificationVersion JDK9 = new SpecificationVersion("9"); //NOI18N
private final AtomicReference<ResultImpl> result;
@@ -282,32 +275,7 @@ public final class UnitTestsCompilerOptionsQueryImpl implements CompilerOptionsQ
@CheckForNull
private static String getModuleName(@NonNull final FileObject moduleInfo) {
- try {
- final String[] res = new String[1];
- final JavaSource src = JavaSource.forFileObject(moduleInfo);
- if (src != null) {
- src.runUserActionTask((cc) -> {
- cc.toPhase(JavaSource.Phase.PARSED);
- final CompilationUnitTree cu = cc.getCompilationUnit();
- for (Tree decl : cu.getTypeDecls()) {
- if (decl.getKind().name().equals("MODULE")) {
- res[0] = ((ModuleTree)decl).getName().toString();
- break;
- }
- }
- }, true);
- }
- return res[0];
- } catch (IOException ioe) {
- LOG.log(
- Level.WARNING,
- "Cannot read module declaration in: {0} due to: {1}", //NOI18N
- new Object[]{
- FileUtil.getFileDisplayName(moduleInfo),
- ioe.getMessage()
- });
- return null;
- }
+ return SourceUtils.parseModuleName(moduleInfo);
}
private static enum TestMode {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists