|
|
|
|
|
Re: Cross reference, Qualified name and scoping [message #1783666 is a reply to message #1349676] |
Thu, 15 March 2018 10:42 |
Denis Nikiforov Messages: 344 Registered: August 2013 |
Senior Member |
|
|
Hi
I have the following rule for qualified names:
QualifiedName:
((catalogName=ID '.')? schemaName=ID '.')? identifier=ID;
And I can't use it for cross-references because it's not a data rule returning EString.
Also in my language the following idnetifiers are the same: dbo.person, "dbo".person, dbo.PERSON
I think I need to transform them into a canonicial form before comparision or implement a custom comparision.
Could you suggest how to implement it?
For now I have the following scope provider:
class SQLScopeProvider implements IScopeProvider {
override getScope(EObject context, EReference reference) {
if (context instanceof ReferencesColumnConstraint) {
if (reference == SqlPackage.eINSTANCE.referencesColumnConstraint_ReferredTableName) {
val rootElement = EcoreUtil2.getRootContainer(context)
val candidates = EcoreUtil2.getAllContentsOfType(rootElement, TableDefinition)
return new SimpleScope(candidates.map[EObjectDescription.create(it.tableName.fullyQualifiedName, it)])
}
else if (reference == SqlPackage.eINSTANCE.referencesColumnConstraint_ReferredColumnNames) {
if (context.referredTableName !== null) {
val rootElement = context.referredTableName
val candidates = EcoreUtil2.getAllContentsOfType(rootElement, ColumnDefinition)
return new SimpleScope(candidates.map[EObjectDescription.create(it.name, it)])
}
}
}
}
def QualifiedName getFullyQualifiedName(TableName obj) {
if (obj.schemaName === null) {
QualifiedName.create(obj.identifier)
}
else if (obj.catalogName === null) {
QualifiedName.create(obj.schemaName, obj.identifier)
}
else {
QualifiedName.create(obj.catalogName, obj.schemaName, obj.identifier)
}
}
}
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03660 seconds