本文整理汇总了Java中org.eclipse.xtext.AbstractElement类的典型用法代码示例。如果您正苦于以下问题:Java AbstractElement类的具体用法?Java AbstractElement怎么用?Java AbstractElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractElement类属于org.eclipse.xtext包,在下文中一共展示了AbstractElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGrammar
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
/**
* Extracts the grammar from this transition or the NFA if this transition does not point to an
* {@link AbstractElement}.
*/
private Grammar getGrammar(Nfa<ISynState> nfa) {
AbstractElement grammarElement = getGrammarElement();
if (grammarElement == null) {
grammarElement = nfa.getStart().getGrammarElement();
if (grammarElement == null) {
grammarElement = nfa.getStop().getGrammarElement();
if (grammarElement == null) {
Iterator<ISynState> iter = nfa.getStart().getFollowers().iterator();
while (grammarElement == null && iter.hasNext()) {
grammarElement = iter.next().getGrammarElement();
}
}
}
}
Grammar grammar = GrammarUtil.getGrammar(grammarElement);
return grammar;
}
示例2: announce
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
@Override
protected void announce(Token start, Token stop, AbstractElement element) {
if (start != null && start != Token.EOF_TOKEN) {
if (start == stop) {
announce(start, element);
} else {
CommonToken castedStart = (CommonToken) start;
if (stop == null) { // possible error condition
if (start.getTokenIndex() == state.lastErrorIndex) {
return;
}
}
CommonToken castedEnd = (CommonToken) stop;
Integer newType = rewriter.rewrite(castedStart, element);
if (newType != null && castedEnd != null && castedEnd != Token.EOF_TOKEN) {
LazyTokenStream castedInput = (LazyTokenStream) this.input;
for (int i = castedStart.getTokenIndex() + 1; i < castedEnd.getTokenIndex(); i++) {
Token token = castedInput.get(i);
if (token.getChannel() != Token.HIDDEN_CHANNEL)
token.setType(newType);
}
castedEnd.setType(newType);
}
}
}
}
示例3: rewriteKeywords
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
private static void rewriteKeywords(AbstractRule rule, N4JSKeywords keywords,
ImmutableMap.Builder<AbstractElement, Integer> builder) {
for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
if (obj instanceof Keyword) {
Keyword keyword = (Keyword) obj;
Integer type = keywords.getTokenType(keyword);
if (type != null) {
if (keyword.eContainer() instanceof EnumLiteralDeclaration) {
builder.put((AbstractElement) keyword.eContainer(), type);
} else {
builder.put(keyword, type);
}
}
}
}
}
示例4: rewriteTypeReferences
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
private static void rewriteTypeReferences(N4JSGrammarAccess ga,
ImmutableMap.Builder<AbstractElement, Integer> builder) {
for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
if (obj instanceof Assignment) {
Assignment assignment = (Assignment) obj;
AbstractElement terminal = assignment.getTerminal();
if (terminal instanceof RuleCall) {
AbstractRule calledRule = ((RuleCall) terminal).getRule();
EClassifier classifier = calledRule.getType().getClassifier();
if (classifier instanceof EClass
&& TypeRefsPackage.Literals.TYPE_REF.isSuperTypeOf((EClass) classifier)) {
builder.put(assignment, TYPE_REF_TOKEN);
}
}
}
}
}
}
示例5: rewriteIdentifiers
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
private static void rewriteIdentifiers(N4JSGrammarAccess ga,
ImmutableMap.Builder<AbstractElement, Integer> builder) {
ImmutableSet<AbstractRule> identifierRules = ImmutableSet.of(
ga.getBindingIdentifierRule(),
ga.getIdentifierNameRule(),
ga.getIDENTIFIERRule());
for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
if (obj instanceof Assignment) {
Assignment assignment = (Assignment) obj;
AbstractElement terminal = assignment.getTerminal();
int type = InternalN4JSParser.RULE_IDENTIFIER;
if (terminal instanceof CrossReference) {
terminal = ((CrossReference) terminal).getTerminal();
type = IDENTIFIER_REF_TOKEN;
}
if (terminal instanceof RuleCall) {
AbstractRule calledRule = ((RuleCall) terminal).getRule();
if (identifierRules.contains(calledRule)) {
builder.put(assignment, type);
}
}
}
}
}
}
示例6: rewriteNumberLiterals
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
private static void rewriteNumberLiterals(N4JSGrammarAccess ga,
ImmutableMap.Builder<AbstractElement, Integer> builder) {
for (ParserRule rule : GrammarUtil.allParserRules(ga.getGrammar())) {
for (EObject obj : EcoreUtil2.eAllContents(rule.getAlternatives())) {
if (obj instanceof Assignment) {
Assignment assignment = (Assignment) obj;
AbstractElement terminal = assignment.getTerminal();
if (terminal instanceof RuleCall) {
AbstractRule calledRule = ((RuleCall) terminal).getRule();
EClassifier classifier = calledRule.getType().getClassifier();
if (classifier == EcorePackage.Literals.EBIG_DECIMAL) {
builder.put(assignment, NUMBER_LITERAL_TOKEN);
}
}
}
}
}
}
示例7: drawAbstractElementTree
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
@Override
protected Node drawAbstractElementTree(AbstractElement grammarElement, Digraph digraph) {
Node node = super.drawAbstractElementTree(grammarElement, digraph);
TreeConstState nfas = nfaProvider.getNFA(grammarElement);
for (TreeConstTransition outgoing : nfas.getOutgoing())
digraph.add(drawFollowerEdge(grammarElement, outgoing, false));
for (TreeConstTransition outgoingAfterReturn : nfas.getOutgoingAfterReturn())
digraph.add(drawFollowerEdge(grammarElement, outgoingAfterReturn, true));
if (nfas.getStatusInternal() != Status.ENABLED)
node.setStyle("dashed");
if (nfas.isEndState())
node.put("peripheries", "2");
setStatusStyle(node, nfas.getStatus());
node.setLabel(nfas + node.get("label"));
return node;
}
示例8: getFollowElements
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
protected Collection<FE> getFollowElements(InternalParser parser, AbstractElement entryPoint) {
String ruleName = getRuleName(entryPoint);
if (ruleName == null) {
if (entryPoint instanceof RuleCall) {
RuleCall call = (RuleCall) entryPoint;
AbstractRule rule = call.getRule();
if (rule instanceof ParserRule) {
ruleName = getRuleNames().getAntlrRuleName(rule);
}
}
}
if (ruleName == null) {
throw new IllegalStateException("entryPoint: " + entryPoint);
}
return getFollowElements(parser, ruleName);
}
示例9: findInsertionPoint
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
public IHiddenRegion findInsertionPoint(ISerializationContext ctx, IEObjectRegion obj, AbstractElement ins) {
ISerState insertionState = findState(ctx, ins);
Set<AbstractElement> followers = collectAdjacent(insertionState, s -> s.getFollowers());
Set<AbstractElement> precendents = collectAdjacent(insertionState, s -> s.getPrecedents());
List<IAstRegion> regions = Lists.newArrayList(obj.getAstRegions());
if (regions.isEmpty()) {
return obj.getPreviousHiddenRegion();
}
if (followers.contains(regions.get(0).getGrammarElement())) {
return obj.getPreviousHiddenRegion();
}
if (precendents.contains(regions.get(regions.size() - 1).getGrammarElement())) {
return obj.getNextHiddenRegion();
}
for (int i = 0; i < regions.size() - 1; i++) {
IAstRegion leading = regions.get(i);
IAstRegion trailing = regions.get(i + 1);
if (precendents.contains(leading.getGrammarElement()) && followers.contains(trailing.getGrammarElement())) {
return leading.getNextHiddenRegion();
}
}
return null;
}
示例10: isInvalidLastChildNode
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
protected boolean isInvalidLastChildNode(ICompositeNode candidate, final INode lastChild) {
if (lastChild != null && lastChild.getSyntaxErrorMessage() != null) {
EObject lastChildGrammarElement = lastChild.getGrammarElement();
if (lastChildGrammarElement == null) {
return true;
}
AbstractElement candidateElement = getCandidateElement(candidate.getGrammarElement());
if (candidateElement != null) {
if (isCalledBy(lastChildGrammarElement, candidateElement)) {
while (candidate != null) {
if (candidateElement != null && hasMandatoryFollowElements(candidateElement)) {
return true;
}
candidate = candidate.getParent();
if (candidate != null) {
candidateElement = getCandidateElement(candidate.getGrammarElement());
}
}
}
return true;
}
}
return false;
}
示例11: assertNoLeakedGrammarElements
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
private void assertNoLeakedGrammarElements(final Grammar grammar, final Pda<ISerState, RuleCall> pda) {
final Function1<ISerState, AbstractElement> _function = (ISerState it) -> {
return it.getGrammarElement();
};
Iterable<AbstractElement> _filterNull = IterableExtensions.<AbstractElement>filterNull(IterableExtensions.<ISerState, AbstractElement>map(new NfaUtil().<ISerState>collect(pda), _function));
for (final AbstractElement ele : _filterNull) {
{
final Grammar actual = GrammarUtil.getGrammar(ele);
if ((actual != grammar)) {
String _objPath = EmfFormatter.objPath(ele);
String _plus = ("Element " + _objPath);
String _plus_1 = (_plus + " leaked!");
Assert.fail(_plus_1);
}
}
}
}
示例12: accept
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
protected void accept(TraceItem ti, SequenceFeeder feeder) {
AbstractElement ele = ti.getState().getAssignedGrammarElement();
if (ti.getState().getFeature().isMany()) {
if (ele instanceof RuleCall)
feeder.accept((RuleCall) ele, ti.getValue(), ti.getIndex(), ti.getNode());
else if (ele instanceof Action)
feeder.accept((Action) ele, (EObject) ti.getValue(), (ICompositeNode) ti.getNode());
else if (ele instanceof Keyword)
feeder.accept((Keyword) ele, ti.getValue(), ti.getIndex(), (ILeafNode) ti.getNode());
} else {
if (ele instanceof RuleCall)
feeder.accept((RuleCall) ele, ti.getValue(), ti.getNode());
else if (ele instanceof Action)
feeder.accept((Action) ele, (EObject) ti.getValue(), (ICompositeNode) ti.getNode());
else if (ele instanceof Keyword)
feeder.accept((Keyword) ele, ti.getValue(), (ILeafNode) ti.getNode());
}
}
示例13: _ebnf2
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
protected String _ebnf2(final Alternatives it, final AntlrOptions options, final boolean supportActions) {
StringConcatenation _builder = new StringConcatenation();
{
EList<AbstractElement> _elements = it.getElements();
boolean _hasElements = false;
for(final AbstractElement element : _elements) {
if (!_hasElements) {
_hasElements = true;
} else {
_builder.appendImmediate("\n |", "");
}
String _ebnf = this.ebnf(element, options, supportActions);
_builder.append(_ebnf);
}
}
_builder.newLineIfNotEmpty();
return _builder.toString();
}
示例14: adjustRuleName
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
protected String adjustRuleName(String ruleName, Param param) {
AbstractElement elementToParse = param.elementToParse;
Set<Parameter> context = getAssignedParameters(elementToParse, param.paramStack);
if (!context.isEmpty()) {
ParserRule containingRule = GrammarUtil.containingParserRule(elementToParse);
String antlrRuleName = ruleNames.getAntlrRuleName(containingRule);
int len = antlrRuleName.length();
if (antlrRuleName.startsWith("rule")) {
len += 2; // rule__XYZ instead of ruleXYZ
}
int config = getParameterConfig(context);
String result = ruleNames.getAntlrRuleName(containingRule, config) + ruleName.substring(len);
return result;
}
return ruleName;
}
示例15: gaTypeAccessor
import org.eclipse.xtext.AbstractElement; //导入依赖的package包/类
/**
* Returns the invocation of an element or rule accessor, including the .getType() call.
* Example1: getFooRule().getType()
* Example2: getBarRule().getFooAction().getType()
*/
public String gaTypeAccessor(final TypeRef ele) {
String _switchResult = null;
EObject _eContainer = ele.eContainer();
final EObject cnt = _eContainer;
boolean _matched = false;
if (cnt instanceof AbstractElement) {
_matched=true;
String _gaRuleElementAccessor = this.gaRuleElementAccessor(((AbstractElement)cnt));
_switchResult = (_gaRuleElementAccessor + ".getType()");
}
if (!_matched) {
if (cnt instanceof AbstractRule) {
_matched=true;
String _gaRuleAccessor = this.gaRuleAccessor(((AbstractRule)cnt));
_switchResult = (_gaRuleAccessor + ".getType()");
}
}
if (!_matched) {
String _name = ele.eContainer().eClass().getName();
String _plus = ("<error: unknown type " + _name);
_switchResult = (_plus + ">");
}
return _switchResult;
}