mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[263773] Adjusted Xtext grammar content assist to support fragments and params
Also fixed validation for wildcard fragment overrides
This commit is contained in:
parent
5746bbb063
commit
9572595662
2 changed files with 23 additions and 5 deletions
|
@ -7,14 +7,16 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.xtext.xtext.ecoreInference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.EStructuralFeature;
|
||||
import org.eclipse.xtext.diagnostics.AbstractDiagnosticProducer;
|
||||
import org.eclipse.xtext.diagnostics.Diagnostic;
|
||||
import org.eclipse.xtext.diagnostics.DiagnosticMessage;
|
||||
import org.eclipse.xtext.diagnostics.Severity;
|
||||
import org.eclipse.xtext.diagnostics.IDiagnosticConsumer;
|
||||
import org.eclipse.xtext.nodemodel.ICompositeNode;
|
||||
import org.eclipse.xtext.diagnostics.Severity;
|
||||
import org.eclipse.xtext.nodemodel.INode;
|
||||
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
|
||||
|
||||
/**
|
||||
|
@ -44,13 +46,24 @@ public class TransformationDiagnosticsProducer extends AbstractDiagnosticProduce
|
|||
@Override
|
||||
public void setTarget(EObject object, EStructuralFeature feature) {
|
||||
EObject myObject = object;
|
||||
ICompositeNode result = NodeModelUtils.getNode(myObject);
|
||||
INode result = NodeModelUtils.getNode(myObject);
|
||||
while(result == null && myObject.eContainer() != null) {
|
||||
myObject = myObject.eContainer();
|
||||
result = NodeModelUtils.getNode(myObject);
|
||||
}
|
||||
if (result == null)
|
||||
throw new IllegalStateException("Cannot find NodeAdapter for object: " + object);
|
||||
else {
|
||||
if (feature == null) {
|
||||
feature = myObject.eClass().getEStructuralFeature("name");
|
||||
}
|
||||
if (feature != null) {
|
||||
List<INode> nodes = NodeModelUtils.findNodesForFeature(myObject, feature);
|
||||
if (nodes.size() == 1) {
|
||||
result = nodes.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
setNode(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -231,6 +231,11 @@ public class Xtext2EcoreTransformer {
|
|||
throw new IllegalStateException("Unknown rule type: " + rule.eClass().getName());
|
||||
}
|
||||
}
|
||||
if (isWildcardFragment(rule)) {
|
||||
for (Grammar usedGrammar: grammar.getUsedGrammars()) {
|
||||
deriveTypeHierarchyFromOverridden((ParserRule) rule, usedGrammar);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (TransformationException e) {
|
||||
reportError(e);
|
||||
|
@ -964,7 +969,7 @@ public class Xtext2EcoreTransformer {
|
|||
private EClassifierInfo findOrCreateEClassifierInfo(TypeRef typeRef, String name, boolean createIfMissing) throws TransformationException {
|
||||
if (typeRef.getClassifier() != null && typeRef.getMetamodel() == null)
|
||||
throw new TransformationException(TransformationErrorCode.UnknownMetaModelAlias,
|
||||
"Cannot find metamodel for type '" + typeRef.getClassifier().getName() + "'", typeRef);
|
||||
"Cannot find EPackage for type '" + typeRef.getClassifier().getName() + "'", typeRef);
|
||||
EClassifierInfo info = eClassifierInfos.getInfo(typeRef);
|
||||
if (info == null) {
|
||||
// we assumend EString for terminal rules and datatype rules, so
|
||||
|
@ -996,7 +1001,7 @@ public class Xtext2EcoreTransformer {
|
|||
AbstractMetamodelDeclaration metaModel = typeRef.getMetamodel();
|
||||
if (metaModel == null)
|
||||
throw new TransformationException(TransformationErrorCode.UnknownMetaModelAlias, "Cannot create type for " + classifierName
|
||||
+ " because its MetaModel is unknown.", typeRef);
|
||||
+ " because its EPackage is unknown.", typeRef);
|
||||
EPackage generatedEPackage = getGeneratedEPackage(metaModel);
|
||||
if (generatedEPackage == null) {
|
||||
throw new TransformationException(TransformationErrorCode.CannotCreateTypeInSealedMetamodel,
|
||||
|
|
Loading…
Reference in a new issue