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

Mark org as Pure Reserved Keyword #2387

Merged
merged 7 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -513,12 +513,18 @@ function meta::protocols::generation::java::conventions(purePackage:String[1], j
| '.' + $packageStr;
);
pair(
$c->identifier($package),
buildIdentifierFactory($package),
$c->identifier($x.name->toOne())->toUpperFirstCharacter()->toOne()
);}
);
}

function <<access.private>> meta::protocols::generation::java::buildIdentifierFactory(name: String[1]):String[1]
mrudula-gs marked this conversation as resolved.
Show resolved Hide resolved
{
let keywordMap = javaKeywords()->map(kw | pair($kw, '_' + $kw))->newMap();
$name->sanitizeIdentifier($keywordMap);
}

function meta::protocols::generation::java::addProvidedTypesFromDependencies(conventions: Conventions[1], dependencies: Configuration[*]): Conventions[1]
{
$dependencies->fold({config: Configuration[1], c1: Conventions[1] |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ meta::pure::mapping::modelToModel::test::alloy::constraints::testQueryOnTypeWith
assert(jsonEquivalent('{"name":"FirmX"}'->parseJSON(), $result.values->toOne()->parseJSON()));
}

function <<meta::pure::profiles::test.Test, meta::pure::profiles::test.AlloyOnly>>
{ serverVersion.start='v1_19_0' }
meta::pure::mapping::modelToModel::test::alloy::constraints::testGraphFetchWithPackageConflictingPropertyName():Boolean[1]
{
let result = execute( |Firm.all()->graphFetchChecked(#{Firm {organization} }#)->serialize(#{Firm {organization} }#),
m2mconstraintmapping1,
^Runtime(
connectionStores = ^ConnectionStore(
element=^ModelStore(),
connection= ^JsonModelConnection(
class=_Firm,
url='data:application/json,{"name":"FirmX","org":"orgA"}'
)
)
),
meta::pure::extension::defaultExtensions()
);
assert(jsonEquivalent('{"defects":[{"path":[],"enforcementLevel":"Error","ruleType":"ClassConstraint","externalId":null,"id":"0","ruleDefinerPath":"meta::pure::mapping::modelToModel::test::alloy::constraints::Firm","message":"Constraint :[0] violated in the Class Firm"}],"source":{"defects":[],"source":{"number":1,"record":"{\\"name\\":\\"FirmX\\",\\"org\\":\\"orgA\\"}"},"value":{"org":"orgA","employees":[]}},"value":{"organization":"orgA"}}'->parseJSON(), $result.values->toOne()->parseJSON()));
}

function <<meta::pure::profiles::test.Test, meta::pure::profiles::test.AlloyOnly>>
{ serverVersion.start='v1_19_0' }
meta::pure::mapping::modelToModel::test::alloy::constraints::testQueryOnSourceTypeWithFailingConstraintSucceedsWithConstraintsDisabled():Boolean[1]
Expand Down Expand Up @@ -386,6 +406,7 @@ Class meta::pure::mapping::modelToModel::test::alloy::constraints::Firm
{
name: String[1];
employees: meta::pure::mapping::modelToModel::test::alloy::constraints::Person[*];
organization: String[1];
}

Class meta::pure::mapping::modelToModel::test::alloy::constraints::Firm2
Expand All @@ -403,6 +424,7 @@ Class meta::pure::mapping::modelToModel::test::alloy::constraints::_Firm
{
name: String[1];
employees:meta::pure::mapping::modelToModel::test::alloy::constraints::_Person[*];
org: String[1];
}

Class meta::pure::mapping::modelToModel::test::alloy::constraints::_Firm2
Expand Down Expand Up @@ -680,7 +702,8 @@ Mapping meta::pure::mapping::modelToModel::test::alloy::constraints::m2mconstrai
{
~src meta::pure::mapping::modelToModel::test::alloy::constraints::_Firm
name: $src.name,
employees: $src.employees
employees: $src.employees,
organization: $src.org
}

meta::pure::mapping::modelToModel::test::alloy::constraints::Person: Pure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ function <<access.private>> meta::external::language::java::transform::buildIden

function <<access.private>> meta::external::language::java::transform::buildJavaKeywordReplacementMap():Map<String, String>[1]
{
javaKeywords()->map(kw | pair($kw, '_' + $kw))->newMap()
reservedKeywords()->map(kw | pair($kw, '_' + $kw))->newMap()
mrudula-gs marked this conversation as resolved.
Show resolved Hide resolved
}

function meta::external::language::java::transform::setBasePackageName(conventions:Conventions[1], name:String[1]): Conventions[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,16 @@ function meta::external::language::java::metamodel::javaKeywords(): String[*]
];
}

function meta::external::language::java::metamodel::modelPropertyKeywords(): String[*]
{
['com', 'org'];
}

function meta::external::language::java::metamodel::reservedKeywords(): String[*]
{
javaKeywords()->concatenate(modelPropertyKeywords());
}

function meta::external::language::java::metamodel::isJavaLang(pkg: meta::external::language::java::metamodel::Package[1]):Boolean[1]
{
$pkg.name == 'lang'
Expand Down
Loading