本文整理汇总了Java中org.eclipse.xtext.XtextPackage类的典型用法代码示例。如果您正苦于以下问题:Java XtextPackage类的具体用法?Java XtextPackage怎么用?Java XtextPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XtextPackage类属于org.eclipse.xtext包,在下文中一共展示了XtextPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInjectorAndDoEMFRegistration
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
@Override
public Injector createInjectorAndDoEMFRegistration() {
// register default ePackages
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"ecore", new EcoreResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xmi", new XMIResourceFactoryImpl());
if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
"xtextbin", new BinaryGrammarResourceFactoryImpl());
if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);
Injector injector = createInjector();
register(injector);
return injector;
}
示例2: processMetamodelDeclarations
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
private void processMetamodelDeclarations(Collection<AbstractMetamodelDeclaration> declarations, ResourceSet resourceSet,
Collection<Resource> resourcesToRemove, Collection<Resource> resourcesToUnload,
Collection<Resource> referencedResources) {
for (AbstractMetamodelDeclaration declaration : declarations) {
EPackage pack = (EPackage) declaration.eGet(XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE, false);
if (pack != null && !pack.eIsProxy()) {
Resource packResource = pack.eResource();
if (packResource != null) {
resourcesToRemove.add(packResource);
if (declaration instanceof ReferencedMetamodel) {
resourcesToUnload.add(packResource);
}
if (isPackageReferenced(resourceSet, pack, declarations)) {
referencedResources.add(packResource);
}
}
}
}
}
示例3: set
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
@Override
public void set(EObject object, String feature, Object value, String ruleName, INode node) throws ValueConverterException {
if (object instanceof AbstractElement && XtextPackage.Literals.ABSTRACT_ELEMENT__CARDINALITY.getName().equals(feature)) {
AbstractElement casted = (AbstractElement) object;
String knownCardinality = casted.getCardinality();
if (knownCardinality != null) {
String newCardinality = String.valueOf(getTokenAsStringIfPossible(value));
if ("*".equals(newCardinality)) {
casted.setCardinality("*");
} else if ("*".equals(knownCardinality)) {
// nothing to do
} else if ("+".equals(knownCardinality)) {
if ("?".equals(newCardinality)) {
casted.setCardinality("*");
}
} else if ("?".equals(knownCardinality)) {
if ("+".equals(newCardinality)) {
casted.setCardinality("*");
}
}
throw new MoreThanOneCardinalityException(newCardinality, casted.getCardinality(), node);
}
}
super.set(object, feature, value, ruleName, node);
}
示例4: getUnconvertedLinkText
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
@Override
protected String getUnconvertedLinkText(EObject object, EReference reference, EObject context) {
if (reference == XtextPackage.eINSTANCE.getGrammar_UsedGrammars())
return ((Grammar) object).getName();
if (reference == XtextPackage.eINSTANCE.getTypeRef_Metamodel()) {
AbstractMetamodelDeclaration casted = (AbstractMetamodelDeclaration) object;
return casted.getAlias();
}
if (reference == XtextPackage.eINSTANCE.getAbstractMetamodelDeclaration_EPackage())
return ((EPackage) object).getNsURI();
if (object instanceof AbstractRule) {
if (reference == XtextPackage.eINSTANCE.getRuleCall_Rule()) {
if (((RuleCall)context).isExplicitlyCalled()) {
return super.getUnconvertedLinkText(object, reference, context);
}
}
return ((AbstractRule) object).getName();
}
return super.getUnconvertedLinkText(object, reference, context);
}
示例5: getFragmentSegment
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
@Override
public CharSequence getFragmentSegment(final EObject object) {
EClass eClass = object.eClass();
EPackage ePackage = eClass.getEPackage();
if (ePackage == XtextPackage.eINSTANCE) {
int classifierID = eClass.getClassifierID();
switch (classifierID) {
case XtextPackage.GRAMMAR:
return getFragmentSegment((Grammar) object);
case XtextPackage.ENUM_RULE:
case XtextPackage.PARSER_RULE:
case XtextPackage.TERMINAL_RULE:
return getFragmentSegment((AbstractRule) object);
case XtextPackage.KEYWORD:
if (((Keyword) object).getValue().equals("selectCardinality")) {
return getFragmentSegment((AbstractElement) object);
} else {
return getFragmentSegment((Keyword) object);
}
default:
return super.getFragmentSegment(object);
}
}
return super.getFragmentSegment(object);
}
示例6: eUnset
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case XtextPackage.PARSER_RULE__DEFINES_HIDDEN_TOKENS:
setDefinesHiddenTokens(DEFINES_HIDDEN_TOKENS_EDEFAULT);
return;
case XtextPackage.PARSER_RULE__HIDDEN_TOKENS:
getHiddenTokens().clear();
return;
case XtextPackage.PARSER_RULE__PARAMETERS:
getParameters().clear();
return;
case XtextPackage.PARSER_RULE__FRAGMENT:
setFragment(FRAGMENT_EDEFAULT);
return;
case XtextPackage.PARSER_RULE__WILDCARD:
setWildcard(WILDCARD_EDEFAULT);
return;
}
super.eUnset(featureID);
}
示例7: checkTerminalFragmentCalledFromTerminalRule
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
@Check
public void checkTerminalFragmentCalledFromTerminalRule(final RuleCall call) {
if (call.getRule() != null && !call.getRule().eIsProxy()) {
if (call.getRule() instanceof TerminalRule && ((TerminalRule) call.getRule()).isFragment()) {
AbstractRule container = GrammarUtil.containingRule(call);
if (!(container instanceof TerminalRule)) {
getMessageAcceptor().acceptError(
"Only terminal rules may use terminal fragments.",
call,
XtextPackage.Literals.RULE_CALL__RULE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
null);
}
}
}
}
示例8: eIsSet
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case XtextPackage.PARSER_RULE__DEFINES_HIDDEN_TOKENS:
return definesHiddenTokens != DEFINES_HIDDEN_TOKENS_EDEFAULT;
case XtextPackage.PARSER_RULE__HIDDEN_TOKENS:
return hiddenTokens != null && !hiddenTokens.isEmpty();
case XtextPackage.PARSER_RULE__PARAMETERS:
return parameters != null && !parameters.isEmpty();
case XtextPackage.PARSER_RULE__FRAGMENT:
return fragment != FRAGMENT_EDEFAULT;
case XtextPackage.PARSER_RULE__WILDCARD:
return wildcard != WILDCARD_EDEFAULT;
}
return super.eIsSet(featureID);
}
示例9: eSet
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case XtextPackage.PARSER_RULE__DEFINES_HIDDEN_TOKENS:
setDefinesHiddenTokens((Boolean)newValue);
return;
case XtextPackage.PARSER_RULE__HIDDEN_TOKENS:
getHiddenTokens().clear();
getHiddenTokens().addAll((Collection<? extends AbstractRule>)newValue);
return;
case XtextPackage.PARSER_RULE__PARAMETERS:
getParameters().clear();
getParameters().addAll((Collection<? extends Parameter>)newValue);
return;
case XtextPackage.PARSER_RULE__FRAGMENT:
setFragment((Boolean)newValue);
return;
case XtextPackage.PARSER_RULE__WILDCARD:
setWildcard((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
示例10: inspectKeywordHidesTerminalRule
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
public void inspectKeywordHidesTerminalRule(Keyword keyword) {
AbstractRule container = GrammarUtil.containingRule(keyword);
if (container instanceof TerminalRule)
return;
Grammar grammar = GrammarUtil.getGrammar(container);
List<TerminalRule> rules = GrammarUtil.allTerminalRules(grammar);
for(TerminalRule rule: rules) {
if (!rule.isFragment()) {
AbstractElement element = rule.getAlternatives();
if (element instanceof Keyword && Strings.isEmpty(element.getCardinality())) {
String value = ((Keyword) element).getValue();
if (value.equals(keyword.getValue()))
acceptor.acceptError(
"The keyword '" + value + "' hides the terminal rule " + rule.getName()+ ".",
keyword,
XtextPackage.Literals.KEYWORD__VALUE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null);
}
}
}
}
示例11: collectMatchableElements
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
protected void collectMatchableElements(AbstractElement ele, Collection<AbstractElement> result) {
switch (ele.eClass().getClassifierID()) {
case XtextPackage.RULE_CALL:
assertNoEObjectRuleCall((RuleCall) ele);
case XtextPackage.KEYWORD:
result.add(ele);
break;
case XtextPackage.CROSS_REFERENCE:
collectMatchableElements(((CrossReference) ele).getTerminal(), result);
break;
case XtextPackage.ASSIGNMENT:
collectMatchableElements(((Assignment) ele).getTerminal(), result);
break;
case XtextPackage.ALTERNATIVES:
case XtextPackage.GROUP:
case XtextPackage.UNORDERED_GROUP:
for (AbstractElement child : ((CompoundElement) ele).getElements())
collectMatchableElements(child, result);
break;
}
}
示例12: eUnset
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case XtextPackage.ASSIGNMENT__FEATURE:
setFeature(FEATURE_EDEFAULT);
return;
case XtextPackage.ASSIGNMENT__OPERATOR:
setOperator(OPERATOR_EDEFAULT);
return;
case XtextPackage.ASSIGNMENT__TERMINAL:
setTerminal((AbstractElement)null);
return;
}
super.eUnset(featureID);
}
示例13: validateReferencedMetamodel
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
protected void validateReferencedMetamodel(final ReferencedMetamodel ref) {
if (((ref.getEPackage() != null) && (!ref.getEPackage().eIsProxy()))) {
return;
}
final EReference eref = XtextPackage.Literals.ABSTRACT_METAMODEL_DECLARATION__EPACKAGE;
final List<INode> nodes = NodeModelUtils.findNodesForFeature(ref, eref);
String _xifexpression = null;
boolean _isEmpty = nodes.isEmpty();
if (_isEmpty) {
_xifexpression = "(unknown)";
} else {
_xifexpression = NodeModelUtils.getTokenText(nodes.get(0));
}
final String refName = _xifexpression;
final String grammarName = GrammarUtil.getGrammar(ref).getName();
final String msg = ((((("The EPackage " + refName) + " in grammar ") + grammarName) + " could not be found. ") + "You might want to register that EPackage in your workflow file.");
throw new IllegalStateException(msg);
}
示例14: eUnset
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case XtextPackage.NAMED_ARGUMENT__PARAMETER:
setParameter((Parameter)null);
return;
case XtextPackage.NAMED_ARGUMENT__VALUE:
setValue((Condition)null);
return;
case XtextPackage.NAMED_ARGUMENT__CALLED_BY_NAME:
setCalledByName(CALLED_BY_NAME_EDEFAULT);
return;
}
super.eUnset(featureID);
}
示例15: eUnset
import org.eclipse.xtext.XtextPackage; //导入依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case XtextPackage.ABSTRACT_ELEMENT__CARDINALITY:
setCardinality(CARDINALITY_EDEFAULT);
return;
case XtextPackage.ABSTRACT_ELEMENT__PREDICATED:
setPredicated(PREDICATED_EDEFAULT);
return;
case XtextPackage.ABSTRACT_ELEMENT__FIRST_SET_PREDICATED:
setFirstSetPredicated(FIRST_SET_PREDICATED_EDEFAULT);
return;
}
super.eUnset(featureID);
}