List of usage examples for org.eclipse.jdt.core IPackageFragmentRoot getRawClasspathEntry
IClasspathEntry getRawClasspathEntry() throws JavaModelException;
From source file:org.apache.felix.sigil.eclipse.internal.model.project.SigilProject.java
License:Apache License
public boolean isInBundleClasspath(IPackageFragment root) throws JavaModelException { if (getBundle().getClasspathEntrys().isEmpty()) { for (String p : getBundle().getPackages()) { SigilCore.log("Checking " + p + "->" + root.getElementName()); Matcher m = GlobCompiler.compile(p).matcher(root.getElementName()); if (m.matches()) { return true; }/*from w w w. ja va 2s.c om*/ } return false; } else { IPackageFragmentRoot parent = (IPackageFragmentRoot) root.getParent(); String enc = getJavaModel().encodeClasspathEntry(parent.getRawClasspathEntry()); return getBundle().getClasspathEntrys().contains(enc.trim()); } }
From source file:org.apache.felix.sigil.eclipse.model.util.JavaHelper.java
License:Apache License
private static void findIndirectReferences(Set<String> indirect, String pckg, IParent parent, IJavaProject p) throws JavaModelException { for (IJavaElement e : parent.getChildren()) { boolean skip = false; switch (e.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT_ROOT: IPackageFragmentRoot rt = (IPackageFragmentRoot) e; IClasspathEntry ce = rt.getRawClasspathEntry(); IPath path = ce.getPath();/*w w w.jav a2 s . c om*/ skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals(path.toString()); break; case IJavaElement.CLASS_FILE: IClassFile cf = (IClassFile) e; if (cf.getElementName().startsWith(pckg)) { findIndirectReferences(indirect, findPackage(cf.getType().getSuperclassName()), p, p); } break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu = (ICompilationUnit) e; break; } if (!skip && e instanceof IParent) { IParent newParent = (IParent) e; findIndirectReferences(indirect, pckg, newParent, p); } } }
From source file:org.apache.felix.sigil.eclipse.model.util.JavaHelper.java
License:Apache License
private static boolean isInClassPath(ISigilProjectModel project, IPackageFragmentRoot rt) throws JavaModelException { String path = encode(project, rt.getRawClasspathEntry()); return project.getBundle().getClasspathEntrys().contains(path); }
From source file:org.cloudfoundry.ide.eclipse.server.standalone.internal.application.JavaPackageFragmentRootHandler.java
License:Open Source License
/** * /*w w w .ja va 2 s. co m*/ * Determines if the given package fragment root corresponds to the class * path entry path. * <p/> * Note that different package fragment roots may point to the same class * path entry. * <p/> * Example: * <p/> * A Java project may have the following package fragment roots: * <p/> * - src/main/java * <p/> * - src/main/resources * <p/> * Both may be using the same output folder: * <p/> * target/classes. * <p/> * In this case, the output folder will have a class path entry - * target/classes - and it will be the same for both roots, and this method * will return true for both roots if passed the entry for target/classes * * @param root * to check if it corresponds to the given class path entry path * @param entry * @return true if root is at the given entry */ private static boolean isRootAtEntry(IPackageFragmentRoot root, IPath entry) { try { IClasspathEntry cpe = root.getRawClasspathEntry(); if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputLocation = cpe.getOutputLocation(); if (outputLocation == null) { outputLocation = root.getJavaProject().getOutputLocation(); } IPath location = ResourcesPlugin.getWorkspace().getRoot().findMember(outputLocation).getLocation(); if (entry.equals(location)) { return true; } } } catch (JavaModelException e) { CloudFoundryPlugin.logError(e); } IResource resource = root.getResource(); if (resource != null && entry.equals(resource.getLocation())) { return true; } IPath path = root.getPath(); if (path != null && entry.equals(path)) { return true; } return false; }
From source file:org.eclim.plugin.jdt.command.src.NewCommand.java
License:Open Source License
private String getPath(IPackageFragmentRoot root) throws Exception { return root.getRawClasspathEntry().getPath().toString(); }
From source file:org.eclipse.ajdt.internal.buildpath.AddToAspectpathAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {/*from w w w. j av a2 s. com*/ if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); jarFile = null; fileName = root.getElementName(); enable = !AspectJCorePreferences.isOnAspectpath(cpEntry); } else { jarFile = getJARFile(selection); if (jarFile != null) { cpEntry = null; project = jarFile.getProject(); enable = (!AspectJCorePreferences.isOnAspectpath(project, jarFile.getFullPath().toPortableString()) && !checkIfAddingOutjar(project)); fileName = jarFile.getName(); } } } catch (JavaModelException e) { } action.setEnabled(enable); } }
From source file:org.eclipse.ajdt.internal.buildpath.AddToInpathAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {/*from w w w.j a v a 2s .c om*/ if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); jarFile = null; fileName = root.getElementName(); enable = !AspectJCorePreferences.isOnInpath(cpEntry); } else { jarFile = getJARFile(selection); if (jarFile != null) { cpEntry = null; project = jarFile.getProject(); enable = (!AspectJCorePreferences.isOnInpath(project, jarFile.getFullPath().toPortableString()) && !checkIfAddingOutjar(project)); fileName = jarFile.getName(); } } } catch (JavaModelException e) { } action.setEnabled(enable); } }
From source file:org.eclipse.ajdt.internal.buildpath.RemoveFromAspectpathAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {// w w w . ja va2 s . com if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); enable = AspectJCorePreferences.isOnAspectpath(cpEntry); } } catch (JavaModelException e) { } action.setEnabled(enable); } }
From source file:org.eclipse.ajdt.internal.buildpath.RemoveFromInpathAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {//from w ww .j a v a 2s . c o m if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); enable = AspectJCorePreferences.isOnInpath(cpEntry); } } catch (JavaModelException e) { } action.setEnabled(enable); } }
From source file:org.eclipse.ajdt.internal.buildpath.UpdateAspectpathRestriction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; Object element = selection.getFirstElement(); try {/* ww w .j ava 2 s . c o m*/ if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root = (IPackageFragmentRoot) element; project = root.getJavaProject().getProject(); cpEntry = root.getRawClasspathEntry(); if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { fileName = root.getElementName(); enable = AspectJCorePreferences.isOnAspectpath(cpEntry); } else { fileName = null; cpEntry = null; project = null; enable = false; } } else { enable = false; } } catch (JavaModelException e) { } action.setEnabled(enable); } }