org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider Java Examples

The following examples show how to use org.eclipse.xtext.common.types.xtext.ui.ITypesProposalProvider. 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: XtendProposalProvider.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void completeType_Extends(EObject model, Assignment assignment, ContentAssistContext context,
		ICompletionProposalAcceptor acceptor) {
	final boolean isInterface = assignment == grammarAccess.getTypeAccess().getExtendsAssignment_2_1_5_1()
			|| assignment == grammarAccess.getTypeAccess().getExtendsAssignment_2_1_5_2_1();
	//	FIXME filter "self"
	completeJavaTypes(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, true, getQualifiedNameValueConverter(),
			new ITypesProposalProvider.Filter() {
				@Override
				public int getSearchFor() {
					return isInterface ? IJavaSearchConstants.INTERFACE : IJavaSearchConstants.CLASS;
				}

				@Override
				public boolean accept(int modifiers, char[] packageName, char[] simpleTypeName,
						char[][] enclosingTypeNames, String path) {
					
					if (TypeMatchFilters.isInternalClass(simpleTypeName, enclosingTypeNames))
						return false;
					if (!TypeMatchFilters.isAcceptableByPreference().accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path)) {
						return false;
					}
					return !Flags.isFinal(modifiers);
				}
			}, acceptor);
}
 
Example #2
Source File: SARLProposalProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Complete for Java types.
 *
 * @param context the completion context.
 * @param filter the filter for the types.
 * @param acceptor the proposal acceptor.
 */
protected void completeJavaTypes(ContentAssistContext context,
		ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) {
	completeJavaTypes(context,
			TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE,
			true,
			getQualifiedNameValueConverter(),
			filter,
			acceptor);
}
 
Example #3
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void completeJavaTypes(ContentAssistContext context, EReference reference, boolean forced,
		IValueConverter<String> valueConverter, ITypesProposalProvider.Filter filter,
		ICompletionProposalAcceptor acceptor) {
	String prefix = context.getPrefix();
	if (prefix.length() > 0) {
		if (Character.isJavaIdentifierStart(context.getPrefix().charAt(0))) {
			if (!forced && getXbaseCrossReferenceProposalCreator().isShowSmartProposals()) {
				if (!prefix.contains(".") && !prefix.contains("::") && !Character.isUpperCase(prefix.charAt(0)))
					return;
			}
			typeProposalProvider.createTypeProposals(this, context, reference, filter, valueConverter, acceptor);
		}
	} else {
		if (forced || !getXbaseCrossReferenceProposalCreator().isShowSmartProposals()) {
			INode lastCompleteNode = context.getLastCompleteNode();
			if (lastCompleteNode instanceof ILeafNode && !((ILeafNode) lastCompleteNode).isHidden()) {
				if (lastCompleteNode.getLength() > 0 && lastCompleteNode.getTotalEndOffset() == context.getOffset()) {
					String text = lastCompleteNode.getText();
					char lastChar = text.charAt(text.length() - 1);
					if (Character.isJavaIdentifierPart(lastChar)) {
						return;
					}
				}
			}
			typeProposalProvider.createTypeProposals(this, context, reference, filter, valueConverter, acceptor);
		}
	}
}
 
Example #4
Source File: XtendJavaDocCompletionProposalComputer.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ICompletionProposal[] exec(XtextResource resource) throws Exception {

	List<ContentAssistContext> contexts = Arrays.asList(protocol.getContextFactory().create(viewer, offset, resource));
	if (contexts.size() > 0) {
		ContentAssistContext contentAssistContext = contexts.get(contexts.size() -1);
		if(isValidPositionForTypeProposal(contentAssistContext)){
			ITypesProposalProvider typesProposalProvider = protocol.getTypesProposalProvider();
			typesProposalProvider.createTypeProposals(protocol.getProposalFactory(), contentAssistContext, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, this);
		}
	}
	return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
 
Example #5
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void completeJavaTypes(ContentAssistContext context, EReference reference, ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) {
	completeJavaTypes(context, reference, qualifiedNameValueConverter, filter, acceptor);
}
 
Example #6
Source File: SARLProposalProvider.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Complete for obtaining SARL types that are subtypes of the given type.
 *
 * @param superType the super-type.
 * @param allowSuperTypeItself indicates if the super-type itself is allowed to be in the proposals.
 * @param context the content assist context.
 * @param reference the reference to the rule part to be complete.
 * @param valueConverter the converter of the proposed values.
 * @param filter the filter of the proposed values.
 * @param acceptor the proposal acceptor.
 */
protected void completeSubJavaTypes(Class<?> superType, boolean allowSuperTypeItself, ContentAssistContext context,
		EReference reference, IValueConverter<String> valueConverter, final ITypesProposalProvider.Filter filter,
		ICompletionProposalAcceptor acceptor) {
	assert superType != null;
	final INode lastCompleteNode = context.getLastCompleteNode();
	if (lastCompleteNode instanceof ILeafNode && !((ILeafNode) lastCompleteNode).isHidden()) {
		if (lastCompleteNode.getLength() > 0 && lastCompleteNode.getTotalEndOffset() == context.getOffset()) {
			final String text = lastCompleteNode.getText();
			final char lastChar = text.charAt(text.length() - 1);
			if (Character.isJavaIdentifierPart(lastChar)) {
				return;
			}
		}
	}
	final ITypesProposalProvider.Filter subTypeFilter;
	if (allowSuperTypeItself) {
		subTypeFilter = filter;
	} else {
		final String superTypeQualifiedName = superType.getName();
		subTypeFilter = new ITypesProposalProvider.Filter() {

			@Override
			public boolean accept(int modifiers, char[] packageName, char[] simpleTypeName,
					char[][] enclosingTypeNames, String path) {
				final String fullName = JavaModelUtil.concatenateName(packageName, simpleTypeName);
				if (Objects.equals(superTypeQualifiedName, fullName)) {
					return false;
				}
				return filter.accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path);
			}

			@Override
			public int getSearchFor() {
				return filter.getSearchFor();
			}

		};
	}
	getTypesProposalProvider().createSubTypeProposals(
			this.typeReferences.findDeclaredType(superType, context.getCurrentModel()),
			this,
			context,
			reference,
			subTypeFilter,
			valueConverter,
			acceptor);
}
 
Example #7
Source File: AbstractSARLUiModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return SARLImportingTypesProposalProvider.class;
}
 
Example #8
Source File: XtendJavaDocContentAssistProcessor.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ITypesProposalProvider getTypesProposalProvider() {
	return typeProposalProvider;
}
 
Example #9
Source File: XtendProposalProvider.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected ITypesProposalProvider.Filter createVisibilityFilter(ContentAssistContext context, int searchFor) {
	return new VisibilityFilter(context, searchFor);
}
 
Example #10
Source File: XtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return XtendImportingTypesProposalProvider.class;
}
 
Example #11
Source File: AbstractXtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return ImportingTypesProposalProvider.class;
}
 
Example #12
Source File: DefaultCommonTypesUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return JdtTypesProposalProvider.class;
}
 
Example #13
Source File: AbstractXImportSectionTestLangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return ImportingTypesProposalProvider.class;
}
 
Example #14
Source File: AbstractPureXbaseUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return ImportingTypesProposalProvider.class;
}
 
Example #15
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected ITypesProposalProvider getTypesProposalProvider() {
	return typeProposalProvider;
}
 
Example #16
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected ITypesProposalProvider.Filter createVisibilityFilter(ContentAssistContext context, int searchFor) {
	return TypeMatchFilters.and(TypeMatchFilters.isNotInternal(searchFor), TypeMatchFilters.isAcceptableByPreference());
}
 
Example #17
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected ITypesProposalProvider.Filter createVisibilityFilter(ContentAssistContext context) {
	return createVisibilityFilter(context, IJavaSearchConstants.TYPE);
}
 
Example #18
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected void completeJavaTypes(ContentAssistContext context, EReference reference, IValueConverter<String> valueConverter, ITypesProposalProvider.Filter filter, ICompletionProposalAcceptor acceptor) {
	completeJavaTypes(context, reference, false, valueConverter, filter, acceptor);
}
 
Example #19
Source File: AbstractDomainmodelUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends ITypesProposalProvider> bindITypesProposalProvider() {
	return ImportingTypesProposalProvider.class;
}
 
Example #20
Source File: SARLProposalProvider.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Create a filter for "extends".
 *
 * <p>An extension filter applies the following constraints: <ul>
 * <li>the type is not an inner type;</li>
 * <li>the type is not final;</li>
 * <li>the type is visible.</li>
 * </ul>
 *
 * @param context the proposal context.
 * @param type the type of the expected proposals.
 * @return the filter.
 */
protected ITypesProposalProvider.Filter createExtensionFilter(ContentAssistContext context, int type) {
	return new ExtensionFilter(context, type);
}
 
Example #21
Source File: XtendJavaDocState.java    From xtext-xtend with Eclipse Public License 2.0 votes vote down vote up
public ITypesProposalProvider getTypesProposalProvider();