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

The following examples show how to use org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext. 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: DotProposalProvider.java    From gef with 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 File: DotHtmlLabelProposalProvider.java    From gef with 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 File: CurrentModelBugTest.java    From xtext-eclipse with 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
Source File: CheckCfgTemplateProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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
Source File: AbstractExportProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public void completeExportModel_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #6
Source File: AbstractXmlProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_STRING(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #7
Source File: AbstractValidProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public void complete_QuickFixKind(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #8
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeVariableStatement_VarDeclsOrBindings(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #9
Source File: AbstractCheckCfgProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public void complete_ConfiguredCatalog(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #10
Source File: AbstractGamlProposalProvider.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public void completeStringLiteral_Op(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #11
Source File: AbstractBug360834TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_UnorderedModifiers(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #12
Source File: AbstractFormatProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public void completeOffsetLocator_Nobreak(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #13
Source File: AbstractReferringTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ContentAssistContext.Factory> bindContentAssistContext$Factory() {
	return DelegatingContentAssistContextFactory.class;
}
 
Example #14
Source File: AbstractTwoContextsTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeAnElement_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #15
Source File: AbstractExportProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public void complete_DeclarationForType(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #16
Source File: XtendProposalProvider.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void complete_RICH_TEXT(EObject model, RuleCall ruleCall, ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	completeInRichString(model, ruleCall, context, acceptor);
}
 
Example #17
Source File: AbstractXtextProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeAssignment_FirstSetPredicated(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #18
Source File: AbstractDomainmodelProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_AbstractElement(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #19
Source File: AbstractN4JSProposalProvider.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public void completeN4ClassDeclaration_Name(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #20
Source File: AbstractBug347012TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_idPlainChar(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #21
Source File: AbstractYangProposalProvider.java    From yang-design-studio with Eclipse Public License 1.0 4 votes vote down vote up
public void complete_ErrorAppTagStatement(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #22
Source File: CodetemplatesProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected IFollowElementAcceptor createNestedSelector(ContentAssistContext context,
		ICompletionProposalAcceptor acceptor, TemplateData data) {
	return new NestedContentAssistProcessorSwitch(context, acceptor, data);
}
 
Example #23
Source File: AbstractBug288734TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_TConstant(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #24
Source File: AbstractCheckProposalProvider.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public void completeCheck_Contexts(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #25
Source File: AbstractBug303200TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void complete_Parameters(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #26
Source File: AbstractSARLProposalProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
public void complete_BreakExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	// subclasses may override
}
 
Example #27
Source File: AbstractBug287941TestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeBooleanAttributeWhereEntry_Alias(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
}
 
Example #28
Source File: AbstractBug348199TestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ContentAssistContext.Factory> bindContentAssistContext$Factory() {
	return DelegatingContentAssistContextFactory.class;
}
 
Example #29
Source File: AbstractParametersTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeScenario4_Second(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
 
Example #30
Source File: AbstractContentAssistContextTestLanguageProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void completeFirstLevel_SecondLevelB(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}