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

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

Introduction

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

Prototype

String VERSION_1_5

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

Click Source Link

Document

Configurable option value: .

Usage

From source file:at.bestsolution.javafx.ide.jdt.internal.jdt.JavaModelUtil.java

License:Open Source License

public static boolean is50OrHigher(String compliance) {
    return !isVersionLessThan(compliance, JavaCore.VERSION_1_5);
}

From source file:boa.datagen.scm.AbstractCommit.java

License:Apache License

private Builder processChangeFile(String path, boolean parse, Writer astWriter, String revKey,
        String keyDelim) {//from w  ww .  j  a va2s .c om
    final ChangedFile.Builder fb = ChangedFile.newBuilder();
    fb.setName(path);
    fb.setKind(FileKind.OTHER);

    final String lowerPath = path.toLowerCase();
    if (lowerPath.endsWith(".txt"))
        fb.setKind(FileKind.TEXT);
    else if (lowerPath.endsWith(".xml"))
        fb.setKind(FileKind.XML);
    else if (lowerPath.endsWith(".jar") || lowerPath.endsWith(".class"))
        fb.setKind(FileKind.BINARY);
    else if (lowerPath.endsWith(".java") && parse) {
        final String content = getFileContents(path);

        fb.setKind(FileKind.SOURCE_JAVA_JLS2);
        if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_4, AST.JLS2, false, astWriter,
                revKey + keyDelim + path)) {
            if (debug)
                System.err.println("Found JLS2 parse error in: revision " + id + ": file " + path);

            fb.setKind(FileKind.SOURCE_JAVA_JLS3);
            if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_5, AST.JLS3, false, astWriter,
                    revKey + keyDelim + path)) {
                if (debug)
                    System.err.println("Found JLS3 parse error in: revision " + id + ": file " + path);

                fb.setKind(FileKind.SOURCE_JAVA_JLS4);
                if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_7, AST.JLS4, false, astWriter,
                        revKey + keyDelim + path)) {
                    if (debug)
                        System.err.println("Found JLS4 parse error in: revision " + id + ": file " + path);

                    //fb.setContent(content);
                    fb.setKind(FileKind.SOURCE_JAVA_ERROR);
                    try {
                        astWriter.append(new Text(revKey + keyDelim + fb.getName()),
                                new BytesWritable(ASTRoot.newBuilder().build().toByteArray()));
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else if (debug)
                    System.err.println("Accepted JLS4: revision " + id + ": file " + path);
            } else if (debug)
                System.err.println("Accepted JLS3: revision " + id + ": file " + path);
        } else if (debug)
            System.err.println("Accepted JLS2: revision " + id + ": file " + path);
    }
    fb.setKey(revKey);

    return fb;
}

From source file:boa.datagen.scm.AbstractCommit.java

License:Apache License

protected ChangedFile.Builder processChangeFile(final String path, final boolean attemptParse) {
    final ChangedFile.Builder fb = ChangedFile.newBuilder();
    fb.setName(path);/*from   w  ww .  ja v a2 s .com*/
    fb.setKind(FileKind.OTHER);

    final String lowerPath = path.toLowerCase();
    if (lowerPath.endsWith(".txt"))
        fb.setKind(FileKind.TEXT);
    else if (lowerPath.endsWith(".xml"))
        fb.setKind(FileKind.XML);
    else if (lowerPath.endsWith(".jar") || lowerPath.endsWith(".class"))
        fb.setKind(FileKind.BINARY);
    else if (lowerPath.endsWith(".java") && attemptParse) {
        final String content = getFileContents(path);

        fb.setKind(FileKind.SOURCE_JAVA_JLS2);
        if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_4, AST.JLS2, false, null, null)) {
            if (debug)
                System.err.println("Found JLS2 parse error in: revision " + id + ": file " + path);

            fb.setKind(FileKind.SOURCE_JAVA_JLS3);
            if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_5, AST.JLS3, false, null, null)) {
                if (debug)
                    System.err.println("Found JLS3 parse error in: revision " + id + ": file " + path);

                fb.setKind(FileKind.SOURCE_JAVA_JLS4);
                if (!parseJavaFile(path, fb, content, JavaCore.VERSION_1_7, AST.JLS4, false, null, null)) {
                    if (debug)
                        System.err.println("Found JLS4 parse error in: revision " + id + ": file " + path);

                    //fb.setContent(content);
                    fb.setKind(FileKind.SOURCE_JAVA_ERROR);
                } else if (debug)
                    System.err.println("Accepted JLS4: revision " + id + ": file " + path);
            } else if (debug)
                System.err.println("Accepted JLS3: revision " + id + ": file " + path);
        } else if (debug)
            System.err.println("Accepted JLS2: revision " + id + ": file " + path);
    }

    return fb;
}

From source file:cideplus.ui.astview.ASTView.java

License:Open Source License

private int getInitialASTLevel(ITypeRoot typeRoot) {
    String option = typeRoot.getJavaProject().getOption(JavaCore.COMPILER_SOURCE, true);
    if (option.compareTo(JavaCore.VERSION_1_5) >= 0) {
        return JLS3;
    }/*from   w  w w  .j a  v a 2 s. co  m*/
    return fCurrentASTLevel; // use previous level
}

From source file:com.chookapp.org.bracketeer.jdt.core.internal.JavaPairMatcher.java

License:Open Source License

public void setSourceVersion(String version) {
    if (JavaCore.VERSION_1_5.compareTo(version) <= 0)
        fHighlightAngularBrackets = true;
    else//from   www .  jav  a 2  s  . c  o m
        fHighlightAngularBrackets = false;
}

From source file:com.ebmwebsourcing.petals.components.wizards.ComponentNewWizardPage.java

License:Open Source License

/**
 * Validates the page fields./*  ww w  .  j  a  v a2s .c o  m*/
 */
private void validate() {

    // Validate fields
    if (StringUtils.isEmpty(this.name)) {
        updateStatus("You have to provide the component name.");
        return;
    }

    if (!this.name.toLowerCase().equals(this.name)) {
        updateStatus("The component name should be completely in lower case.");
        return;
    }

    if (this.isAtDefaultLocation) {
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(this.name);
        if (project.exists()) {
            updateStatus("A component project with a similar name already exists in the workspace.");
            return;
        }
    }

    if (StringUtils.isEmpty(this.groupId)) {
        updateStatus("You have to provide the component group ID.");
        return;
    }

    if (!JavaConventions.validatePackageName(this.groupId, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5).isOK()) {
        updateStatus("The component group ID does not respect the Java package syntax.");
        return;
    }

    if (StringUtils.isEmpty(this.rootPackage)) {
        updateStatus("You have to provide the Java root package.");
        return;
    }

    if (!JavaConventions.validatePackageName(this.rootPackage, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5)
            .isOK()) {
        updateStatus("The Java root package name does not respect the Java package syntax.");
        return;
    }

    // Project location
    File projectFile;
    if (!this.isAtDefaultLocation) {

        if (StringUtils.isEmpty(this.location)) {
            updateStatus("You have to specify the project location.");
            return;
        }

        try {
            projectFile = new File(this.location, this.name);
            this.projectLocationURI = projectFile.toURI();

        } catch (Exception e) {
            updateStatus("The specified location is not a valid file location.");
            return;
        }

        IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(this.name);
        IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocationURI(p, this.projectLocationURI);
        if (status.getCode() != IStatus.OK) {
            updateStatus(status.getMessage());
            return;
        }

    } else {
        this.projectLocationURI = null;
        projectFile = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), this.name);
    }

    // Does the file exists?
    if (projectFile.exists()) {
        updateStatus("There is already an existing file at this location.");
        return;
    }

    updateStatus(null);
}

From source file:com.ebmwebsourcing.petals.components.wizards.SharedLibraryNewWizardPage.java

License:Open Source License

/**
 * Validates the page fields.//w w w .j  a v  a2  s  . co m
 */
private void validate() {

    // Validate fields
    if (StringUtils.isEmpty(this.name)) {
        updateStatus("You have to provide the shared-library's name.");
        return;
    }

    if (!this.name.toLowerCase().equals(this.name)) {
        updateStatus("The shared library's name should be completely in lower case.");
        return;
    }

    if (this.isAtDefaultLocation) {
        IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(this.name);
        if (project.exists()) {
            updateStatus("A project with a similar name already exists in the workspace.");
            return;
        }
    }

    if (StringUtils.isEmpty(this.groupId)) {
        updateStatus("You have to provide the group ID.");
        return;
    }

    if (!JavaConventions.validatePackageName(this.groupId, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5).isOK()) {
        updateStatus("The group ID does not respect the Java package syntax.");
        return;
    }

    // Project location
    File projectFile;
    if (!this.isAtDefaultLocation) {

        if (this.location == null || this.location.length() == 0) {
            updateStatus("You have to specify the project location.");
            return;
        }

        try {
            projectFile = new File(this.location, this.name);
            this.projectLocationURI = projectFile.toURI();

        } catch (Exception e) {
            updateStatus("The specified location is not a valid file location.");
            return;
        }

        IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(this.name);
        IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocationURI(p, this.projectLocationURI);
        if (status.getCode() != IStatus.OK) {
            updateStatus(status.getMessage());
            return;
        }

    } else {
        this.projectLocationURI = null;
        projectFile = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), this.name);
    }

    // Does the file exists?
    if (projectFile.exists()) {
        updateStatus("There is already an existing file at this location.");
        return;
    }

    updateStatus(null);
}

From source file:com.google.dart.java2dart.Context.java

License:Open Source License

/**
 * @return the Java AST of the given Java {@link File} in context of {@link #sourceFolders}.
 *//*from  w  w  w.j  a  va 2 s. c  o  m*/
private Map<File, CompilationUnit> parseJavaFiles(final List<File> javaFiles) throws Exception {
    String paths[] = new String[javaFiles.size()];
    final Map<String, File> pathToFile = Maps.newHashMap();
    for (int i = 0; i < javaFiles.size(); i++) {
        File javaFile = javaFiles.get(i);
        String javaPath = javaFile.getAbsolutePath();
        paths[i] = javaPath;
        pathToFile.put(javaPath, javaFile);
    }
    // prepare Java parser
    ASTParser parser = ASTParser.newParser(AST.JLS4);
    {
        String[] classpathEntries = new String[classpathFiles.size()];
        for (int i = 0; i < classpathFiles.size(); i++) {
            classpathEntries[i] = classpathFiles.get(i).getAbsolutePath();
        }
        String[] sourceEntries = new String[sourceFolders.size()];
        for (int i = 0; i < sourceFolders.size(); i++) {
            sourceEntries[i] = sourceFolders.get(i).getAbsolutePath();
        }
        parser.setEnvironment(classpathEntries, sourceEntries, null, true);
    }
    parser.setResolveBindings(true);
    parser.setCompilerOptions(ImmutableMap.of(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5,
            JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED));
    // do parse
    final Map<File, CompilationUnit> units = Maps.newLinkedHashMap();
    parser.createASTs(paths, null, ArrayUtils.EMPTY_STRING_ARRAY, new FileASTRequestor() {
        @Override
        public void acceptAST(String sourceFilePath, org.eclipse.jdt.core.dom.CompilationUnit javaUnit) {
            File astFile = pathToFile.get(sourceFilePath);
            CompilationUnit dartUnit = SyntaxTranslator.translate(Context.this, javaUnit);
            units.put(astFile, dartUnit);
        }
    }, null);
    return units;
}

From source file:com.google.dart.java2dart.SyntaxTranslatorTest.java

License:Open Source License

/**
 * Parse Java source lines into {@link #javaUnit}.
 *///from   w  w w  .  jav a  2  s  .  co m
private void parseJava(String... lines) {
    String source = Joiner.on("\n").join(lines);
    ASTParser parser = ASTParser.newParser(AST.JLS4);
    parser.setCompilerOptions(ImmutableMap.of(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5,
            JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED));
    parser.setSource(source.toCharArray());
    javaUnit = (org.eclipse.jdt.core.dom.CompilationUnit) parser.createAST(null);
    assertThat(javaUnit.getProblems()).isEmpty();
}

From source file:com.google.gdt.eclipse.appengine.rpc.util.JavaUtils.java

License:Open Source License

public static IStatus validatePackageName(String text) {
    return JavaConventions.validatePackageName(text, JavaCore.VERSION_1_5, JavaCore.VERSION_1_5);
}