Example usage for org.eclipse.jdt.core JavaCore PLUGIN_ID

List of usage examples for org.eclipse.jdt.core JavaCore PLUGIN_ID

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore PLUGIN_ID.

Prototype

String PLUGIN_ID

To view the source code for org.eclipse.jdt.core JavaCore PLUGIN_ID.

Click Source Link

Document

The plug-in identifier of the Java core support (value "org.eclipse.jdt.core").

Usage

From source file:com.codenvy.ide.ext.java.server.dom.JavaConventions.java

License:Open Source License

/**
 * Validate the given compilation unit name for the given source and compliance levels.
 * <p>//from  w w  w. j  a  v  a 2s . c om
 * A compilation unit name must obey the following rules:
 * <ul>
 * <li> it must not be null
 * <li> it must be suffixed by a dot ('.') followed by one of the
 *       {@link org.eclipse.jdt.core.JavaCore#getJavaLikeExtensions() Java-like extensions}
 * <li> its prefix must be a valid identifier
 * <li> it must not contain any characters or substrings that are not valid
 *         on the file system on which workspace root is located.
 * </ul>
 * </p>
 * @param name the name of a compilation unit
 * @param sourceLevel the source level
 * @param complianceLevel the compliance level
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a compilation unit name, otherwise a status
 *      object indicating what is wrong with the name
 * @since 3.3
 */
public static IStatus validateCompilationUnitName(String name, String sourceLevel, String complianceLevel) {
    if (name == null) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_unit_nullName, null);
    }
    if (!Util.isJavaLikeFileName(name)) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_unit_notJavaName, null);
    }
    String identifier;
    int index;
    index = name.lastIndexOf('.');
    if (index == -1) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_unit_notJavaName, null);
    }
    identifier = name.substring(0, index);
    // JSR-175 metadata strongly recommends "package-info.java" as the
    // file in which to store package annotations and
    // the package-level spec (replaces package.html)
    if (!identifier.equals(PACKAGE_INFO)) {
        IStatus status = validateIdentifier(identifier, sourceLevel, complianceLevel);
        if (!status.isOK()) {
            return status;
        }
    }
    //        IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
    //        if (!status.isOK()) {
    //            return status;
    //        }
    return JavaModelStatus.VERIFIED_OK;
}

From source file:com.codenvy.ide.ext.java.server.dom.JavaConventions.java

License:Open Source License

/**
 * Validate the given .class file name for the given source and compliance levels.
 * <p>/*from   w w w .  j a  v a 2  s . co m*/
 * A .class file name must obey the following rules:
 * <ul>
 * <li> it must not be null
 * <li> it must include the <code>".class"</code> suffix
 * <li> its prefix must be a valid identifier
 * <li> it must not contain any characters or substrings that are not valid
 *         on the file system on which workspace root is located.
 * </ul>
 * </p>
 * @param name the name of a .class file
 * @param sourceLevel the source level
 * @param complianceLevel the compliance level
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given name is valid as a .class file name, otherwise a status
 *      object indicating what is wrong with the name
 * @since 3.3
 */
public static IStatus validateClassFileName(String name, String sourceLevel, String complianceLevel) {
    if (name == null) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_nullName, null);
    }
    if (!org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName,
                null);
    }
    String identifier;
    int index;
    index = name.lastIndexOf('.');
    if (index == -1) {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Messages.convention_classFile_notClassFileName,
                null);
    }
    identifier = name.substring(0, index);
    // JSR-175 metadata strongly recommends "package-info.java" as the
    // file in which to store package annotations and
    // the package-level spec (replaces package.html)
    if (!identifier.equals(PACKAGE_INFO)) {
        IStatus status = validateIdentifier(identifier, sourceLevel, complianceLevel);
        if (!status.isOK()) {
            return status;
        }
    }
    //        IStatus status = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE);
    //        if (!status.isOK()) {
    //            return status;
    //        }
    return JavaModelStatus.VERIFIED_OK;
}

From source file:com.codenvy.ide.ext.java.server.dom.JavaConventions.java

License:Open Source License

/**
 * Validate the given Java identifier for the given source and compliance levels
 * The identifier must not have the same spelling as a Java keyword,
 * boolean literal (<code>"true"</code>, <code>"false"</code>), or null literal (<code>"null"</code>).
 * See section 3.8 of the <em>Java Language Specification, Second Edition</em> (JLS2).
 * A valid identifier can act as a simple type name, method name or field name.
 *
 * @param id the Java identifier/*from   w  w  w .  j av  a  2  s.c  o  m*/
 * @param sourceLevel the source level
 * @param complianceLevel the compliance level
 * @return a status object with code <code>IStatus.OK</code> if
 *      the given identifier is a valid Java identifier, otherwise a status
 *      object indicating what is wrong with the identifier
 * @since 3.3
 */
public static IStatus validateIdentifier(String id, String sourceLevel, String complianceLevel) {
    if (scannedIdentifier(id, sourceLevel, complianceLevel) != null) {
        return JavaModelStatus.VERIFIED_OK;
    } else {
        return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1,
                Messages.bind(Messages.convention_illegalIdentifier, id), null);
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.DeltaProcessingState.java

License:Open Source License

public void saveExternalLibTimeStamps() throws CoreException {
    if (this.externalTimeStamps == null)
        return;// w  ww . jav  a  2 s  . c  o  m

    // cleanup to avoid any leak ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=244849 )
    HashSet toRemove = new HashSet();
    if (this.roots != null) {
        Enumeration keys = this.externalTimeStamps.keys();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            if (this.roots.get(key) == null) {
                toRemove.add(key);
            }
        }
    }

    File timestamps = getTimeStampsFile();
    DataOutputStream out = null;
    try {
        out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(timestamps)));
        out.writeInt(this.externalTimeStamps.size() - toRemove.size());
        Iterator entries = this.externalTimeStamps.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry entry = (Map.Entry) entries.next();
            IPath key = (IPath) entry.getKey();
            if (!toRemove.contains(key)) {
                out.writeUTF(key.toPortableString());
                Long timestamp = (Long) entry.getValue();
                out.writeLong(timestamp.longValue());
            }
        }
    } catch (IOException e) {
        IStatus status = new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, IStatus.ERROR,
                "Problems while saving timestamps", e); //$NON-NLS-1$
        throw new CoreException(status);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                // nothing we can do: ignore
            }
        }
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java

License:Open Source License

/**
 * Constructs an Java model status with no corresponding elements.
 *///from   ww  w . j a va 2s. co m
public JavaModelStatus() {
    // no code for an multi-status
    super(ERROR, JavaCore.PLUGIN_ID, 0, "JavaModelStatus", null); //$NON-NLS-1$
}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java

License:Open Source License

/**
 * Constructs an Java model status with no corresponding elements.
 *//*from   ww w .j a  v a 2 s .  c om*/
public JavaModelStatus(int code) {
    super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
    this.elements = JavaElement.NO_ELEMENTS;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java

License:Open Source License

/**
 * Constructs an Java model status with the given corresponding
 * elements./*from   www. j ava  2s .  c om*/
 */
public JavaModelStatus(int code, IJavaElement[] elements) {
    super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
    this.elements = elements;
    this.path = null;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java

License:Open Source License

/**
 * Constructs an Java model status with no corresponding elements.
 *///from   w  w  w  .  j  a v  a  2  s.  com
public JavaModelStatus(int severity, int code, String string) {
    super(severity, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
    this.elements = JavaElement.NO_ELEMENTS;
    this.path = null;
    this.string = string;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java

License:Open Source License

/**
 * Constructs an Java model status with no corresponding elements.
 */// w w w . j a v a  2s .  co m
public JavaModelStatus(int code, Throwable throwable) {
    super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", throwable); //$NON-NLS-1$
    this.elements = JavaElement.NO_ELEMENTS;
}

From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java

License:Open Source License

/**
 * Constructs an Java model status with no corresponding elements.
 *//*w ww .  jav  a  2  s . co  m*/
public JavaModelStatus(int code, IPath path) {
    super(ERROR, JavaCore.PLUGIN_ID, code, "JavaModelStatus", null); //$NON-NLS-1$
    this.elements = JavaElement.NO_ELEMENTS;
    this.path = path;
}