Java Code Examples for org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry#setLabel()

The following examples show how to use org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry#setLabel() . 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: ImportsAwareReferenceProposalCreator.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private ContentAssistEntry convertResolutionToContentAssistEntry(ReferenceResolution resolution,
		N4JSResource resource, ContentAssistContext context) {
	ContentAssistEntry cae = new ContentAssistEntry();
	cae.setPrefix(context.getPrefix());
	cae.setProposal(resolution.proposal);
	cae.setLabel(resolution.label);
	cae.setDescription(resolution.description);
	if (resolution.importToBeAdded != null) {
		ReplaceRegion textReplacement = importHelper.getReplacementForImport(resource.getScript(),
				resolution.importToBeAdded);
		cae.getTextReplacements().add(textReplacement);
	}
	cae.setSource(resolution.referencedElement);
	cae.setKind(getKind(resolution));
	return cae;
}
 
Example 2
Source File: JSONIdeContentProposalProvider.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private void addTemplateProposal(
		String proposal,
		String label,
		String description,
		String kind,
		ContentAssistContext context,
		IIdeContentProposalAcceptor acceptor) {
	if (getProposalCreator().isValidProposal(label, context.getPrefix(), context)) {
		ContentAssistEntry entry = new ContentAssistEntry();
		entry.setProposal(proposal);
		entry.setPrefix(context.getPrefix());
		entry.setKind(ContentAssistEntry.KIND_SNIPPET + ":" + kind);
		entry.setLabel(label);
		entry.setDescription(description);
		acceptor.accept(entry, getProposalPriorities().getDefaultPriority(entry));
	}
}
 
Example 3
Source File: XbaseIdeCrossrefProposalProvider.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected void addNameAndDescription(ContentAssistEntry entry, EObject element, String qualifiedNameAsString,
		String shortName) {
	QualifiedName qualifiedName = getQualifiedNameConverter().toQualifiedName(qualifiedNameAsString);
	if (qualifiedName.getSegmentCount() > 1) {
		entry.setLabel(qualifiedName.getLastSegment());
		entry.setDescription(qualifiedNameAsString);
	} else {
		entry.setLabel(qualifiedNameAsString);
	}
}
 
Example 4
Source File: XbaseIdeCrossrefProposalProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
protected void addNameAndDescription(ContentAssistEntry entry, JvmFeature feature, boolean withParents,
		int insignificantParameters, String shortName, LightweightTypeReferenceFactory converter) {
	StringBuilder labelBuilder = new StringBuilder(shortName);
	StringBuilder descriptionBuilder = new StringBuilder();
	if (feature instanceof JvmOperation) {
		if (withParents) {
			labelBuilder.append("(");
			appendParameters(labelBuilder, (JvmExecutable) feature, insignificantParameters, converter);
			labelBuilder.append(")");
		}
		JvmOperation jvmOperation = (JvmOperation) feature;
		JvmTypeReference returnType = jvmOperation.getReturnType();
		if (returnType != null && returnType.getSimpleName() != null) {
			labelBuilder.append(" : ");
			labelBuilder.append(converter.toLightweightReference(returnType).getHumanReadableName());
		}
		descriptionBuilder.append(
				converter.toPlainTypeReference(jvmOperation.getDeclaringType()).getHumanReadableName());
		if (!withParents) {
			descriptionBuilder.append(".");
			descriptionBuilder.append(jvmOperation.getSimpleName());
			descriptionBuilder.append("()");
		}
	} else {
		if (feature instanceof JvmField) {
			labelBuilder.append(" : ");
			JvmField jvmField = (JvmField) feature;
			if (jvmField.getType() != null) {
				String fieldType = converter.toLightweightReference(jvmField.getType())
						.getHumanReadableName();
				if (fieldType != null) {
					labelBuilder.append(fieldType);
				}
			}
			descriptionBuilder.append(
					converter.toPlainTypeReference(jvmField.getDeclaringType()).getHumanReadableName());
		} else if (feature instanceof JvmConstructor) {
			if (withParents) {
				labelBuilder.append("(");
				appendParameters(labelBuilder, ((JvmExecutable) feature), insignificantParameters, converter);
				labelBuilder.append(")");
			}
		}
	}
	entry.setLabel(labelBuilder.toString());
	entry.setDescription(descriptionBuilder.toString());
}