Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed key escaping; fixed list/map property extraction. #5535

Merged
merged 2 commits into from
Mar 27, 2023

Conversation

sdedic
Copy link
Member

@sdedic sdedic commented Feb 19, 2023

This PR initially started from reviewing this change as the intention was to un-escape ';' sequence to ';'. Then as I attempted to write tests, I've found a few rough edges of the BuildProperties API ...

Some highlights here, minor commnents inline in the diff.
1/ Gradle defines an extensibility 'ext' container for most domain object, where extra properties can be defined. After definition, they become 'part of' the domain object itself and can be referenced as such. Those extra properties were not exported in the project info. Now they're exported into the domain object's namespace.

2/ Structures (structured things that are not Maps) get their keys enumerated. Allows for introspection in NB IDE

@sdedic sdedic added Gradle [ci] enable "build tools" tests enterprise [ci] enable enterprise job labels Feb 19, 2023
@sdedic sdedic added this to the NB18 milestone Feb 19, 2023
@sdedic sdedic self-assigned this Feb 19, 2023
return;
}
if (clazz.isEnum() || clazz.isArray()) {
if (clazz.isArray() || (excludes == null && ignoreClassesPattern.matcher(clazz.getName()).matches())) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition for shortcut path remain the same; but now the implementation tries to export Maps and Lists. Covers the case when inspectObjectAndValues0 is called for e.g. java.util.HashMap object, which is otherwise excluded by filters - i.e. Map inside a Map.

defaultValues.put(prefix + propName + "." + k, Objects.toString(v)); // NOI18N
inspectObjectAndValues(v.getClass(), v, newPrefix, globalTypes, propertyTypes, defaultValues, null, false);
}
dumpContainerProperties(m, prefix + propName, defaultValues);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted into a method, to allow call from `inspectExtensions'.

dumped = true;
}
} else {
dumped = dumpValue(value, prefix + propName, propertyTypes, defaultValues, t, typeParameters);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted into a method so that inspectObjectAndValues can call that for j.u.HashMap from line 579

@@ -811,14 +885,23 @@ private void inspectExtensions(String prefix, ExtensionContainer container) {

Object ext;
try {
ext = project.getExtensions().getByName(extName);
ext = container.getByName(extName);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a bug !! The extension enumerated from a domain object was always looked up as extension of a project itself.

@sdedic sdedic force-pushed the gradle/list-map-properties branch from b3dca4a to 8afa04b Compare February 20, 2023 08:22
@sdedic
Copy link
Member Author

sdedic commented Feb 20, 2023

Rebased onto latest master; resolved conflicts with @tbw777 changes to NbProjectInfoBuilder

propertyTypes.merge(prefix + COLLECTION_KEYS_MARKER, String.join(";;", keys), (old, add) -> {
List<String> oldList = new ArrayList<>(Arrays.asList(old.split(";;")));
List<String> newList = Arrays.asList(add.split(";;"));
oldList.addAll(newList);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about ?
Collections.addAll(oldList, add.split(";;"));

@sdedic sdedic requested review from dbalek and lkishalmi February 20, 2023 09:43
@sdedic
Copy link
Member Author

sdedic commented Mar 3, 2023

ping ...

prop = support.findExtensionProperty("graalvmNative", "binaries.main.buildArgs");
assertEquals(BuildPropertiesSupport.PropertyKind.LIST, prop.getKind());
Iterable<BuildPropertiesSupport.Property> it = support.items(prop, null);
assertNotNull(it);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems redundant, next line will throw NPE if it == null and the test will fail

Copy link
Contributor

@dbalek dbalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

Copy link
Contributor

@lkishalmi lkishalmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Ok.

@sdedic sdedic force-pushed the gradle/list-map-properties branch from 8f0cfa2 to 773eca8 Compare March 27, 2023 10:15
@sdedic sdedic merged commit 6cc1721 into apache:master Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enterprise [ci] enable enterprise job Gradle [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants