Search in sources :

Example 26 with ParameterizedType

use of org.eclipse.jdt.core.dom.ParameterizedType in project bndtools by bndtools.

the class NewTypeWizardPage method superClassChanged.

/**
     * Hook method that gets called when the superclass name has changed. The method validates the superclass name and
     * returns the status of the validation.
     * <p>
     * Subclasses may extend this method to perform their own validation.
     * </p>
     *
     * @return the status of the validation
     */
protected IStatus superClassChanged() {
    StatusInfo status = new StatusInfo();
    IPackageFragmentRoot root = getPackageFragmentRoot();
    fSuperClassDialogField.enableButton(root != null);
    fSuperClassStubTypeContext = null;
    String sclassName = getSuperClass();
    if (sclassName.length() == 0) {
        // accept the empty field (stands for java.lang.Object)
        return status;
    }
    if (root != null) {
        Type type = TypeContextChecker.parseSuperClass(sclassName);
        if (type == null) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperClassName);
            return status;
        }
        if (type instanceof ParameterizedType && !JavaModelUtil.is50OrHigher(root.getJavaProject())) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_SuperClassNotParameterized);
            return status;
        }
    } else {
        //$NON-NLS-1$
        status.setError("");
    }
    return status;
}
Also used : ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) IType(org.eclipse.jdt.core.IType) ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) Type(org.eclipse.jdt.core.dom.Type) StatusInfo(org.eclipse.jdt.internal.ui.dialogs.StatusInfo) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Example 27 with ParameterizedType

use of org.eclipse.jdt.core.dom.ParameterizedType in project bndtools by bndtools.

the class NewTypeWizardPage method superInterfacesChanged.

/**
     * Hook method that gets called when the list of super interface has changed. The method validates the super
     * interfaces and returns the status of the validation.
     * <p>
     * Subclasses may extend this method to perform their own validation.
     * </p>
     *
     * @return the status of the validation
     */
protected IStatus superInterfacesChanged() {
    StatusInfo status = new StatusInfo();
    IPackageFragmentRoot root = getPackageFragmentRoot();
    fSuperInterfacesDialogField.enableButton(0, root != null);
    if (root != null) {
        List<InterfaceWrapper> elements = fSuperInterfacesDialogField.getElements();
        int nElements = elements.size();
        for (int i = 0; i < nElements; i++) {
            String intfname = elements.get(i).interfaceName;
            Type type = TypeContextChecker.parseSuperInterface(intfname);
            if (type == null) {
                status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperInterfaceName, BasicElementLabels.getJavaElementName(intfname)));
                return status;
            }
            if (type instanceof ParameterizedType && !JavaModelUtil.is50OrHigher(root.getJavaProject())) {
                status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_SuperInterfaceNotParameterized, BasicElementLabels.getJavaElementName(intfname)));
                return status;
            }
        }
    }
    return status;
}
Also used : ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) IType(org.eclipse.jdt.core.IType) ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) Type(org.eclipse.jdt.core.dom.Type) StatusInfo(org.eclipse.jdt.internal.ui.dialogs.StatusInfo) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Aggregations

ParameterizedType (org.eclipse.jdt.core.dom.ParameterizedType)27 Type (org.eclipse.jdt.core.dom.Type)21 SimpleType (org.eclipse.jdt.core.dom.SimpleType)13 ArrayType (org.eclipse.jdt.core.dom.ArrayType)12 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)10 IType (org.eclipse.jdt.core.IType)9 ASTNode (org.eclipse.jdt.core.dom.ASTNode)9 NameQualifiedType (org.eclipse.jdt.core.dom.NameQualifiedType)7 QualifiedType (org.eclipse.jdt.core.dom.QualifiedType)7 SimpleName (org.eclipse.jdt.core.dom.SimpleName)6 ClassInstanceCreation (org.eclipse.jdt.core.dom.ClassInstanceCreation)5 Name (org.eclipse.jdt.core.dom.Name)5 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)4 ASTVisitor (org.eclipse.jdt.core.dom.ASTVisitor)4 AbstractTypeDeclaration (org.eclipse.jdt.core.dom.AbstractTypeDeclaration)4 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)4 UnionType (org.eclipse.jdt.core.dom.UnionType)4 AST (org.eclipse.jdt.core.dom.AST)3 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)3 MethodInvocation (org.eclipse.jdt.core.dom.MethodInvocation)3