Java Code Examples for org.eclipse.xtext.Keyword
The following examples show how to use
org.eclipse.xtext.Keyword.
These examples are extracted from open source projects.
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 Project: xtext-extras Author: eclipse File: XbaseIdeContentProposalProvider.java License: Eclipse Public License 2.0 | 6 votes |
@Override public boolean filterKeyword(final Keyword keyword, final ContentAssistContext context) { final String value = keyword.getValue(); if (((value.length() > 1) && Character.isLetter(value.charAt(0)))) { if ((Objects.equal(value, "as") || Objects.equal(value, "instanceof"))) { final EObject previousModel = context.getPreviousModel(); if ((previousModel instanceof XExpression)) { if (((context.getPrefix().length() == 0) && (NodeModelUtils.getNode(previousModel).getEndOffset() > context.getOffset()))) { return false; } final LightweightTypeReference type = this.typeResolver.resolveTypes(previousModel).getActualType(((XExpression)previousModel)); if (((type == null) || type.isPrimitiveVoid())) { return false; } } } return true; } return false; }
Example #2
Source Project: xtext-extras Author: eclipse File: XbaseSyntacticSequencer.java License: Eclipse Public License 2.0 | 6 votes |
/** * Syntax: '('* */ @Override protected void emit_XParenthesizedExpression_LeftParenthesisKeyword_0_a(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { Keyword kw = grammarAccess.getXParenthesizedExpressionAccess().getLeftParenthesisKeyword_0(); if (nodes == null) { if (semanticObject instanceof XIfExpression || semanticObject instanceof XTryCatchFinallyExpression) { EObject cnt = semanticObject.eContainer(); if (cnt instanceof XExpression && !(cnt instanceof XBlockExpression) && !(cnt instanceof XForLoopExpression)) acceptUnassignedKeyword(kw, kw.getValue(), null); } if (semanticObject instanceof XConstructorCall) { XConstructorCall call = (XConstructorCall) semanticObject; if (!call.isExplicitConstructorCall() && call.getArguments().isEmpty()) { acceptUnassignedKeyword(kw, kw.getValue(), null); } } } acceptNodes(transition, nodes); }
Example #3
Source Project: xtext-xtend Author: eclipse File: JFlexGeneratorFragmentTemplate.java License: Eclipse Public License 2.0 | 5 votes |
public void collectTokens(final EObject it, final List<String> known) { if (it instanceof Keyword) { _collectTokens((Keyword)it, known); return; } else if (it instanceof AbstractRule) { _collectTokens((AbstractRule)it, known); return; } else if (it != null) { _collectTokens(it, known); return; } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, known).toString()); } }
Example #4
Source Project: xtext-core Author: eclipse File: SequenceFeeder.java License: Eclipse Public License 2.0 | 5 votes |
public void accept(Keyword keyword, Object value, int indexInFeature, int indexInNonTransient) { Assignment ass = getAssignment(keyword); EStructuralFeature feature = getFeature(ass.getFeature()); assertIndex(feature, indexInFeature); assertIndex(feature, indexInNonTransient); assertValue(feature, value); ILeafNode node = getLeafNode(feature, indexInFeature, indexInNonTransient, value); String token = getToken(keyword, value, node); acceptKeyword(ass, keyword, value, token, indexInFeature, node); }
Example #5
Source Project: openhab-core Author: openhab File: ThingSyntacticSequencerExtension.java License: Eclipse Public License 2.0 | 5 votes |
@Override protected void emit_ModelThing_ThingKeyword_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) { ILeafNode node = nodes != null && nodes.size() == 1 && nodes.get(0) instanceof ILeafNode ? (ILeafNode) nodes .get(0) : null; Keyword keyword = grammarAccess.getModelThingAccess().getThingKeyword_0(); acceptUnassignedKeyword(keyword, keyword.getValue(), node); }
Example #6
Source Project: sarl Author: sarl File: BugSinglelineCommentIndentation.java License: Apache License 2.0 | 5 votes |
private static boolean detectBugSituation(IHiddenRegion hiddenRegion) { if (hiddenRegion != null) { final ISemanticRegion semanticRegion = hiddenRegion.getNextSemanticRegion(); if (semanticRegion != null) { final EObject element = semanticRegion.getGrammarElement(); if (element instanceof Keyword && Strings.equal(((Keyword) element).getValue(), "}")) { //$NON-NLS-1$ return true; } } } return false; }
Example #7
Source Project: gama Author: gama-platform File: AbstractGamlProposalProvider.java License: GNU General Public License v3.0 | 5 votes |
public void completeClassicFacet_Key(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { if (assignment.getTerminal() instanceof RuleCall) { completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor); } if (assignment.getTerminal() instanceof Keyword) { // subclasses may override } }
Example #8
Source Project: xtext-core Author: eclipse File: XtextValidator.java License: Eclipse Public License 2.0 | 5 votes |
@Check public void checkKeywordNotEmpty(final Keyword keyword) { if (keyword.getValue().length()==0 && !(keyword.eContainer() instanceof EnumLiteralDeclaration)) { addIssue("A keyword cannot be empty.", keyword, null, EMPTY_KEYWORD); } }
Example #9
Source Project: xtext-eclipse Author: eclipse File: XbaseProposalProvider.java License: Eclipse Public License 2.0 | 5 votes |
@Override public void completeKeyword(Keyword keyword, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) { if (isKeywordWorthyToPropose(keyword, contentAssistContext)) { super.completeKeyword(keyword, contentAssistContext, acceptor); } }
Example #10
Source Project: xtext-core Author: eclipse File: AbstractPackratParser.java License: Eclipse Public License 2.0 | 4 votes |
@Override public int consumeKeyword(Keyword keyword, String feature, boolean isMany, boolean isBoolean, ICharacterClass notFollowedBy, boolean optional) { keywordConsumer.configure(keyword, notFollowedBy); return consumeTerminal(keywordConsumer, feature, isMany, isBoolean, keyword, ISequenceMatcher.Factory.nullMatcher(), optional); }
Example #11
Source Project: dsl-devkit Author: dsldevkit File: CheckFormatter.java License: Eclipse Public License 1.0 | 4 votes |
/** * General formatting configuration. Delegates formatting configuration to individual grammar elements. * * @param configuration * formating configuration * @param access * grammarAccess */ private void configure(final FormattingConfig configuration, final CheckGrammarAccess access) { super.configure(configuration, access.getXbaseWithAnnotationsGrammarAccess()); // Common curly brackets handling (for check grammar only) List<Pair<Keyword, Keyword>> curlyPairs = access.findKeywordPairs("{", "}"); //$NON-NLS-1$ //$NON-NLS-2$ for (Pair<Keyword, Keyword> pair : curlyPairs) { if (EcoreUtil2.getContainerOfType(pair.getFirst(), GrammarImpl.class).getName().equals(CheckConstants.GRAMMAR)) { configuration.setLinewrap().after(pair.getFirst()); configuration.setIndentation(pair.getFirst(), pair.getSecond()); configuration.setLinewrap().before(pair.getSecond()); } } // AutoLineWrap configuration.setAutoLinewrap(LINE_WRAP_LENGTH); // Comments configuration.setLinewrap(0, 1, 2).before(access.getSL_COMMENTRule()); configuration.setLinewrap(1, 1, 2).before(access.getML_COMMENTRule()); configuration.setLinewrap(1, 1, 1).after(access.getML_COMMENTRule()); // Rules configuration.setLinewrap(1, 1, 2).before(access.getXImportDeclarationRule()); configuration.setLinewrap(1, 2, 2).before(access.getCategoryRule()); configuration.setLinewrap(1, 2, 2).before(access.getImplementationRule()); configuration.setLinewrap(1, 2, 2).before(access.getCheckRule()); configuration.setLinewrap(1, 1, 2).before(access.getXGuardExpressionRule()); configuration.setLinewrap(1, 1, 2).before(access.getXIssueExpressionRule()); configuration.setLinewrap(1, 1, 2).before(access.getXIfExpressionRule()); configuration.setLinewrap(1, 1, 2).before(access.getXVariableDeclarationRule()); // Rule elements configureFeatureCall(configuration, access.getXMemberFeatureCallAccess()); configureCheckCatalog(configuration, access.getCheckCatalogAccess()); configureSeverityRange(configuration, access.getSeverityRangeAccess()); configureCheck(configuration, access.getCheckAccess()); configureXIssueExpression(configuration, access.getXIssueExpressionAccess()); configureCheckContext(configuration, access.getContextAccess()); }
Example #12
Source Project: xtext-eclipse Author: eclipse File: XbaseProposalProvider.java License: Eclipse Public License 2.0 | 4 votes |
protected boolean isKeywordWorthyToPropose(Keyword keyword) { return keyword.getValue().length() > 1 && Character.isLetter(keyword.getValue().charAt(0)); }
Example #13
Source Project: xtext-core Author: eclipse File: HiddenTokenSequencer.java License: Eclipse Public License 2.0 | 4 votes |
@Override public void acceptAssignedKeyword(Keyword keyword, String token, Object value, int index, ILeafNode node) { emitHiddenTokens(getHiddenNodesBetween(lastNode, node)); lastNode = node; delegate.acceptAssignedKeyword(keyword, token, value, index, node); }
Example #14
Source Project: dsl-devkit Author: dsldevkit File: FormatScopeNameProvider.java License: Eclipse Public License 1.0 | 4 votes |
@Override public String caseKeyword(final Keyword object) { return '"' + object.getValue() + '"'; }
Example #15
Source Project: xtext-core Author: eclipse File: XtextSemanticSequencer.java License: Eclipse Public License 2.0 | 2 votes |
/** * Contexts: * PredicatedKeyword returns Keyword * * Constraint: * ((predicated?='=>' | firstSetPredicated?='->') value=STRING) */ protected void sequence_PredicatedKeyword(ISerializationContext context, Keyword semanticObject) { genericSequencer.createSequence(context, semanticObject); }
Example #16
Source Project: xtext-eclipse Author: eclipse File: Bug332217TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getDetailDetailKeyword_2_0() { return cDetailDetailKeyword_2_0; }
Example #17
Source Project: xtext-eclipse Author: eclipse File: ParametersTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getFragmentKeyword_1_0() { return cFragmentKeyword_1_0; }
Example #18
Source Project: xtext-eclipse Author: eclipse File: Bug303200TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getRightSquareBracketKeyword_1_5() { return cRightSquareBracketKeyword_1_5; }
Example #19
Source Project: xtext-core Author: eclipse File: ConcreteSyntaxValidationTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getKw2Keyword_4() { return cKw2Keyword_4; }
Example #20
Source Project: xtext-eclipse Author: eclipse File: GH341TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getSemicolonKeyword_2_2() { return cSemicolonKeyword_2_2; }
Example #21
Source Project: xtext-eclipse Author: eclipse File: Bug304681TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getOptionalLoopKeyword_5_6_0() { return cOptionalLoopKeyword_5_6_0; }
Example #22
Source Project: xtext-eclipse Author: eclipse File: BacktrackingContentAssistTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getLeftCurlyBracketKeyword_2_0() { return cLeftCurlyBracketKeyword_2_0; }
Example #23
Source Project: xtext-core Author: eclipse File: XtextGrammarTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getEqualsSignKeyword_1_1_1() { return cEqualsSignKeyword_1_1_1; }
Example #24
Source Project: xtext-core Author: eclipse File: Bug299395TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getRightSquareBracketKeyword_2_2() { return cRightSquareBracketKeyword_2_2; }
Example #25
Source Project: xtext-eclipse Author: eclipse File: Bug289187TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getCommaKeyword_5_2_0() { return cCommaKeyword_5_2_0; }
Example #26
Source Project: xtext-eclipse Author: eclipse File: BacktrackingContentAssistTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getColonKeyword_1() { return cColonKeyword_1; }
Example #27
Source Project: xtext-eclipse Author: eclipse File: Bug304681TestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getSemicolonKeyword_5_0_2() { return cSemicolonKeyword_5_0_2; }
Example #28
Source Project: xtext-core Author: eclipse File: SequencerTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getKw1Keyword_1_1_0() { return cKw1Keyword_1_1_0; }
Example #29
Source Project: xtext-eclipse Author: eclipse File: CrossReferenceProposalTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getRightCurlyBracketKeyword_3() { return cRightCurlyBracketKeyword_3; }
Example #30
Source Project: xtext-core Author: eclipse File: BeeLangTestLanguageGrammarAccess.java License: Eclipse Public License 2.0 | votes |
public Keyword getFunctionNamePlusSignPlusSignKeyword_1_1_0_1() { return cFunctionNamePlusSignPlusSignKeyword_1_1_0_1; }