Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaElement


                    content.append(comment);
                    content.append(lineDelimiter);
                }

                content.append(constructTypeStub(parentCU, imports, lineDelimiter));
                IJavaElement sibling = null;
                if (enclosingType.isEnum()) {
                    IField[] fields = enclosingType.getFields();
                    if (fields.length > 0) {
                        for (int i = 0, max = fields.length; i < max; i++) {
                            if (!fields[i].isEnumConstant()) {
View Full Code Here


            List<String> addedNames = new ArrayList<String>();
            if (data instanceof IResource[]) {
                IResource[] resources = (IResource[]) data;
                for (IResource resource : resources) {
                    IJavaElement javaElement = JavaCore.create(resource);
                    if (javaElement != null) {
                        try {
                            if (javaElement instanceof IType) {
                                IType type = (IType) javaElement;
                                if (type.isClass() && Flags.isPublic(type.getFlags())) {
View Full Code Here

        Dialog.applyDialogFont(composite);
        PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IJavaHelpContextIds.NEW_CLASS_WIZARD_PAGE);
    }

    public void init(IStructuredSelection selection) {
        IJavaElement jelem = getInitialJavaElement(selection);
        initContainerPage(jelem);
        initTypePage(jelem);
        doStatusUpdate();

        boolean createConstructors = false;
View Full Code Here

        // Remove non-source and excludes
        Set<String> testCaseNames = new LinkedHashSet<String>();
        for (Iterator<IJavaElement> iter = testCaseList.iterator(); iter.hasNext();) {
            boolean omit = false;
            IJavaElement element = iter.next();
            try {

                IType type = (IType) element.getAncestor(IJavaElement.TYPE);
                if (Flags.isAbstract(type.getFlags())) {
                    omit = true;
                }

                if (!includeNonSource) {
                    IPackageFragment pkgFragment = (IPackageFragment) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
                    if (pkgFragment.getCompilationUnits().length == 0) {
                        omit = true;
                    }
                }
View Full Code Here

            final List<String> typesFound = new ArrayList<String>();

            SearchRequestor requestor = new SearchRequestor() {
                @Override
                public void acceptSearchMatch(SearchMatch match) throws CoreException {
                    IJavaElement enclosingElement = (IJavaElement) match.getElement();
                    if (!testCaseList.contains(enclosingElement)) {
                        typesFound.add(getClassName(enclosingElement));
                    }
                    testCaseList.add(enclosingElement);
                }
View Full Code Here

    /**
     * @param match
     * @return the enclosing {@link ICompilationUnit} of the given match, or null iff none
     */
    public static ICompilationUnit getCompilationUnit(SearchMatch match) {
        IJavaElement enclosingElement = getEnclosingJavaElement(match);
        if (enclosingElement != null) {
            if (enclosingElement instanceof ICompilationUnit)
                return (ICompilationUnit) enclosingElement;
            ICompilationUnit cu = (ICompilationUnit) enclosingElement.getAncestor(IJavaElement.COMPILATION_UNIT);
            if (cu != null)
                return cu;
        }

        IJavaElement jElement = JavaCore.create(match.getResource());
        if (jElement != null && jElement.exists() && jElement.getElementType() == IJavaElement.COMPILATION_UNIT)
            return (ICompilationUnit) jElement;
        return null;
    }
View Full Code Here

    public String[] getPackages(boolean includeNonSource, IPackageFilter filter) throws PackageListException {
        final List<IJavaElement> packageList = new LinkedList<IJavaElement>();
        final SearchRequestor requestor = new SearchRequestor() {
            @Override
            public void acceptSearchMatch(SearchMatch match) throws CoreException {
                IJavaElement enclosingElement = (IJavaElement) match.getElement();
                String name = enclosingElement.getElementName();
                if (name.length() > 0) { // Do not include default pkg
                    packageList.add(enclosingElement);
                }
            }
        };
        final SearchPattern pattern = SearchPattern.createPattern("*", IJavaSearchConstants.PACKAGE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE);

        IRunnableWithProgress operation = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, monitor);
                } catch (CoreException e) {
                    throw new InvocationTargetException(e);
                }
            }
        };

        try {
            runContext.run(true, true, operation);
        } catch (InvocationTargetException e) {
            throw new PackageListException(e.getCause());
        } catch (InterruptedException e) {
            throw new PackageListException("Operation interrupted");
        }

        // Remove non-source and excludes
        Set<String> packageNames = new LinkedHashSet<String>();
        for (Iterator<IJavaElement> iter = packageList.iterator(); iter.hasNext();) {
            boolean omit = false;
            IJavaElement element = iter.next();
            if (!includeNonSource) {
                IPackageFragment pkgFragment = (IPackageFragment) element;
                try {
                    if (pkgFragment.getCompilationUnits().length == 0) {
                        omit = true;
                    }
                } catch (JavaModelException e) {
                    throw new PackageListException(e);
                }
            }

            if (filter != null && !filter.select(element.getElementName())) {
                omit = true;
            }
            if (!omit) {
                packageNames.add(element.getElementName());
            }
        }

        return packageNames.toArray(new String[packageNames.size()]);
    }
View Full Code Here

    return null;
  }

  private Type findType(ITypeBinding binding) {
    if (binding == null) return null;
    IJavaElement javaElement = binding.getJavaElement();
    if (javaElement == null) return null;
    return model.get(javaElement.getHandleIdentifier());
  }
View Full Code Here

    }
   
    public void selectionChanged(MapSelection mapSelection) {
        final ArrayList<IJavaElement> selection = new ArrayList<IJavaElement>();
        for (String each : mapSelection) {
            IJavaElement javaElement = Resources.asJavaElement(each);
            selection.add(javaElement);
        }
        StructuredSelection structuredSelection = new StructuredSelection(selection);
        MapSelectionProvider selectionProvider = CodemapCore.getPlugin().getController().getSelectionProvider();
        selectionProvider.setSelection(structuredSelection);
View Full Code Here

   */
  private void selectionChanged(IStructuredSelection selection) throws CoreException {
    IJavaProject javaProject = null;
    Collection<ICompilationUnit> units = new HashSet<ICompilationUnit>();
    for (Object each: selection.toList()) {
      IJavaElement javaElement = Adaptables.adapt(each, IJavaElement.class);
      if (javaElement == null) continue;
      // we can't handle binaries as their project usually contains no sources and is not
      // visible in the navigation
      if (javaElement instanceof IMember){
          IMember member = (IMember) javaElement;
          if (member.isBinary()) return;
      }
     
      if (javaProject == null) {
        javaProject = javaElement.getJavaProject();
      }
      if (!javaProject.equals(javaElement.getJavaProject()) && javaElement.getJavaProject() != null) {
        multipleProjectsSelected();
        return;
      }
      if (javaElement instanceof ICompilationUnit) {
        units.add((ICompilationUnit) javaElement);
      }
      if (javaElement instanceof IPackageFragment) {
        ICompilationUnit[] children = ((IPackageFragment) javaElement).getCompilationUnits();
        units.addAll(Arrays.asList(children));
      }
      if (javaElement instanceof IMember) {
        javaElement = javaElement.getAncestor(IJavaElement.COMPILATION_UNIT);
        if (javaElement != null) {
          units.add((ICompilationUnit) javaElement);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IJavaElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.