Java Code Examples for org.eclipse.xtext.xtype.XImportDeclaration#setStatic()

The following examples show how to use org.eclipse.xtext.xtype.XImportDeclaration#setStatic() . 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: RewritableImportSection.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public boolean addStaticImport(JvmDeclaredType type, String memberName) {
	if (hasStaticImport(staticImports, type, memberName)) {
		return false;
	}
	Maps2.putIntoSetMap(type, memberName, staticImports);
	XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
	importDeclaration.setImportedType(type);
	importDeclaration.setStatic(true);
	if (memberName == null) {
		importDeclaration.setWildcard(true);
	} else {
		importDeclaration.setMemberName(memberName);
	}
	addedImportDeclarations.add(importDeclaration);
	return true;
}
 
Example 2
Source File: RewritableImportSection.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public boolean addStaticExtensionImport(JvmDeclaredType type, String memberName) {
	if (hasStaticImport(staticExtensionImports, type, memberName)) {
		return false;
	}
	Maps2.putIntoSetMap(type, memberName, staticExtensionImports);
	XImportDeclaration importDeclaration = XtypeFactory.eINSTANCE.createXImportDeclaration();
	importDeclaration.setImportedType(type);
	importDeclaration.setStatic(true);
	importDeclaration.setExtension(true);
	if (memberName == null) {
		importDeclaration.setWildcard(true);
	} else {
		importDeclaration.setMemberName(memberName);
	}
	addedImportDeclarations.add(importDeclaration);
	return true;
}
 
Example 3
Source File: RewritableImportSection.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param typeFqn
 *            The fully qualified name of the type to import. E.g. <code>java.util.List</code>. May not be
 *            <code>null</code>.
 * @param member
 *            member name to import. May not be <code>null</code>. For wildcard use <code>*</code>
 * 
 */
public boolean addStaticImport(final String typeFqn, final String member) {
	if (typeFqn == null || member == null) {
		throw new IllegalArgumentException("Type name " + typeFqn + ". Member name: " + member);
	}
	if (hasStaticImport(typeFqn, member, false)) {
		return false;
	}
	XImportDeclaration importDecl = createImport(typeFqn, member);
	importDecl.setStatic(true);
	return addedImportDeclarations.add(importDecl);
}
 
Example 4
Source File: RewritableImportSection.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @param typeFqn
 *            The fully qualified name of the type to import. E.g. <code>java.util.List</code>. May not be
 *            <code>null</code>.
 * @param member
 *            member name to import. May not be <code>null</code>. For wildcard use <code>*</code>
 * 
 */
public boolean addStaticExtensionImport(final String typeFqn, final String member) {
	if (typeFqn == null || member == null) {
		throw new IllegalArgumentException("Type name " + typeFqn + ". Member name: " + member);
	}
	if (hasStaticImport(typeFqn, member, true)) {
		return false;
	}
	XImportDeclaration importDecl = createImport(typeFqn, member);
	importDecl.setStatic(true);
	importDecl.setExtension(true);
	return addedImportDeclarations.add(importDecl);
}