org.eclipse.xtext.CrossReference Java Examples
The following examples show how to use
org.eclipse.xtext.CrossReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XbaseProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void createReceiverProposals(XExpression receiver, CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) { // long time = System.currentTimeMillis(); String ruleName = getConcreteSyntaxRuleName(crossReference); Function<IEObjectDescription, ICompletionProposal> proposalFactory = getProposalFactory(ruleName, contentAssistContext); IResolvedTypes resolvedTypes = typeResolver.resolveTypes(receiver); LightweightTypeReference receiverType = resolvedTypes.getActualType(receiver); if (receiverType == null || receiverType.isPrimitiveVoid()) { return; } IExpressionScope expressionScope = resolvedTypes.getExpressionScope(receiver, IExpressionScope.Anchor.RECEIVER); // TODO exploit the type name information IScope scope; if (contentAssistContext.getCurrentModel() != receiver) { EObject currentModel = contentAssistContext.getCurrentModel(); if (currentModel instanceof XMemberFeatureCall && ((XMemberFeatureCall) currentModel).getMemberCallTarget() == receiver) { scope = filterByConcreteSyntax(expressionScope.getFeatureScope((XAbstractFeatureCall) currentModel), crossReference); } else { scope = filterByConcreteSyntax(expressionScope.getFeatureScope(), crossReference); } } else { scope = filterByConcreteSyntax(expressionScope.getFeatureScope(), crossReference); } getCrossReferenceProposalCreator().lookupCrossReference(scope, receiver, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, acceptor, getFeatureDescriptionPredicate(contentAssistContext), proposalFactory); // System.out.printf("XbaseProposalProvider.createReceiverProposals = %d\n", System.currentTimeMillis() - time); }
Example #2
Source File: AbstractFormattingConfig.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected List<AbstractElement> getAbstractElements(EObject obj) { if (obj instanceof AbstractElement) return Collections.singletonList((AbstractElement) obj); if (obj instanceof AbstractRule) { AbstractRule rule = (AbstractRule) obj; if (rule.getType().getClassifier() instanceof EClass) return Collections.singletonList(rule.getAlternatives()); List<AbstractElement> result = Lists.newArrayList(); for (RuleCall rc : grammarAccess.findRuleCalls(rule)) { CrossReference cr = GrammarUtil.containingCrossReference(rc); result.add(cr == null ? rc : cr); } return result; } return null; }
Example #3
Source File: AntlrContentAssistGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override protected String _crossrefEbnf(final Keyword it, final CrossReference ref, final boolean supportActions) { StringConcatenation _builder = new StringConcatenation(); _builder.append("("); _builder.newLine(); _builder.append("\t"); _builder.append("{ before(grammarAccess."); String _grammarElementAccess = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<Keyword>getOriginalElement(it)); _builder.append(_grammarElementAccess, "\t"); _builder.append("); }"); _builder.newLineIfNotEmpty(); _builder.append("\t"); String __crossrefEbnf = super._crossrefEbnf(it, ref, supportActions); _builder.append(__crossrefEbnf, "\t"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("{ after(grammarAccess."); String _grammarElementAccess_1 = this._grammarAccessExtensions.grammarElementAccess(AntlrGrammarGenUtil.<Keyword>getOriginalElement(it)); _builder.append(_grammarElementAccess_1, "\t"); _builder.append("); }"); _builder.newLineIfNotEmpty(); _builder.append(")"); _builder.newLine(); return _builder.toString(); }
Example #4
Source File: SyntaxFilteredScopes.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public IScope create(IScope parent, AbstractElement syntaxElement) { if (syntaxElement instanceof CrossReference) { return create(parent, ((CrossReference) syntaxElement).getTerminal()); } if (syntaxElement instanceof RuleCall) { AbstractRule rule = ((RuleCall) syntaxElement).getRule(); if (GrammarUtil.isDatatypeRule(rule)) { List<String> values = getEnumeratedValues((ParserRule) rule); if (values.isEmpty()) { return parent; } return new SyntaxFilteredScope(parent, values); } } return parent; }
Example #5
Source File: AbstractJavaBasedContentProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void lookupCrossReference(CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor, Predicate<IEObjectDescription> filter) { ParserRule containingParserRule = GrammarUtil.containingParserRule(crossReference); if (!GrammarUtil.isDatatypeRule(containingParserRule)) { EReference ref; if (containingParserRule.isWildcard()) { // TODO we need better ctrl flow analysis here // The cross reference may come from another parser rule then the current model ref = GrammarUtil.getReference(crossReference, contentAssistContext.getCurrentModel().eClass()); } else { ref = GrammarUtil.getReference(crossReference); } if (ref != null) { lookupCrossReference(crossReference, ref, contentAssistContext, acceptor, filter); } } }
Example #6
Source File: TokenDiagnosticProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String getFullReferenceName(EObject semanticObject, CrossReference reference) { EReference ref = GrammarUtil.getReference(reference); String clazz = semanticObject.eClass().getName(); if (ref.getEContainingClass() != semanticObject.eClass()) clazz = ref.getEContainingClass().getName() + "(" + clazz + ")"; return clazz + "." + ref.getName(); }
Example #7
Source File: CrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected String getCrossReferenceNameFromScope(EObject semanticObject, CrossReference crossref, EObject target, final IScope scope, Acceptor errors) { String ruleName = linkingHelper.getRuleNameFrom(crossref); boolean foundOne = false; List<ISerializationDiagnostic> recordedErrors = null; for (IEObjectDescription desc : scope.getElements(target)) { foundOne = true; String unconverted = qualifiedNameConverter.toString(desc.getName()); try { return valueConverter.toString(unconverted, ruleName); } catch (ValueConverterException e) { if (errors != null) { if (recordedErrors == null) recordedErrors = Lists.newArrayList(); recordedErrors.add(diagnostics.getValueConversionExceptionDiagnostic(semanticObject, crossref, unconverted, e)); } } } if (errors != null) { if (recordedErrors != null) for (ISerializationDiagnostic diag : recordedErrors) errors.accept(diag); if (!foundOne) errors.accept(diagnostics.getNoEObjectDescriptionFoundDiagnostic(semanticObject, crossref, target, scope)); } return null; }
Example #8
Source File: AntlrContentAssistGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected String crossrefEbnf(final AbstractElement it, final CrossReference ref, final boolean supportActions) { if (it instanceof Alternatives) { return _crossrefEbnf((Alternatives)it, ref, supportActions); } else if (it instanceof Keyword) { return _crossrefEbnf((Keyword)it, ref, supportActions); } else if (it instanceof RuleCall) { return _crossrefEbnf((RuleCall)it, ref, supportActions); } else if (it != null) { return _crossrefEbnf(it, ref, supportActions); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, ref, supportActions).toString()); } }
Example #9
Source File: AbstractJavaBasedContentProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void lookupCrossReference(CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor, Predicate<IEObjectDescription> filter, Function<IEObjectDescription, ICompletionProposal> proposalFactory) { ParserRule containingParserRule = GrammarUtil.containingParserRule(crossReference); if (!GrammarUtil.isDatatypeRule(containingParserRule)) { EReference ref = GrammarUtil.getReference(crossReference); lookupCrossReference(contentAssistContext.getCurrentModel(), ref, acceptor, filter, proposalFactory); } }
Example #10
Source File: CallHierarchyHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Boolean caseCrossReference(CrossReference object) { if (!checkFurther(object)) return result; if (doSwitch(object.getTerminal())) return true; if (GrammarUtil.isMultipleCardinality(object)) { if (!checkFurther(object)) return result; if (doSwitch(object.getTerminal())) return true; } return Boolean.FALSE; }
Example #11
Source File: DefaultQuickfixProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected EReference getUnresolvedEReference(final Issue issue, EObject target) { final ICompositeNode node = NodeModelUtils.getNode(target); if (node==null) return null; ICompositeNode rootNode = node.getRootNode(); ILeafNode leaf = NodeModelUtils.findLeafNodeAtOffset(rootNode, issue.getOffset()); CrossReference crossReference = findCrossReference(target, leaf); if (crossReference != null) { return GrammarUtil.getReference(crossReference, target.eClass()); } return null; }
Example #12
Source File: XbaseProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected String getConcreteSyntaxRuleName(CrossReference crossReference) { String ruleName = null; if (crossReference.getTerminal() instanceof RuleCall) { ruleName = getConcreteSyntaxRuleName((RuleCall) crossReference.getTerminal()); } return ruleName; }
Example #13
Source File: XtextLabelProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private String getLabel(CrossReference ref) { TypeRef type = ref.getType(); String typeName = getClassifierName(type); if (ref.getTerminal() instanceof RuleCall) return "[" + typeName + "|" + getLabel((RuleCall) ref.getTerminal()) + "]"; return "[" + typeName + "|..]"; }
Example #14
Source File: XbaseIdeCrossrefProposalProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean hasIdRule(CrossReference crossRef) { if (crossRef.getTerminal() instanceof RuleCall) { String ruleName = ((RuleCall) crossRef.getTerminal()).getRule().getName(); return "IdOrSuper".equals(ruleName) || "ValidID".equals(ruleName) || "FeatureCallID".equals(ruleName); } return false; }
Example #15
Source File: NodeModelBasedRegionAccessBuilder.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected boolean include(INode node) { if (node instanceof ILeafNode) { return true; } else if (node instanceof ICompositeNode) { EObject element = node.getGrammarElement(); return GrammarUtil.isDatatypeRuleCall(element) || element instanceof CrossReference || GrammarUtil.isEnumRuleCall(element); } return false; }
Example #16
Source File: ContentAssistFragment2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private StringConcatenationClient _assignmentTerminal(final CrossReference element, final StringConcatenationClient accessor) { StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("lookupCrossReference((("); _builder.append(CrossReference.class); _builder.append(")"); _builder.append(accessor); _builder.append("), context, acceptor);"); _builder.newLineIfNotEmpty(); } }; return _client; }
Example #17
Source File: CrossReferenceSerializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isValid(EObject context, CrossReference crossref, EObject target, IErrorAcceptor errorAcceptor) { try { final EReference ref = GrammarUtil.getReference(crossref, context.eClass()); String text = getUnconvertedLinkText(target, ref, context); if (text == null) return true; // maybe we'll find something useful in the node model later on? getConvertedValue(text, crossref); return true; } catch (ValueConverterException e) { if (errorAcceptor != null) errorAcceptor.error(e.getMessage()); return false; } }
Example #18
Source File: AbstractDomainModelTestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeReference_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #19
Source File: AntlrGrammarGenerator.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override protected String _assignmentEbnf(final CrossReference it, final Assignment assignment, final AntlrOptions options, final boolean supportActions) { String _xifexpression = null; if (supportActions) { StringConcatenation _builder = new StringConcatenation(); { boolean _isBacktrack = options.isBacktrack(); if (_isBacktrack) { _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("/* */"); _builder.newLine(); _builder.append("}"); _builder.newLine(); } } _builder.append("{"); _builder.newLine(); _builder.append("\t"); _builder.append("if ($current==null) {"); _builder.newLine(); _builder.append("\t\t"); _builder.append("$current = "); CharSequence _createModelElement = this.createModelElement(assignment); _builder.append(_createModelElement, "\t\t"); _builder.append(";"); _builder.newLineIfNotEmpty(); _builder.append("\t"); _builder.append("}"); _builder.newLine(); _builder.append("}"); _builder.newLine(); String __assignmentEbnf = super._assignmentEbnf(it, assignment, options, supportActions); _builder.append(__assignmentEbnf); _xifexpression = _builder.toString(); } else { _xifexpression = super._assignmentEbnf(it, assignment, options, supportActions); } return _xifexpression; }
Example #20
Source File: AbstractBug287941TestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeReferenceAliasWhereEntry_Reference(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #21
Source File: AbstractBug287941TestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeStringAttributeWhereEntry_Attribute(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #22
Source File: AbstractBug287941TestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeDoubleWhereEntry_Attribute(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #23
Source File: AbstractBug287941TestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeFromEntry_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #24
Source File: AbstractJavaBasedContentProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void lookupCrossReference(CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor, Function<IEObjectDescription, ICompletionProposal> proposalFactory) { lookupCrossReference(crossReference, contentAssistContext, acceptor, Predicates.<IEObjectDescription> alwaysTrue(), proposalFactory); }
Example #25
Source File: AbstractStatemachineProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeState_Actions(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #26
Source File: AbstractBuilderTestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeElement_References(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #27
Source File: AbstractGH341TestLanguageProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void completeBroken_Refs(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor); }
Example #28
Source File: IdeCrossrefProposalProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected Iterable<IEObjectDescription> queryScope(IScope scope, CrossReference crossReference, ContentAssistContext context) { return scope.getAllElements(); }
Example #29
Source File: XbaseProposalProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override protected void lookupCrossReference(CrossReference crossReference, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) { lookupCrossReference(crossReference, contentAssistContext, acceptor, getFeatureDescriptionPredicate(contentAssistContext)); }
Example #30
Source File: IdeContentProposalProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected Predicate<IEObjectDescription> getCrossrefFilter(CrossReference reference, ContentAssistContext context) { return Predicates.alwaysTrue(); }