Ejemplo n.º 1
0
 @Override
 public void complete_INT(
     EObject model,
     RuleCall ruleCall,
     ContentAssistContext context,
     ICompletionProposalAcceptor acceptor) {
   super.complete_INT(model, ruleCall, context, getCustomAcceptor(model, "integer", acceptor));
 }
Ejemplo n.º 2
0
  /**
   * Validates if a keyword should be viewed by the proposal view.
   *
   * <p>Builds dependent on the ContentAssistContext a list with keywords which shouldn't be
   * displayed by the proposal view.
   */
  @Override
  public void completeKeyword(
      Keyword keyword,
      ContentAssistContext contentAssistContext,
      ICompletionProposalAcceptor acceptor) {
    List<Keyword> suppressKeywords = new ArrayList<Keyword>();
    // context Transition
    if (contentAssistContext.getRootModel() instanceof TransitionSpecification) {
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getEntryEventAccess().getGroup().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getExitEventAccess().getGroup().eContents()));
    }
    // context States
    else if (contentAssistContext.getRootModel() instanceof SimpleScope) {
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getVariableDefinitionAccess().getGroup().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getEventDefinitionAccess().getGroup().eContents()));
      // suppressKeywords.addAll(getKeywords(grammarAccess.getExitpointAccess()
      // .getGroup().eContents()));
      // suppressKeywords.addAll(getKeywords(grammarAccess.getEntrypointAccess()
      // .getGroup().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getDirectionAccess().getAlternatives().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getOperationDefinitionAccess().getGroup().eContents()));
    }
    // context Statechart
    else if (contentAssistContext.getRootModel() instanceof StatechartSpecification) {
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getExitEventAccess().getGroup().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getEntryEventAccess().getGroup().eContents()));

      if (!atLeastOnePackageExistsInIndex(getSctResource(contentAssistContext.getRootModel()))) {
        suppressKeywords.addAll(
            getKeywords(grammarAccess.getImportScopeAccess().getGroup().eContents()));
      }
    }

    EObject currentModel = contentAssistContext.getCurrentModel();
    if (currentModel instanceof InterfaceScope) {
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getLocalReactionAccess().getGroup().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getAlwaysEventAccess().getGroup().eContents()));
      // suppressKeywords.addAll(getKeywords(grammarAccess.getOnCycleEventAccess()
      // .getGroup().eContents()));
      suppressKeywords.addAll(
          getKeywords(grammarAccess.getTimeEventTypeAccess().getAlternatives().eContents()));
      suppressKeywords.add(grammarAccess.getDirectionAccess().getLOCALLocalKeyword_0_0());
    }

    if (currentModel instanceof FeatureCall) {
      FeatureCall featureCall = (FeatureCall) currentModel;
      if (!(featureCall.getFeature() instanceof Operation)) {
        suppressKeywords.add(
            grammarAccess.getFeatureCallAccess().getOperationCallLeftParenthesisKeyword_1_3_0_0());
      }
    }
    if (currentModel instanceof ElementReferenceExpression) {
      ElementReferenceExpression referenceExpression = (ElementReferenceExpression) currentModel;
      if (!(referenceExpression.getReference() instanceof Operation)) {
        suppressKeywords.add(
            grammarAccess
                .getElementReferenceExpressionAccess()
                .getOperationCallLeftParenthesisKeyword_2_0_0());
      }
    }
    if (currentModel instanceof InternalScope) {
      suppressKeywords.add(grammarAccess.getDirectionAccess().getINInKeyword_1_0());
      suppressKeywords.add(grammarAccess.getDirectionAccess().getOUTOutKeyword_2_0());
    }

    if (!suppressKeywords.contains(keyword)) {
      super.completeKeyword(keyword, contentAssistContext, new AcceptorDelegate(acceptor));
    }
  }