generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Default value fixes in M3 compiler and reactivator #827
Open
aziemchawdhary-gs
wants to merge
15
commits into
finos:master
Choose a base branch
from
aziemchawdhary-gs:default_value_reactivator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6c16107
Set default values for calls to new in reactivator flow
aziemchawdhary-gs 3b603a8
Add more default values in test
aziemchawdhary-gs 39f5670
Fix test
aziemchawdhary-gs 392ba3c
Fix typo in Pure newObject instantiation
aziemchawdhary-gs aca7f9a
Add decimal to default value reactivator test
aziemchawdhary-gs c434c46
Set default values first and then override with user params
aziemchawdhary-gs fe96ce8
Support properties from inheritance and associations
aziemchawdhary-gs 6ea7bd8
Add default value association test
aziemchawdhary-gs 0a02215
TOFIX: association default value test
aziemchawdhary-gs e51086e
Remove redundant test
aziemchawdhary-gs 60c668c
Compilation failure for default value on associations
aziemchawdhary-gs 0af7378
Add failing compilation test assoc default values
aziemchawdhary-gs c0241cc
Handle default values after keyexpression processing
aziemchawdhary-gs dea7e4b
Assert on compilation exception
aziemchawdhary-gs b1a40ae
Move assoc prop defaultvalue check to validator
aziemchawdhary-gs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -34,6 +34,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.FunctionDefinition; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.LambdaFunction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.NativeFunction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.DefaultValue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.QualifiedProperty; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.multiplicity.Multiplicity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -55,6 +56,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.navigation.Instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.navigation.M3Paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.navigation.ProcessorSupport; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.navigation._class._Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m3.navigation.generictype.GenericType; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m4.coreinstance.CoreInstance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import org.finos.legend.pure.m4.coreinstance.SourceInformation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -721,13 +723,17 @@ public static Object newObject(Bridge bridge, org.finos.legend.pure.m3.coreinsta | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Class<?> c = ((CompiledExecutionSupport) es).getClassLoader().loadClass(JavaPackageAndImportBuilder.platformJavaPackage() + "." + Pure.elementToPath(aClass, "_", true) + "_Impl"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Any result = (Any) c.getConstructor(String.class).newInstance(name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MutableList<String> userAssignedParameters = Lists.mutable.empty(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
root_meta_pure_functions_lang_keyExpressions.forEach(new CheckedProcedure<KeyExpression>() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public void safeValue(KeyExpression o) throws Exception | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Object res = reactivate(o._expression(), new PureMap(Maps.fixedSize.empty()), bridge, es); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Method m = c.getMethod("_" + o._key()._values().getFirst(), RichIterable.class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
String key = (String) o._key()._values().getFirst(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
userAssignedParameters.add(key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Method m = c.getMethod("_" + key, RichIterable.class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (res instanceof RichIterable) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
m.invoke(result, res); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -736,9 +742,38 @@ public void safeValue(KeyExpression o) throws Exception | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
m.invoke(result, Lists.fixedSize.of(res)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RichIterable<CoreInstance> classProperties = _Class.getSimpleProperties(aClass, ((CompiledExecutionSupport) es).getProcessorSupport()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
classProperties.forEach(new CheckedProcedure<CoreInstance>() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
public void safeValue(CoreInstance p) throws Exception | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (!userAssignedParameters.contains(p.getName())) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Property<?, ?> prop = (Property<?, ?>) p; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DefaultValue defaultValue = prop._defaultValue(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (defaultValue != null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Object res = reactivate(defaultValue._functionDefinition()._expressionSequence().getFirst(), new PureMap(Maps.fixedSize.empty()), bridge, es); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Method method = c.getMethod("_" + prop._name(), RichIterable.class); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (res instanceof RichIterable) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
method.invoke(result, res); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
method.invoke(result, Lists.fixedSize.of(res)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+749
to
+772
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have methods now on AbstractCompiledCoreInstance for dealing with default values. Maybe result above can be cast directly to AbstractCompiledCoreInstance? In case it needs to be cast to Any above, I'm casting it in the suggestion below.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
catch (RuntimeException e) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.