List of usage examples for org.eclipse.jdt.core IJavaElement PACKAGE_FRAGMENT
int PACKAGE_FRAGMENT
To view the source code for org.eclipse.jdt.core IJavaElement PACKAGE_FRAGMENT.
Click Source Link
From source file:com.codenvy.ide.ext.java.server.internal.core.SourceType.java
License:Open Source License
/** * @see org.eclipse.jdt.core.IType// www. j a v a 2s . com */ public IPackageFragment getPackageFragment() { IJavaElement parentElement = this.parent; while (parentElement != null) { if (parentElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT) { return (IPackageFragment) parentElement; } else { parentElement = parentElement.getParent(); } } Assert.isTrue(false); // should not happen return null; }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.JavaElementFinder.java
License:Open Source License
public void consumeLocalType(char[] uniqueKey) { if (this.element == null) return;// w ww. j a v a2s .com if (this.element instanceof BinaryType) { int lastSlash = CharOperation.lastIndexOf('/', uniqueKey); int end = CharOperation.indexOf(';', uniqueKey, lastSlash + 1); char[] localName = CharOperation.subarray(uniqueKey, lastSlash + 1, end); IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class); } else { int firstDollar = CharOperation.indexOf('$', uniqueKey); int end = CharOperation.indexOf('$', uniqueKey, firstDollar + 1); if (end == -1) end = CharOperation.indexOf(';', uniqueKey, firstDollar + 1); char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar + 1, end); int position = Integer.parseInt(new String(sourceStart)); try { this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position); } catch (JavaModelException e) { this.exception = e; } } }
From source file:com.codenvy.ide.ext.java.server.internal.core.util.Util.java
License:Open Source License
public static final boolean isExcluded(IJavaElement element) { int elementType = element.getElementType(); switch (elementType) { case IJavaElement.JAVA_MODEL: case IJavaElement.JAVA_PROJECT: case IJavaElement.PACKAGE_FRAGMENT_ROOT: return false; case IJavaElement.PACKAGE_FRAGMENT: PackageFragmentRoot root = (PackageFragmentRoot) element .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); File resource = ((PackageFragment) element).resource(); return resource != null && isExcluded(resource, root.fullInclusionPatternChars(), root.fullExclusionPatternChars()); case IJavaElement.COMPILATION_UNIT: root = (PackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); resource = ((CompilationUnit) element).resource(); if (resource == null) return false; if (isExcluded(resource, root.fullInclusionPatternChars(), root.fullExclusionPatternChars())) return true; return isExcluded(element.getParent()); default:/*from w w w. ja v a2 s . c o m*/ IJavaElement cu = element.getAncestor(IJavaElement.COMPILATION_UNIT); return cu != null && isExcluded(cu); } }
From source file:com.codenvy.ide.ext.java.server.JavadocFinder.java
License:Open Source License
private static long getHeaderFlags(IJavaElement element) { switch (element.getElementType()) { case IJavaElement.LOCAL_VARIABLE: return LOCAL_VARIABLE_FLAGS; case IJavaElement.TYPE_PARAMETER: return TYPE_PARAMETER_FLAGS; case IJavaElement.PACKAGE_FRAGMENT: return PACKAGE_FLAGS; default:/* ww w . ja va2 s . c om*/ return LABEL_FLAGS; } }
From source file:com.ebmwebsourcing.petals.common.internal.provisional.ui.jdt.ContainerFilter.java
License:Open Source License
@Override public boolean select(Viewer viewer, Object parent, Object element) { boolean isContainer = element instanceof IContainer; if (!isContainer && element instanceof IJavaElement) { int type = ((IJavaElement) element).getElementType(); isContainer = type == IJavaElement.JAVA_MODEL || type == IJavaElement.JAVA_PROJECT || type == IJavaElement.PACKAGE_FRAGMENT || type == IJavaElement.PACKAGE_FRAGMENT_ROOT; }/*from ww w.ja v a 2 s .co m*/ return (this.fFilterContainers && !isContainer) || (!this.fFilterContainers && isContainer); }
From source file:com.google.appengine.eclipse.core.markers.quickfixes.AppEngineJavaProblemMarkerResolutionGenerator.java
License:Open Source License
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { List<IJavaCompletionProposal> proposals = new ArrayList<IJavaCompletionProposal>(); for (IProblemLocation problem : locations) { AppEngineProblemType problemType = AppEngineProblemType.getProblemType(problem.getProblemId()); if (problemType == null) { continue; }/*from w ww .jav a2 s .c om*/ switch (problemType) { case UNSUPPORTED_JRE_TYPE: proposals.add(new ExcludeFromValidationProposal(context.getCompilationUnit(), 100)); proposals.add(new ExcludeFromValidationProposal( (IPackageFragment) context.getCompilationUnit().getAncestor(IJavaElement.PACKAGE_FRAGMENT), 99)); break; case WRONG_JDBC_URL: IJavaProject javaProject = context.getCompilationUnit().getJavaProject(); proposals.add(new UrlCorrectionProposal(javaProject, problem, 100)); break; } } return proposals.toArray(new IJavaCompletionProposal[0]); }
From source file:com.google.gdt.eclipse.core.reference.ElementChangeListener.java
License:Open Source License
public void elementChanged(ElementChangedEvent event) { final Map<IJavaElement, IJavaElementDelta> changedElements = new HashMap<IJavaElement, IJavaElementDelta>(); JavaModelSearch.visitJavaElementDelta(event.getDelta(), new IJavaElementDeltaVisitor() { public boolean visit(IJavaElementDelta delta) { IJavaElement element = delta.getElement(); /*/*from ww w . ja va 2s . co m*/ * We care about packages being only added or removed because if we * called the change listeners on a change to a package, any change * to any file in that package will cause all ui.xml files that * reference that package (say with xmlns urn imports) to be * revalidated. Some projects end up having hundreds of ui.xml files * referencing a package, and then saving any change in that package * ends up taking tens of seconds. */ int type = element.getElementType(); if (type == IJavaElement.PACKAGE_FRAGMENT && delta.getKind() == IJavaElementDelta.CHANGED) { return true; } Set<IReference> references = referenceManager.getReferencesWithMatchingJavaElement(element, EnumSet.of(ReferenceLocationType.TARGET)); if (references != null && references.size() > 0) { changedElements.put(element, delta); } return true; } }); if (changedElements.size() > 0) { callReferenceChangeListeners(changedElements); } }
From source file:com.google.gdt.eclipse.designer.common.GwtPropertyTester.java
License:Open Source License
/** * Tests property, can throw {@link Exception}. *//*w w w . j ava 2 s. c o m*/ private static boolean testEx(Object receiver, String property) throws Exception { // prepare IResource final IResource resource; if (receiver instanceof IAdaptable) { resource = (IResource) ((IAdaptable) receiver).getAdapter(IResource.class); } else { resource = null; } // prepare IJavaElement final IJavaElement element; if (receiver instanceof IAdaptable) { element = (IJavaElement) ((IAdaptable) receiver).getAdapter(IJavaElement.class); } else { element = null; } // resources tests { if (PROPERTY_IS_GWT_MODULE_ELEMENT.equals(property)) { if (resource != null) { return Utils.getSingleModule(resource) != null; } return false; } if (PROPERTY_IS_RESOURCE.equals(property)) { return resource != null; } } // project tests { if (PROPERTY_IS_GWT_PROJECT_ELEMENT.equals(property)) { // resource selected if (resource != null && resource.exists()) { IProject project = resource.getProject(); IJavaProject javaProject = JavaCore.create(project); return Utils.isGWTProject(javaProject); } // Java element selected if (element != null && element.exists()) { IJavaProject javaProject = (IJavaProject) element.getAncestor(IJavaElement.JAVA_PROJECT); return Utils.isGWTProject(javaProject); } // bad selection return false; } } // Java tests { // prepare java element if (element == null || !element.exists()) { return false; } // do tests if (PROPERTY_IS_CLIENT_PACKAGE.equals(property)) { IPackageFragment packageFragment = (IPackageFragment) element .getAncestor(IJavaElement.PACKAGE_FRAGMENT); if (packageFragment != null) { return Utils.isModuleSourcePackage(packageFragment); } return false; } if (PROPERTY_IS_ENTRY_POINT.equals(property)) { return Utils.isEntryPoint(element); } if (PROPERTY_IS_REMOTE_SERVICE.equals(property)) { return Utils.isRemoteService(element); } if (PROPERTY_IS_REMOTE_SERVICE_IMPL.equals(property)) { return Utils.isRemoteServiceImpl(element); } } // unknown property throw new IllegalArgumentException( MessageFormat.format("Illegal property '{0}' for '{1}'.", property, receiver)); }
From source file:com.google.gdt.eclipse.designer.gxt.actions.GxtPropertyTester.java
License:Open Source License
/** * Tests property, can throw {@link Exception}. *///from w ww . j a v a 2 s. c o m private static boolean testEx(Object receiver, String property) throws Exception { // prepare IJavaElement final IJavaElement element; if (receiver instanceof IAdaptable) { element = (IJavaElement) ((IAdaptable) receiver).getAdapter(IJavaElement.class); } else { element = null; } // Java tests { // prepare java element if (element == null || !element.exists()) { return false; } // do tests if (PROPERTY_IS_CONFIGURED.equals(property)) { IJavaProject javaProject = element.getJavaProject(); boolean hasJar = javaProject.findType("com.extjs.gxt.ui.client.widget.Component") != null; if (hasJar) { IJavaElement pkg = element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); if (pkg != null) { IResource resource = pkg.getUnderlyingResource(); ModuleDescription module = Utils.getSingleModule(resource); return module != null && Utils.inheritsModule(module, "com.extjs.gxt.ui.GXT"); } } return false; } } // unknown property throw new IllegalArgumentException( MessageFormat.format("Illegal property '{0}' for '{1}'.", property, receiver)); }
From source file:com.google.gdt.eclipse.designer.smart.actions.SmartGwtPropertyTester.java
License:Open Source License
/** * Tests property, can throw {@link Exception}. *//*from w w w .j av a 2s . c o m*/ private static boolean testEx(Object receiver, String property) throws Exception { // prepare IJavaElement final IJavaElement element; if (receiver instanceof IAdaptable) { element = (IJavaElement) ((IAdaptable) receiver).getAdapter(IJavaElement.class); } else { element = null; } // Java tests { // prepare java element if (element == null || !element.exists()) { return false; } // do tests if (PROPERTY_IS_CONFIGURED.equals(property)) { IJavaProject javaProject = element.getJavaProject(); boolean hasJar = javaProject.findType("com.smartgwt.client.widgets.BaseWidget") != null; if (hasJar) { IJavaElement pkg = element.getAncestor(IJavaElement.PACKAGE_FRAGMENT); if (pkg != null) { IResource resource = pkg.getUnderlyingResource(); ModuleDescription module = Utils.getSingleModule(resource); return module != null && Utils.inheritsModule(module, "com.smartgwt.SmartGwt"); } } return false; } } // unknown property throw new IllegalArgumentException( MessageFormat.format("Illegal property '{0}' for '{1}'.", property, receiver)); }