org.openxma.dsl.ddl.scoping.DdlDslScopeProvider Maven / Gradle / Ivy
/*
* generated by Xtext
*/
package org.openxma.dsl.ddl.scoping;
import static org.eclipse.xtext.scoping.Scopes.scopedElementsFor;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
import org.eclipse.xtext.scoping.impl.SimpleScope;
import org.openxma.dsl.ddl.ddlDsl.AddTableConstraint;
import org.openxma.dsl.ddl.ddlDsl.Alter;
import org.openxma.dsl.ddl.ddlDsl.AlterTableAction;
import org.openxma.dsl.ddl.ddlDsl.CreateIndex;
import org.openxma.dsl.ddl.ddlDsl.CreateTable;
import org.openxma.dsl.ddl.ddlDsl.ForeignKeyConstraint;
import org.openxma.dsl.ddl.ddlDsl.PrimaryKeyConstraint;
import org.openxma.dsl.ddl.ddlDsl.ReferenceClause;
import org.openxma.dsl.ddl.ddlDsl.UniqueKeyConstraint;
/**
* This class contains custom scoping description.
*
* see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping on
* how and when to use it
*
*/
public class DdlDslScopeProvider extends AbstractDeclarativeScopeProvider {
public IScope scope_CreateIndex_columns(CreateIndex indexDefinition,
EReference eReference) {
return new SimpleScope(scopedElementsFor((indexDefinition.getTable()
.getProperties())));
}
public IScope scope_UniqueKeyConstraint_columns(
UniqueKeyConstraint unqiueKeyConstraint,
EReference eReference) {
if (unqiueKeyConstraint.eContainer() instanceof AlterTableAction) {
AlterTableAction alterTableAction = (AlterTableAction) unqiueKeyConstraint
.eContainer();
Alter alterTable = (Alter) alterTableAction.eContainer();
return new SimpleScope(scopedElementsFor((alterTable.getTable()
.getProperties())));
} else if (unqiueKeyConstraint.eContainer() instanceof CreateTable) {
CreateTable CreateTable = (CreateTable) unqiueKeyConstraint
.eContainer();
return new SimpleScope(scopedElementsFor((CreateTable
.getProperties())));
}
return IScope.NULLSCOPE;
}
public IScope scope_PrimaryKeyConstraint_columns(
PrimaryKeyConstraint primaryKeyConstraint,
EReference eReference) {
if (primaryKeyConstraint.eContainer() instanceof AlterTableAction) {
AlterTableAction alterTableAction = (AlterTableAction) primaryKeyConstraint
.eContainer();
Alter alterTable = (Alter) alterTableAction.eContainer();
return new SimpleScope(scopedElementsFor((alterTable.getTable()
.getProperties())));
} else if (primaryKeyConstraint.eContainer() instanceof CreateTable) {
CreateTable CreateTable = (CreateTable) primaryKeyConstraint
.eContainer();
return new SimpleScope(scopedElementsFor((CreateTable
.getProperties())));
}
return IScope.NULLSCOPE;
}
public IScope scope_ForeignKeyConstraint_columns(
ForeignKeyConstraint foreignKeyConstraint, EReference eReference) {
if (foreignKeyConstraint.eContainer() instanceof AddTableConstraint) {
AddTableConstraint addTableConstraint = (AddTableConstraint) foreignKeyConstraint
.eContainer();
Alter alterTable = (Alter) addTableConstraint
.eContainer();
return new SimpleScope(scopedElementsFor((alterTable.getTable()
.getProperties())));
}
return IScope.NULLSCOPE;
}
public IScope scope_ReferenceClause_columns(
ReferenceClause foreignKeyConstraint, EReference eReference) {
return new SimpleScope(scopedElementsFor((foreignKeyConstraint
.getTable().getProperties())));
}
}