blob: 2e4c33ebb7a114fa941125f66aed88f5b3ed222c [file] [log] [blame]
package org.eclipse.osbp.xtext.oxtype.ui.quickfix;
import org.eclipse.osbp.xtext.oxtype.oxtype.OXImportDeclaration;
import org.eclipse.xtext.util.IAcceptor;
import org.eclipse.xtext.xbase.ui.quickfix.JavaTypeQuickfixes;
import org.eclipse.xtext.xtype.XImportDeclaration;
import org.eclipse.xtext.xtype.XImportSection;
@SuppressWarnings("restriction")
public class CustomJavaTypeQuickfixes extends JavaTypeQuickfixes {
protected void parseImportSection(XImportSection importSection,
IAcceptor<String> visiblePackages, IAcceptor<String> importedTypes) {
for (XImportDeclaration importDeclaration : importSection
.getImportDeclarations()) {
if (!importDeclaration.isStatic()) {
// do not use fqn imports
if (importDeclaration instanceof OXImportDeclaration) {
OXImportDeclaration oxImportDecl = (OXImportDeclaration) importDeclaration;
if (oxImportDecl.isFqnImport()) {
continue;
}
}
if (importDeclaration.getImportedNamespace() != null) {
String importedAsString = importDeclaration
.getImportedNamespace();
if (importDeclaration.isWildcard()) {
importedAsString = importedAsString.substring(0,
importedAsString.length() - 2);
visiblePackages.accept(importedAsString);
} else {
importedTypes.accept(importedAsString);
}
} else {
importedTypes.accept(importDeclaration
.getImportedTypeName());
}
}
}
}
}