Example usage for org.eclipse.jdt.core IType isLocal

List of usage examples for org.eclipse.jdt.core IType isLocal

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IType isLocal.

Prototype

boolean isLocal() throws JavaModelException;

Source Link

Document

Returns whether this type represents a local type.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.codeassist.SelectionEngine.java

License:Open Source License

/**
 * Asks the engine to compute the selection of the given type
 * from the given context/*from ww  w .  j a v  a2 s.  c  o  m*/
 *
 *  @param typeName char[]
 *      a type name which is to be resolved in the context of a compilation unit.
 *      NOTE: the type name is supposed to be correctly reduced (no whitespaces, no unicodes left)
 *
 *  @param context org.eclipse.jdt.core.IType
 *      the context in which code assist is invoked.
 */
public void selectType(char[] typeName, IType context) throws JavaModelException {
    try {
        this.acceptedAnswer = false;

        // only the type erasure are returned by IType.resolvedType(...)
        if (CharOperation.indexOf('<', typeName) != -1) {
            char[] typeSig = Signature.createCharArrayTypeSignature(typeName, false/*not resolved*/);
            typeSig = Signature.getTypeErasure(typeSig);
            typeName = Signature.toCharArray(typeSig);
        }

        CompilationUnitDeclaration parsedUnit = null;
        TypeDeclaration typeDeclaration = null;
        org.eclipse.jdt.core.ICompilationUnit cu = context.getCompilationUnit();
        if (cu != null) {
            IType[] topLevelTypes = cu.getTypes();
            int length = topLevelTypes.length;
            SourceTypeElementInfo[] topLevelInfos = new SourceTypeElementInfo[length];
            for (int i = 0; i < length; i++) {
                topLevelInfos[i] = (SourceTypeElementInfo) ((SourceType) topLevelTypes[i]).getElementInfo();
            }
            CompilationResult result = new CompilationResult(
                    (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) cu, 1, 1,
                    this.compilerOptions.maxProblemsPerUnit);
            int flags = SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE;
            if (context.isAnonymous() || context.isLocal())
                flags |= SourceTypeConverter.LOCAL_TYPE;
            parsedUnit = SourceTypeConverter.buildCompilationUnit(topLevelInfos, flags,
                    this.parser.problemReporter(), result);
            if (parsedUnit != null && parsedUnit.types != null) {
                if (DEBUG) {
                    System.out.println("SELECTION - Diet AST :"); //$NON-NLS-1$
                    System.out.println(parsedUnit.toString());
                }
                // find the type declaration that corresponds to the original source type
                typeDeclaration = new ASTNodeFinder(parsedUnit).findType(context);
            }
        } else { // binary type
            ClassFile classFile = (ClassFile) context.getClassFile();
            ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo(
                    (IFile) null/*classFile.resource()*/,
                    false/*don't fully initialize so as to keep constant pool (used below)*/);
            CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1,
                    this.compilerOptions.maxProblemsPerUnit);
            parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
            HashSetOfCharArrayArray typeNames = new HashSetOfCharArrayArray();

            BinaryTypeConverter converter = new BinaryTypeConverter(this.parser.problemReporter(), result,
                    typeNames);
            typeDeclaration = converter.buildTypeDeclaration(context, parsedUnit);
            parsedUnit.imports = converter.buildImports(reader);
        }

        if (typeDeclaration != null) {

            // add fake field with the type we're looking for
            // note: since we didn't ask for fields above, there is no field defined yet
            FieldDeclaration field = new FieldDeclaration();
            int dot;
            if ((dot = CharOperation.lastIndexOf('.', typeName)) == -1) {
                this.selectedIdentifier = typeName;
                field.type = new SelectionOnSingleTypeReference(typeName, -1);
                // position not used
            } else {
                char[][] previousIdentifiers = CharOperation.splitOn('.', typeName, 0, dot);
                char[] selectionIdentifier = CharOperation.subarray(typeName, dot + 1, typeName.length);
                this.selectedIdentifier = selectionIdentifier;
                field.type = new SelectionOnQualifiedTypeReference(previousIdentifiers, selectionIdentifier,
                        new long[previousIdentifiers.length + 1]);
            }
            field.name = "<fakeField>".toCharArray(); //$NON-NLS-1$
            typeDeclaration.fields = new FieldDeclaration[] { field };

            // build bindings
            this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
            if ((this.unitScope = parsedUnit.scope) != null) {
                try {
                    // build fields
                    // note: this builds fields only in the parsed unit (the buildFieldsAndMethods flag is not passed along)
                    this.lookupEnvironment.completeTypeBindings(parsedUnit, true);

                    // resolve
                    parsedUnit.scope.faultInTypes();
                    parsedUnit.resolve();
                } catch (SelectionNodeFound e) {
                    if (e.binding != null) {
                        if (DEBUG) {
                            System.out.println("SELECTION - Selection binding :"); //$NON-NLS-1$
                            System.out.println(e.binding.toString());
                        }
                        // if null then we found a problem in the selection node
                        selectFrom(e.binding, parsedUnit, e.isDeclaration);
                    }
                }
            }
        }
        if (this.noProposal && this.problem != null) {
            this.requestor.acceptError(this.problem);
        }
    } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object
    } finally {
        reset(true);
    }
}

From source file:de.loskutov.dh.search.SearchUtils.java

License:Open Source License

private static Set<IType> getAllMemberTypes(IType type, IProgressMonitor monitor) throws JavaModelException {
    HashSet<IType> set = new HashSet<IType>();
    IType[] memberTypes = type.getTypes();
    for (IType iType : memberTypes) {
        if (iType.isClass() && iType.isLocal()) {
            set.add(iType);//from   w  w  w.  j  av  a  2 s.co  m
        }
    }
    return set;
}

From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java

License:Open Source License

/********************************************************************************/

static void outputTypeHierarchy(ITypeHierarchy th, IvyXmlWriter xw) {
    xw.begin("HIERARCHY");
    IType[] typs = th.getAllTypes();/*from  www.  j  ava 2s. c  om*/
    for (IType typ : typs) {
        xw.begin("TYPE");
        try {
            xw.field("NAME", typ.getFullyQualifiedName());
            xw.field("QNAME", typ.getTypeQualifiedName());
            xw.field("PNAME", typ.getFullyQualifiedParameterizedName());
            if (typ.isClass())
                xw.field("KIND", "CLASS");
            else if (typ.isEnum())
                xw.field("KIND", "ENUM");
            else if (typ.isInterface())
                xw.field("KIND", "INTERFACE");
            xw.field("LOCAL", typ.isLocal());
            xw.field("MEMBER", typ.isMember());
            xw.field("KEY", typ.getKey());
            IType[] subs = th.getAllSubtypes(typ);
            for (IType styp : subs) {
                xw.begin("SUBTYPE");
                xw.field("NAME", styp.getFullyQualifiedName());
                xw.field("KEY", styp.getKey());
                xw.end("SUBTYPE");
            }
            IType[] sups = th.getAllSuperclasses(typ);
            for (IType styp : sups) {
                xw.begin("SUPERCLASS");
                xw.field("NAME", styp.getFullyQualifiedName());
                xw.field("KEY", styp.getKey());
                xw.end("SUPERCLASS");
            }
            sups = th.getAllSuperInterfaces(typ);
            for (IType styp : sups) {
                xw.begin("SUPERIFACE");
                xw.field("NAME", styp.getFullyQualifiedName());
                xw.field("KEY", styp.getKey());
                xw.end("SUPERIFACE");
            }
            sups = th.getAllSupertypes(typ);
            for (IType styp : sups) {
                xw.begin("SUPERTYPE");
                xw.field("NAME", styp.getFullyQualifiedName());
                xw.field("KEY", styp.getKey());
                xw.end("SUPERTYPE");
            }
            sups = th.getExtendingInterfaces(typ);
            for (IType styp : sups) {
                xw.begin("EXTENDIFACE");
                xw.field("NAME", styp.getFullyQualifiedName());
                xw.field("KEY", styp.getKey());
                xw.end("EXTENDIFACE");
            }
            sups = th.getImplementingClasses(typ);
            for (IType styp : sups) {
                xw.begin("IMPLEMENTOR");
                xw.field("NAME", styp.getFullyQualifiedName());
                xw.field("KEY", styp.getKey());
                xw.end("IMPLEMENTOR");
            }
        } catch (JavaModelException e) {
        }

        xw.end("TYPE");
    }
    xw.end("HIERARCHY");
}

From source file:edu.illinois.compositerefactorings.refactorings.copymembertosubtype.CopyMemberToSubtypeRefactoringProcessor.java

License:Open Source License

/**
 * {@link org.eclipse.jdt.internal.corext.refactoring.structure.PushDownRefactoringProcessor#createChange(IProgressMonitor)}
 *//*from   w ww. j  a  v  a  2  s .co m*/
@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    try {
        final Map<String, String> arguments = new HashMap<String, String>();
        String project = null;
        final IType declaring = getDeclaringType();
        final IJavaProject javaProject = declaring.getJavaProject();
        if (javaProject != null)
            project = javaProject.getElementName();
        int flags = JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING
                | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
        try {
            if (declaring.isLocal() || declaring.isAnonymous())
                flags |= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
        } catch (JavaModelException exception) {
            JavaPlugin.log(exception);
        }
        final String description = fMembersToMove.length == 1
                ? Messages.format(
                        RefactoringCoreMessages.PushDownRefactoring_descriptor_description_short_multi,
                        BasicElementLabels.getJavaElementName(fMembersToMove[0].getElementName()))
                : RefactoringCoreMessages.PushDownRefactoring_descriptor_description_short;
        final String header = fMembersToMove.length == 1 ? Messages.format(
                RefactoringCoreMessages.PushDownRefactoring_descriptor_description_full,
                new String[] {
                        JavaElementLabels.getElementLabel(fMembersToMove[0],
                                JavaElementLabels.ALL_FULLY_QUALIFIED),
                        JavaElementLabels.getElementLabel(declaring, JavaElementLabels.ALL_FULLY_QUALIFIED) })
                : Messages.format(RefactoringCoreMessages.PushDownRefactoring_descriptor_description,
                        new String[] { JavaElementLabels.getElementLabel(declaring,
                                JavaElementLabels.ALL_FULLY_QUALIFIED) });
        final JDTRefactoringDescriptorComment comment = new JDTRefactoringDescriptorComment(project, this,
                header);
        final String[] settings = new String[fMembersToMove.length];
        for (int index = 0; index < settings.length; index++)
            settings[index] = JavaElementLabels.getElementLabel(fMembersToMove[index],
                    JavaElementLabels.ALL_FULLY_QUALIFIED);
        comment.addSetting(JDTRefactoringDescriptorComment.createCompositeSetting(
                RefactoringCoreMessages.PushDownRefactoring_pushed_members_pattern, settings));
        addSuperTypeSettings(comment, true);
        final PushDownDescriptor descriptor = RefactoringSignatureDescriptorFactory
                .createPushDownDescriptor(project, description, comment.asString(), arguments, flags);
        if (fCachedDeclaringType != null)
            arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
                    JavaRefactoringDescriptorUtil.elementToHandle(project, fCachedDeclaringType));
        for (int index = 0; index < fMembersToMove.length; index++) {
            arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + (index + 1),
                    JavaRefactoringDescriptorUtil.elementToHandle(project, fMembersToMove[index]));
            for (int offset = 0; offset < fMemberInfos.length; offset++) {
                if (fMemberInfos[offset].getMember().equals(fMembersToMove[index])) {
                    arguments.put(ATTRIBUTE_PUSH + (index + 1), Boolean.valueOf(true).toString());
                }
            }
        }
        return new DynamicValidationRefactoringChange(descriptor,
                RefactoringCoreMessages.PushDownRefactoring_change_name, fChangeManager.getAllChanges());
    } finally {
        pm.done();
        clearCaches();
    }
}

From source file:edu.illinois.compositerefactorings.steps.CopyMemberToSubtype.java

License:Open Source License

private CopyMemberToSubtypeDescriptor createDescriptor(IType supertype, IMember member, IType subtype) {
    String description = MessageFormat.format(CompositeRefactoringsMessages.CopyMemberToSubstype_description,
            member.getElementName(), subtype.getElementName());
    Map<String, String> arguments = new HashMap<String, String>();
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
            JavaRefactoringDescriptorUtil.elementToHandle(getJavaProject().getElementName(), supertype));
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_ELEMENT + 1,
            JavaRefactoringDescriptorUtil.elementToHandle(getJavaProject().getElementName(), member));
    arguments.put(CopyMemberToSubtypeDescriptor.ATTRIBUTE_SUBTYPE + 1,
            JavaRefactoringDescriptorUtil.elementToHandle(getJavaProject().getElementName(), subtype));

    int flags = JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING
            | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
    try {//from  w w  w. j a va  2  s .c  om
        if (supertype.isLocal() || supertype.isAnonymous())
            flags |= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
    } catch (JavaModelException exception) {
        JavaPlugin.log(exception);
    }
    CopyMemberToSubtypeDescriptor descriptor = new CopyMemberToSubtypeDescriptor(
            getJavaProject().getElementName(), description, null, arguments, flags);
    return descriptor;
}

From source file:edu.illinois.compositerefactorings.steps.CreateNewTopLevelInterface.java

License:Open Source License

/**
 * The computation of {@code flags} is based on
 * {@link ExtractInterfaceProcessor#createChange(IProgressMonitor)}
 *//* w  ww  . java  2s  .  co m*/
@Override
protected Collection<RefactoringDescriptor> getDescriptors(Object input) throws CoreException {
    TypeDeclaration typeDeclaration = (TypeDeclaration) input;
    ITypeBinding typeBinding = typeDeclaration.resolveBinding();
    IType type = (IType) typeBinding.getJavaElement();
    Collection<RefactoringDescriptor> descriptors = new ArrayList<RefactoringDescriptor>();

    String description = MessageFormat.format(
            CompositeRefactoringsMessages.CreateNewTopLevelInterface_description, type.getElementName());
    Map<String, String> arguments = new HashMap<String, String>();
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_INPUT,
            JavaRefactoringDescriptorUtil.elementToHandle(getJavaProject().getElementName(), type));
    arguments.put(JavaRefactoringDescriptorUtil.ATTRIBUTE_NAME, "I" + type.getElementName());
    int flags = JavaRefactoringDescriptor.JAR_MIGRATION | JavaRefactoringDescriptor.JAR_REFACTORING
            | RefactoringDescriptor.STRUCTURAL_CHANGE | RefactoringDescriptor.MULTI_CHANGE;
    try {
        if (type.isLocal() || type.isAnonymous()) {
            flags |= JavaRefactoringDescriptor.JAR_SOURCE_ATTACHMENT;
        }
    } catch (JavaModelException exception) {
        JavaPlugin.log(exception);
    }
    CreateNewTopLevelInterfaceDescriptor descriptor = new CreateNewTopLevelInterfaceDescriptor(
            getJavaProject().getElementName(), description, null, arguments, flags);
    descriptors.add(descriptor);
    return descriptors;
}

From source file:edu.uci.ics.sourcerer.extractor.ast.ClassFileExtractor.java

License:Open Source License

public static boolean isTopLevelOrAnonymous(IClassFile classFile) {
    if (classFile.getType() == null) {
        logger.log(Level.SEVERE, "Null type!" + classFile);
        return false;
    } else {/*from   w  w w  .ja  v a 2  s .c  o m*/
        IType type = classFile.getType();
        try {
            if (type.isMember() || type.isLocal()) {
                return false;
            } else {
                return true;
            }
        } catch (JavaModelException e) {
            logger.log(Level.SEVERE, "Error determining if class is top level", e);
            return true;
        }
    }
    //    return !classFile.getType().getFullyQualifiedName().contains("$");
    //    try {
    //      IType declaring = classFile.getType();
    //      boolean topLevel = true;
    //
    //      while (declaring != null) {
    //        if (declaring.isMember() || declaring.isLocal() || declaring.isAnonymous()) {
    //          topLevel = false;
    //          break;
    //        }
    //        declaring = declaring.getDeclaringType();
    //      }
    //      
    //      if (topLevel) {
    //        // check if there is any $ in the fqn
    //        if (classFile.getType().getFullyQualifiedName().indexOf('$') == -1) { 
    //          return true;
    //        } else {
    //          logger.log(Level.SEVERE, "isTopLevel thinks " + classFile.getType().getFullyQualifiedName() + " is top-level");
    //          return true;
    //        }
    //      }
    //    } catch (JavaModelException e) {
    //      logger.log(Level.SEVERE, "Error in determining toplevel", e);
    //      return false;
    //    }
}

From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.EclipseExtractor.java

License:Open Source License

public boolean extractClassFiles(Collection<IClassFile> classFiles) {
    TaskProgressLogger task = TaskProgressLogger.get();

    task.start("Extracting " + classFiles.size() + " class files", "class files extracted", 500);
    boolean oneWithSource = false;

    Map<String, Collection<IClassFile>> memberMap = new HashMap<>();
    ;//from w  ww .j a  v  a 2 s.co m
    Set<String> sourceFailed = new HashSet<>();

    Collection<IClassFile> parentTypes = new LinkedList<>();
    for (IClassFile classFile : classFiles) {
        IType type = classFile.getType();
        try {
            if (type.isMember() || type.isAnonymous() || type.isLocal()) {
                String key = null;
                IType dec = type.getDeclaringType();
                if (dec == null) {
                    key = classFile.getElementName();
                    int dollar = key.indexOf('$');
                    if (dollar == -1) {
                        if (classFile.getSource() == null) {
                            // Doesn't matter, just make it a parentType
                            parentTypes.add(classFile);
                        } else {
                            logger.log(Level.SEVERE, "Should have a dollar: " + key);
                        }
                    } else {
                        key = key.substring(0, dollar) + ".class";
                    }
                } else {
                    key = dec.getClassFile().getElementName();
                }
                if (key != null) {
                    Collection<IClassFile> members = memberMap.get(key);
                    if (members == null) {
                        members = new LinkedList<>();
                        memberMap.put(key, members);
                    }
                    members.add(classFile);
                }
            } else {
                parentTypes.add(classFile);
            }
        } catch (Exception e) {
            logger.log(Level.SEVERE, classFile.getType().getFullyQualifiedName(), e);
            sourceFailed.add(classFile.getType().getFullyQualifiedName());
            extractClassFile(classFile);
        }
    }

    for (IClassFile classFile : parentTypes) {
        task.progress();
        try {
            IBuffer buffer = classFile.getBuffer();
            if (buffer == null || buffer.getLength() == 0) {
                extractClassFile(classFile);
                sourceFailed.add(classFile.getType().getFullyQualifiedName());
            } else {
                IType type = classFile.getType();
                // Handle Eclipse issue with GSSUtil
                if ("sun.security.jgss.GSSUtil".equals(type.getFullyQualifiedName())) {
                    extractClassFile(classFile);
                    sourceFailed.add(classFile.getType().getFullyQualifiedName());
                    continue;
                }
                // Handle multiple top-level types
                {
                    BinaryType bType = (BinaryType) type;
                    String sourceFile = type.getPackageFragment().getElementName() + "."
                            + bType.getSourceFileName(null);
                    String fqn = classFile.getType().getFullyQualifiedName() + ".java";
                    if (!fqn.equals(sourceFile)) {
                        continue;
                    }
                }
                parser.setStatementsRecovery(true);
                parser.setResolveBindings(true);
                parser.setBindingsRecovery(true);
                parser.setSource(classFile);

                CompilationUnit unit = (CompilationUnit) parser.createAST(null);
                boolean foundProblem = false;
                // start by checking for a "public type" error
                // just skip this unit in if one is found 
                for (IProblem problem : unit.getProblems()) {
                    if (problem.isError() && problem.getID() == IProblem.PublicClassMustMatchFileName) {
                        foundProblem = true;
                    }
                }
                if (foundProblem) {
                    logger.log(Level.WARNING, "Giving up on " + classFile.getElementName());
                    continue;
                }

                boolean trouble = checkForMissingTypes(unit);
                if (trouble) {
                    sourceFailed.add(classFile.getType().getFullyQualifiedName());
                    extractClassFile(classFile);
                } else {
                    try {
                        visitor.setCompilationUnitSource(classFile.getSource());
                        visitor.setAdvisor(
                                NamingAdvisor.create(classFile, memberMap.get(classFile.getElementName())));
                        unit.accept(visitor);
                        oneWithSource = true;
                    } catch (Exception e) {
                        logger.log(Level.SEVERE, "Error in extracting " + classFile.getElementName(), e);
                        //              for (IProblem problem : unit.getProblems()) {
                        //                if (problem.isError()) {
                        //                  logger.log(Level.SEVERE, "Error in source for class file (" + classFile.getElementName() + "): " + problem.getMessage());
                        //                }
                        //              }
                        sourceFailed.add(classFile.getType().getFullyQualifiedName());
                        extractClassFile(classFile);
                    }
                }
            }
        } catch (JavaModelException | ClassCastException | IllegalArgumentException | NullPointerException e) {
            logger.log(Level.SEVERE, classFile.getElementName(), e);
            sourceFailed.add(classFile.getType().getFullyQualifiedName());
            extractClassFile(classFile);
        }
    }

    for (String failed : sourceFailed) {
        Collection<IClassFile> members = memberMap.get(failed);
        if (members != null) {
            for (IClassFile classFile : members) {
                extractClassFile(classFile);
            }
        }
    }
    task.finish();
    return oneWithSource;
}

From source file:fr.ifpen.emptooling.reverse.JavaToEcore.java

License:Open Source License

/**
 * Process (creates {@link EPackage} and {@link EClass}) for all java packages and classes.
 * /*from   www .jav  a2s  .c  o m*/
 * @param package_
 * @return
 * @throws JavaModelException
 */
protected EPackage processPackage(IPackageFragment package_) throws JavaModelException {
    PackageSettings packageParams = params.packageParams.get(package_.getElementName());
    EPackage subPackage = null;
    if (packageParams != null) {
        // create and configure sub-package
        subPackage = packageParams.createEcorePackage();
    } else {
        subPackage = new DefaultPackageSetting(baseURI, baseNSPrefix, package_).createEcorePackage();
    }
    // process java source file from this package
    ICompilationUnit[] compilationUnits = package_.getCompilationUnits();
    List<ICompilationUnit> listOfCUs = Arrays.asList(compilationUnits);
    Collections.sort(listOfCUs, new Comparator<ICompilationUnit>() {
        public int compare(ICompilationUnit c1, ICompilationUnit c2) {
            return c1.getElementName().compareTo(c2.getElementName());
        }
    });
    for (ICompilationUnit compilationUnit : compilationUnits) {
        IType[] allTypes = compilationUnit.getAllTypes();
        for (IType iType : allTypes) {
            // do not process nested classes
            if (/*iType.isMember() ||*/iType.isLocal()) {
                continue;
            }
            EClassifier clazz = preProcessType(iType);
            if (!(clazz instanceof EEnum)) {
                subPackage.getEClassifiers().add(clazz);
            }
            eClassesAdded.put(iType.getFullyQualifiedName(), clazz);
            eTypesAdded.put(iType, clazz);
        }

    }
    return subPackage;
}

From source file:org.codehaus.groovy.eclipse.debug.ui.ToggleBreakpointAdapter.java

License:Open Source License

protected IType getType(ITextSelection selection) {
    IMember member = ActionDelegateHelper.getDefault().getCurrentMember(selection);
    IType type = null;
    if (member instanceof IType) {
        type = (IType) member;/*from w ww  .j ava 2 s . c  om*/
    } else if (member != null) {
        type = member.getDeclaringType();
    }
    // bug 52385: we don't want local and anonymous types from compilation
    // unit,
    // we are getting 'not-always-correct' names for them.
    try {
        while (type != null && !type.isBinary() && type.isLocal()) {
            type = type.getDeclaringType();
        }
    } catch (JavaModelException e) {
        JDIDebugUIPlugin.log(e);
    }
    return type;
}