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

The following examples show how to use org.eclipse.xtext.common.types.xtext.ui.TypeMatchFilters. 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 boolean accept(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames,
		String path) {
	if (TypeMatchFilters.isNotInternal(getSearchFor()).accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path)
		&& TypeMatchFilters.isAcceptableByPreference().accept(modifiers, packageName, simpleTypeName, enclosingTypeNames, path)) {
		XtendFile file = (XtendFile) context.getRootModel();
		final char[] contextPackageName = Strings.emptyIfNull(file.getPackage()).toCharArray();

		if ("org.eclipse.xtend.lib".equals(String.valueOf(packageName))) {
			if ("Property".equals(String.valueOf(simpleTypeName))||"Data".equals(String.valueOf(simpleTypeName))) {
				return false;
			}
		}
		if (Flags.isPublic(modifiers)) {
			return true;
		}
		if (Flags.isPrivate(modifiers)) {
			return false;
		}
		if (Arrays.equals(contextPackageName, packageName)) {
			return true;
		}
	} 
	return false;
}
 
Example #2
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 #3
Source File: XbaseProposalProvider.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void completeXConstructorCall_Constructor(EObject model, Assignment assignment,
		ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
	completeJavaTypes(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, true,
			qualifiedNameValueConverter, TypeMatchFilters.and(TypeMatchFilters.canInstantiate(), createVisibilityFilter(context)), acceptor);
}
 
Example #4
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());
}