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/12 04:55:07 UTC
[netbeans] branch master updated: [NETBEANS-4770] Handle source
type correctly in GradleSourcesImpl
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 15e311a [NETBEANS-4770] Handle source type correctly in GradleSourcesImpl
15e311a is described below
commit 15e311afa79c92b6d72c2db690b929b0ca5c66df
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Thu Sep 3 07:44:58 2020 -0700
[NETBEANS-4770] Handle source type correctly in GradleSourcesImpl
---
.../modules/gradle/NbGradleProjectImpl.java | 3 ++-
.../gradle/java/classpath/GradleSourcesImpl.java | 31 +++++++++++++++-------
.../gradle/java/nodes/SourcesNodeFactory.java | 11 ++++++--
3 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java b/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
index 6f29dab..0801593 100644
--- a/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
+++ b/extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
@@ -165,11 +165,12 @@ public final class NbGradleProjectImpl implements Project {
aux,
aux.getProblemProvider(),
new GradleAuxiliaryPropertiesImpl(this),
- new GradleSharabilityQueryImpl(this),
UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()),
UILookupMergerSupport.createProjectProblemsProviderMerger(),
UILookupMergerSupport.createRecommendedTemplatesMerger(),
UILookupMergerSupport.createPrivilegedTemplatesMerger(),
+ LookupProviderSupport.createSourcesMerger(),
+ LookupProviderSupport.createSharabilityQueryMerger(),
state
);
}
diff --git a/java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImpl.java b/java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImpl.java
index 5dda8c2..e2db217 100644
--- a/java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImpl.java
+++ b/java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/GradleSourcesImpl.java
@@ -107,6 +107,8 @@ import org.openide.util.Pair;
public class GradleSourcesImpl implements Sources, SourceGroupModifierImplementation {
private static final Map<String, String> COMMON_NAMES = new HashMap<>();
+ public static final String SOURCE_TYPE_GROOVY = "groovy"; //NOI18N
+ public static final String SOURCE_TYPE_GENERATED = "generated"; //NOI18N
static {
COMMON_NAMES.put("main.JAVA", "01main.java");
@@ -153,23 +155,24 @@ public class GradleSourcesImpl implements Sources, SourceGroupModifierImplementa
if (Sources.TYPE_GENERIC.equals(type)) {
return new SourceGroup[]{new GradleSourceGroup(proj.getProjectDirectory(), "ProjectRoot", //NOI18N
ProjectUtils.getInformation(proj).getDisplayName())};
- } else {
- checkChanges(false);
+ }
+ checkChanges(false);
+ SourceType stype = soureType2SourceType(type);
+ if (stype != null) {
ArrayList<SourceGroup> ret = new ArrayList<>();
for (String group : gradleSources.keySet()) {
- for (SourceType langType : SourceType.values()) {
- Set<File> dirs = gradleSources.get(group).getSourceDirs(langType);
- boolean unique = dirs.size() == 1;
- for (File dir : dirs) {
- if (dir.isDirectory()) {
- ret.add(createSourceGroup(unique, group, dir, langType));
- }
+ Set<File> dirs = gradleSources.get(group).getSourceDirs(stype);
+ boolean unique = dirs.size() == 1;
+ for (File dir : dirs) {
+ if (dir.isDirectory()) {
+ ret.add(createSourceGroup(unique, group, dir, stype));
}
}
}
Collections.sort(ret, Comparator.comparing(SourceGroup::getName));
return ret.toArray(new SourceGroup[ret.size()]);
}
+ return new SourceGroup[0];
}
SourceGroup createSourceGroup(boolean unique, String group, File dir,
@@ -331,6 +334,16 @@ public class GradleSourcesImpl implements Sources, SourceGroupModifierImplementa
return ret && gp.getSourceSets().containsKey(hint);
}
+ private static SourceType soureType2SourceType(String type) {
+ switch (type) {
+ case JavaProjectConstants.SOURCES_TYPE_JAVA: return SourceType.JAVA;
+ case JavaProjectConstants.SOURCES_TYPE_RESOURCES: return SourceType.RESOURCES;
+ case SOURCE_TYPE_GENERATED: return SourceType.GENERATED;
+ case SOURCE_TYPE_GROOVY: return SourceType.GROOVY; // Should be in the Groovy support module theoretically
+ }
+ return null;
+ }
+
private final class GradleSourceGroup implements SourceGroup {
private final FileObject rootFolder;
diff --git a/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/SourcesNodeFactory.java b/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/SourcesNodeFactory.java
index 8cb7571..ee5ffdd 100644
--- a/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/SourcesNodeFactory.java
+++ b/java/gradle.java/src/org/netbeans/modules/gradle/java/nodes/SourcesNodeFactory.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import org.netbeans.modules.gradle.api.NbGradleProject;
import org.netbeans.modules.gradle.spi.nodes.AbstractGradleNodeList;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -34,6 +35,7 @@ import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.api.project.SourceGroup;
import org.netbeans.api.project.Sources;
+import org.netbeans.modules.gradle.java.classpath.GradleSourcesImpl;
import org.netbeans.spi.java.project.support.ui.PackageView;
import org.netbeans.spi.project.ui.support.NodeFactory;
import org.netbeans.spi.project.ui.support.NodeList;
@@ -69,8 +71,13 @@ public final class SourcesNodeFactory implements NodeFactory {
@Override
public List<SourceGroup> keys() {
Sources srcs = ProjectUtils.getSources(project);
- SourceGroup[] javagroup = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
- return Arrays.asList(javagroup);
+ List<SourceGroup> ret = new ArrayList<>();
+ ret.addAll(Arrays.asList(srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)));
+ ret.addAll(Arrays.asList(srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES)));
+ ret.addAll(Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_GENERATED)));
+ ret.addAll(Arrays.asList(srcs.getSourceGroups(GradleSourcesImpl.SOURCE_TYPE_GROOVY)));
+ ret.sort(Comparator.comparing(SourceGroup::getName));
+ return ret;
}
@NbBundle.Messages({
---------------------------------------------------------------------
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