You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/11/03 10:32:30 UTC
[GitHub] [netbeans] sdedic commented on a change in pull request #3291: Handle generated sources during native image debugging.
sdedic commented on a change in pull request #3291:
URL: https://github.com/apache/netbeans/pull/3291#discussion_r741803632
##########
File path: java/java.project/src/org/netbeans/api/java/project/JavaProjectConstants.java
##########
@@ -46,6 +46,13 @@ private JavaProjectConstants() {}
*/
public static final String SOURCES_TYPE_MODULES = "modules"; // NOI18N
+ /**
+ * Generated root sources type.
+ * @see org.netbeans.api.project.Sources
+ * @since 1.88
+ */
+ public static final String SOURCES_TYPE_GENERATED = "generated"; // NOI18N
Review comment:
Note that other languages may also generate sources; e.g. in Gradle build, one can easily have `build/generated-sources/groovy/...` or kotlin. There's sadly not an is-a formal hierarchy among source types, although Gradle/Groovy support provides one (retursn Groovy source root for "java" query) - but maybe we could declare "java-resources" from the start here ?
@JaroslavTulach ?
##########
File path: java/java.nativeimage.debugger/src/org/netbeans/modules/java/nativeimage/debugger/displayer/JavaFrameDisplayer.java
##########
@@ -161,35 +162,44 @@ private static ClassPath findSourcePath(Project project) {
List<FileObject> allSourceRoots = new ArrayList<>();
Set<FileObject> preferredRoots = new HashSet<>();
Set<FileObject> addedBinaryRoots = new HashSet<>();
- SourceGroup[] sgs = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
- for (SourceGroup sg : sgs) {
- ClassPath ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE);
- if (ecp == null) {
- ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE);
- }
- if (ecp != null) {
- FileObject[] binaryRoots = ecp.getRoots();
- for (FileObject fo : binaryRoots) {
- if (addedBinaryRoots.contains(fo)) {
- continue;
- }
- addedBinaryRoots.add(fo);
- FileObject[] roots = SourceForBinaryQuery.findSourceRoots(fo.toURL()).getRoots();
- for (FileObject fr : roots) {
- if (!preferredRoots.contains(fr)) {
- allSourceRoots.add(fr);
- preferredRoots.add(fr);
- }
- }
- }
- }
+ Sources sources = ProjectUtils.getSources(project);
+ SourceGroup[] sgs = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
+ addSourceRoots(sgs, allSourceRoots, preferredRoots, addedBinaryRoots);
+ sgs = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_GENERATED);
+ if (sgs != null) {
+ addSourceRoots(sgs, allSourceRoots, preferredRoots, addedBinaryRoots);
}
return createClassPath(allSourceRoots);
} else {
return null;
}
}
+ private static void addSourceRoots(SourceGroup[] sgs, List<FileObject> allSourceRoots, Set<FileObject> preferredRoots, Set<FileObject> addedBinaryRoots) {
+ for (SourceGroup sg : sgs) {
+ ClassPath ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE);
+ if (ecp == null) {
+ ecp = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.SOURCE);
+ }
+ if (ecp != null) {
+ FileObject[] binaryRoots = ecp.getRoots();
+ for (FileObject fo : binaryRoots) {
+ if (addedBinaryRoots.contains(fo)) {
+ continue;
+ }
+ addedBinaryRoots.add(fo);
+ FileObject[] roots = SourceForBinaryQuery.findSourceRoots(fo.toURL()).getRoots();
+ for (FileObject fr : roots) {
+ if (!preferredRoots.contains(fr)) {
Review comment:
It seems that `preferredSourceRoots` is just an optimization for `contains` -- what if the `allSourceRoots` would be a `LinkedHashMap` ?
##########
File path: java/maven/src/org/netbeans/modules/maven/classpath/MavenSourcesImpl.java
##########
@@ -78,7 +78,7 @@
public class MavenSourcesImpl implements Sources, SourceGroupModifierImplementation, OtherSourcesExclude {
public static final String TYPE_OTHER = "Resources"; //NOI18N
public static final String TYPE_TEST_OTHER = "TestResources"; //NOI18N
- public static final String TYPE_GEN_SOURCES = "GeneratedSources"; //NOI18N
Review comment:
This may lead to a possible incompatibility, if someone looks for "GeneratedSources". Would it be possible to handle both type strings ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists