Java Code Examples for org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext

The following examples show how to use org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext. 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: gef   Source File: DotProposalProvider.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void completeAttribute_Name(EObject model, Assignment assignment,
		ContentAssistContext contentAssistContext,
		ICompletionProposalAcceptor acceptor) {

	super.completeAttribute_Name(model, assignment, contentAssistContext,
			acceptor);

	EObject modelCompleted = model instanceof NodeStmt ? model.eContainer()
			: model;

	if (modelCompleted instanceof AttrList
			|| modelCompleted instanceof DotGraph
			|| modelCompleted instanceof Subgraph) {
		Context attributeContext = DotAttributes.getContext(modelCompleted);
		proposeAttributeNames(attributeContext, contentAssistContext,
				acceptor);
	}
}
 
Example 2
Source Project: gef   Source File: DotHtmlLabelProposalProvider.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void proposeHtmlBgColorAttributeValues(ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	INode currentNode = context.getCurrentNode();
	String fullText = currentNode.getText();
	String text = fullText;
	int beginReplacementOffset = currentNode.getOffset();

	if (context.getPrefix().contains(":")) { //$NON-NLS-1$
		int colonOffset = fullText.indexOf(':') + 1;
		text = fullText.substring(colonOffset);
		beginReplacementOffset += colonOffset;
	} else {
		beginReplacementOffset += beginsWithQuote(text) ? 1 : 0;
	}
	proposeHtmlColorAttributeValues(context, acceptor,
			text.replaceAll("['\"]", ""), //$NON-NLS-1$ //$NON-NLS-2$
			beginReplacementOffset, context.getOffset());
	if (!fullText.contains(":")) { //$NON-NLS-1$
		acceptor.accept(new ConfigurableCompletionProposal(":", //$NON-NLS-1$
				context.getOffset(), 0, 1));
	}
}
 
Example 3
Source Project: xtext-eclipse   Source File: CurrentModelBugTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void verify(ContentAssistContext contentAssistContext) {
	EObject currentModel = contentAssistContext.getCurrentModel();
	assertEquals(currentModel.toString(), expectedClass, currentModel.eClass());
	if (expectedClassName != null) {
		assertTrue(contentAssistContext.getCurrentModel() instanceof org.eclipse.xtext.ui.tests.editor.contentassist.domainModelTest.Class);
		assertEquals(expectedClassName, ((org.eclipse.xtext.ui.tests.editor.contentassist.domainModelTest.Class) contentAssistContext.getCurrentModel()).getName());
	}
}
 
Example 4
/**
 * Adds template proposals for all checks which may be referenced in current catalog configuration. Only proposals for checks
 * which have not yet been configured are provided.
 *
 * @param templateContext
 *          the template context
 * @param context
 *          the context
 * @param acceptor
 *          the acceptor
 */
private void addConfiguredCheckTemplates(final TemplateContext templateContext, final ContentAssistContext context, final ITemplateAcceptor acceptor) { // NOPMD
  ConfiguredCatalog configuredCatalog = EcoreUtil2.getContainerOfType(context.getCurrentModel(), ConfiguredCatalog.class);
  Iterable<String> alreadyConfiguredCheckNames = Iterables.filter(Iterables.transform(configuredCatalog.getCheckConfigurations(), new Function<ConfiguredCheck, String>() {
    @Override
    public String apply(final ConfiguredCheck from) {
      if (from.getCheck() != null) {
        return from.getCheck().getName();
      }
      return null;
    }
  }), Predicates.notNull());
  final CheckCatalog catalog = configuredCatalog.getCatalog();
  for (final Check check : catalog.getAllChecks()) {
    // create a template on the fly
    final String checkName = check.getName();
    if (!Iterables.contains(alreadyConfiguredCheckNames, checkName)) {

      // check if referenced check has configurable parameters
      final StringJoiner paramsJoiner = new StringJoiner(", ", " (", ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      paramsJoiner.setEmptyValue(""); //$NON-NLS-1$
      for (final FormalParameter param : check.getFormalParameters()) {
        final String paramName = param.getName();
        final Object defaultValue = interpreter.evaluate(param.getRight()).getResult();

        final String valuePlaceholder = helper.createLiteralValuePattern(paramName, defaultValue);
        paramsJoiner.add(paramName + " = " + valuePlaceholder); //$NON-NLS-1$
      }

      final String severity = (catalog.isFinal() || check.isFinal()) ? "default " : "${default:Enum('SeverityKind')} "; //$NON-NLS-1$ //$NON-NLS-2$
      final String description = "Configures the check \"" + check.getLabel() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
      final String contextTypeId = "com.avaloq.tools.ddk.checkcfg.CheckCfg.ConfiguredCheck." + checkName; //$NON-NLS-1$
      final String pattern = severity + qualifiedNameValueConverter.toString(checkName) + paramsJoiner + "${cursor}"; //$NON-NLS-1$

      Template t = new Template(checkName, description, contextTypeId, pattern, true);
      TemplateProposal tp = createProposal(t, templateContext, context, images.forConfiguredCheck(check.getDefaultSeverity()), getRelevance(t));
      acceptor.accept(tp);
    }
  }
}
 
Example 5
public void completeSpecificDirective_GrammarElements(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 6
public void completeIfExp_ThenExpression(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 7
public void complete_BooleanOperator(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 8
Source Project: n4js   Source File: AbstractN4JSProposalProvider.java    License: Eclipse Public License 1.0 4 votes vote down vote up
public void complete_NamespaceImportSpecifier(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 9
public void completeRoundBracketExp_Arguments(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 10
public void completeModel_Model(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 11
public void completeXBasicForLoopExpression_Expression(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 12
@Override
public void completeXCatchClause_Expression(EObject model, Assignment assignment, ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	createLocalVariableAndImplicitProposals(model, IExpressionScope.Anchor.WITHIN, context, acceptor);
}
 
Example 13
Source Project: bromium   Source File: AbstractBromiumProposalProvider.java    License: MIT License 4 votes vote down vote up
public void complete_ExposedParameter(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 14
public void completeClosureExpression_FuncExpr(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 15
public void completeOperation_4_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 16
public void completeClosureExpression_VarArgs(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 17
public void completeXOtherOperatorExpression_Feature(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
}
 
Example 18
void createTypeProposals(ICompletionProposalFactory proposalFactory, ContentAssistContext context,
EReference typeReference, Filter filter, IValueConverter<String> valueConverter, ICompletionProposalAcceptor acceptor);
 
Example 19
@Override
public void completeXShortClosure_Expression(EObject model, Assignment assignment, ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	createLocalVariableAndImplicitProposals(model, IExpressionScope.Anchor.WITHIN, context, acceptor);
}
 
Example 20
@Override
public void complete_Annotation(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	createAnnotationProposals(acceptor, context, true);
}
 
Example 21
public void completePredicatedKeyword_FirstSetPredicated(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 22
public Class<? extends ContentAssistContext.Factory> bindContentAssistContext$Factory() {
	return DelegatingContentAssistContextFactory.class;
}
 
Example 23
public Class<? extends ContentAssistContext.Factory> bindContentAssistContext$Factory() {
	return DelegatingContentAssistContextFactory.class;
}
 
Example 24
public void completeModel_Imports(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 25
public void completeS_Loop_Key(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 26
public void completeLiteralCondition_True(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 27
public void completeAugmentUsesStatement_Augmentsubstatements(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example 28
public void completeXImportDeclaration_Extension(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 29
public void complete_LT(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example 30
public void completeGrammar_HiddenTokens(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
}