List of usage examples for org.eclipse.jdt.core IJavaModelStatusConstants INVALID_ELEMENT_TYPES
int INVALID_ELEMENT_TYPES
To view the source code for org.eclipse.jdt.core IJavaModelStatusConstants INVALID_ELEMENT_TYPES.
Click Source Link
From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFile.java
License:Open Source License
public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else {/*from w w w . j a v a 2 s.c om*/ switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException((IJavaModelStatus) status); } } }
From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFile.java
License:Open Source License
private IStatus validateClassFile() { IPackageFragmentRoot root = getPackageFragmentRoot(); try {//from www .j a v a 2 s .c o m if (root.getKind() != IPackageFragmentRoot.K_BINARY) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } IJavaProject project = getJavaProject(); if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(getElementName())) { return Status.OK_STATUS; } return Status.CANCEL_STATUS; // return JavaConventions.validateClassFileName(getElementName(), project.getOption(JavaCore.COMPILER_SOURCE, true), // project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); }
From source file:com.codenvy.ide.ext.java.server.internal.core.CompilationUnit.java
License:Open Source License
protected IStatus validateCompilationUnit(File resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try {/*w w w.j a v a2 s . c om*/ if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot) root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot) root).fullExclusionPatternChars(); if (Util.isExcluded(new Path(resource.getPath()), inclusionPatterns, exclusionPatterns, false)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.exists()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(), project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); }
From source file:com.codenvy.ide.ext.java.server.internal.core.Initializer.java
License:Open Source License
/** * @see org.eclipse.jdt.core.ISourceManipulation *//*from ww w . j a v a2 s .co m*/ public void rename(String newName, boolean force, IProgressMonitor monitor) throws JavaModelException { throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this)); }
From source file:com.github.parzonka.ccms.engine.SortElementsOperation.java
License:Open Source License
/** * Calculates the required text edits to sort the <code>unit</code> * * @param group// www .j a va 2 s.c o m * @return the edit or null if no sorting is required */ public TextEdit calculateEdit(org.eclipse.jdt.core.dom.CompilationUnit unit, TextEditGroup group) throws JavaModelException { if (this.elementsToProcess.length != 1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS)); if (!(this.elementsToProcess[0] instanceof ICompilationUnit)) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0])); try { beginTask(Messages.operation_sortelements, getMainAmountOfWork()); final ICompilationUnit cu = (ICompilationUnit) this.elementsToProcess[0]; final String content = cu.getBuffer().getContents(); final ASTRewrite rewrite = sortCompilationUnit(unit, group); if (rewrite == null) { return null; } final Document document = new Document(content); return rewrite.rewriteAST(document, cu.getJavaProject().getOptions(true)); } finally { done(); } }
From source file:com.github.parzonka.ccms.engine.SortElementsOperation.java
License:Open Source License
/** * Possible failures://from w w w . j a v a 2s . c o m * <ul> * <li>NO_ELEMENTS_TO_PROCESS - the compilation unit supplied to the * operation is <code>null</code></li>. * <li>INVALID_ELEMENT_TYPES - the supplied elements are not an instance of * IWorkingCopy</li>. * </ul> * * @return IJavaModelStatus */ @Override public IJavaModelStatus verify() { if (this.elementsToProcess.length != 1) { return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS); } if (this.elementsToProcess[0] == null) { return new JavaModelStatus(IJavaModelStatusConstants.NO_ELEMENTS_TO_PROCESS); } if (!(this.elementsToProcess[0] instanceof ICompilationUnit) || !((ICompilationUnit) this.elementsToProcess[0]).isWorkingCopy()) { return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this.elementsToProcess[0]); } return JavaModelStatus.VERIFIED_OK; }
From source file:org.codehaus.jdt.groovy.model.GroovyClassFileWorkingCopy.java
License:Open Source License
public void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException { throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, this)); }
From source file:org.eclipse.jdt.internal.core.CompilationUnit.java
License:Open Source License
protected IStatus validateCompilationUnit(IResource resource) { IPackageFragmentRoot root = getPackageFragmentRoot(); // root never null as validation is not done for working copies try {/* w w w . j av a 2 s . c o m*/ if (root.getKind() != IPackageFragmentRoot.K_SOURCE) return new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, root); } catch (JavaModelException e) { return e.getJavaModelStatus(); } if (resource != null) { char[][] inclusionPatterns = ((PackageFragmentRoot) root).fullInclusionPatternChars(); char[][] exclusionPatterns = ((PackageFragmentRoot) root).fullExclusionPatternChars(); if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH, this); if (!resource.isAccessible()) return new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this); } IJavaProject project = getJavaProject(); return JavaConventions.validateCompilationUnitName(getElementName(), project.getOption(JavaCore.COMPILER_SOURCE, true), project.getOption(JavaCore.COMPILER_COMPLIANCE, true)); }
From source file:org.eclipse.jdt.internal.core.CopyResourceElementsOperation.java
License:Open Source License
/** * @see MultiOperation/*from www . ja va 2 s . c o m*/ * This method delegates to <code>processCompilationUnitResource</code> or * <code>processPackageFragmentResource</code>, depending on the type of * <code>element</code>. */ protected void processElement(IJavaElement element) throws JavaModelException { IJavaElement dest = getDestinationParent(element); switch (element.getElementType()) { case IJavaElement.COMPILATION_UNIT: processCompilationUnitResource((ICompilationUnit) element, (PackageFragment) dest); this.createdElements.add(((IPackageFragment) dest).getCompilationUnit(element.getElementName())); break; case IJavaElement.PACKAGE_FRAGMENT: processPackageFragmentResource((PackageFragment) element, (PackageFragmentRoot) dest, getNewNameFor(element)); break; default: throw new JavaModelException( new JavaModelStatus(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element)); } }
From source file:org.eclipse.jdt.internal.core.CopyResourceElementsOperation.java
License:Open Source License
/** * @see MultiOperation//w w w . j a va 2 s. com */ protected void verify(IJavaElement element) throws JavaModelException { if (element == null || !element.exists()) error(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, element); if (element.isReadOnly() && (isRename() || isMove())) error(IJavaModelStatusConstants.READ_ONLY, element); IResource resource = ((JavaElement) element).resource(); if (resource instanceof IFolder) { if (resource.isLinked()) { error(IJavaModelStatusConstants.INVALID_RESOURCE, element); } } int elementType = element.getElementType(); if (elementType == IJavaElement.COMPILATION_UNIT) { org.eclipse.jdt.internal.core.CompilationUnit compilationUnit = (org.eclipse.jdt.internal.core.CompilationUnit) element; if (isMove() && compilationUnit.isWorkingCopy() && !compilationUnit.isPrimary()) error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element); } else if (elementType != IJavaElement.PACKAGE_FRAGMENT) { error(IJavaModelStatusConstants.INVALID_ELEMENT_TYPES, element); } JavaElement dest = (JavaElement) getDestinationParent(element); verifyDestination(element, dest); if (this.renamings != null) { verifyRenaming(element); } }