Example usage for org.eclipse.jdt.core IClasspathAttribute IGNORE_OPTIONAL_PROBLEMS

List of usage examples for org.eclipse.jdt.core IClasspathAttribute IGNORE_OPTIONAL_PROBLEMS

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IClasspathAttribute IGNORE_OPTIONAL_PROBLEMS.

Prototype

String IGNORE_OPTIONAL_PROBLEMS

To view the source code for org.eclipse.jdt.core IClasspathAttribute IGNORE_OPTIONAL_PROBLEMS.

Click Source Link

Document

Constant for the name of the ignore optional compile problems attribute.

Usage

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

License:Open Source License

public boolean ignoreOptionalProblems() {
    if (this.entryKind == IClasspathEntry.CPE_SOURCE) {
        for (int i = 0; i < this.extraAttributes.length; i++) {
            IClasspathAttribute attrib = this.extraAttributes[i];
            if (IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS.equals(attrib.getName())) {
                return "true".equals(attrib.getValue()); //$NON-NLS-1$
            }//from w  w  w  .  j  ava  2  s.com
        }
    }
    return false;
}

From source file:io.sarl.eclipse.natures.SARLProjectConfigurator.java

License:Apache License

/** Replies the default source entries for a SARL project.
 *
 * @param projectFolder the folder of the project.
 * @return the classpath entries./*from ww  w  .j av  a  2 s  . c o  m*/
 */
public static List<IClasspathEntry> getDefaultSourceClassPathEntries(IPath projectFolder) {
    final IPath srcJava = projectFolder.append(Path.fromPortableString(SARLConfig.FOLDER_SOURCE_JAVA));
    final IClasspathEntry srcJavaEntry = JavaCore.newSourceEntry(srcJava.makeAbsolute());

    final IPath srcSarl = projectFolder.append(Path.fromPortableString(SARLConfig.FOLDER_SOURCE_SARL));
    final IClasspathEntry srcSarlEntry = JavaCore.newSourceEntry(srcSarl.makeAbsolute());

    final IPath srcGeneratedSources = projectFolder
            .append(Path.fromPortableString(SARLConfig.FOLDER_SOURCE_GENERATED));
    final IClasspathAttribute attr = JavaCore
            .newClasspathAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, Boolean.TRUE.toString());
    final IClasspathEntry srcGeneratedSourcesEntry = JavaCore.newSourceEntry(srcGeneratedSources.makeAbsolute(),
            ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null /*output location*/,
            new IClasspathAttribute[] { attr });

    final IPath srcResources = projectFolder.append(Path.fromPortableString(SARLConfig.FOLDER_RESOURCES));
    final IClasspathEntry srcResourcesEntry = JavaCore.newSourceEntry(srcResources.makeAbsolute());

    return Arrays.asList(srcSarlEntry, srcJavaEntry, srcResourcesEntry, srcGeneratedSourcesEntry);
}

From source file:io.sarl.eclipse.natures.SARLProjectConfigurator.java

License:Apache License

private static List<CPListElement> buildClassPathEntries(IJavaProject project, IFolder[] sourcePaths,
        IFolder[] generationPaths) {/*from  ww w.  j a v  a2 s .  co  m*/
    final List<CPListElement> list = new ArrayList<>();

    for (final IFolder sourcePath : sourcePaths) {
        if (sourcePath != null) {
            list.add(new CPListElement(project, IClasspathEntry.CPE_SOURCE,
                    sourcePath.getFullPath().makeAbsolute(), sourcePath));
        }
    }

    for (final IFolder sourcePath : generationPaths) {
        if (sourcePath != null) {
            final IClasspathAttribute attr = JavaCore.newClasspathAttribute(
                    IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, Boolean.TRUE.toString());
            final IClasspathEntry entry = JavaCore.newSourceEntry(sourcePath.getFullPath().makeAbsolute(),
                    ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null /*output location*/,
                    new IClasspathAttribute[] { attr });
            list.add(CPListElement.create(entry, false, project));
        }
    }

    for (final IClasspathEntry current : PreferenceConstants.getDefaultJRELibrary()) {
        if (current != null) {
            list.add(CPListElement.create(current, true, project));
            break;
        }
    }

    list.add(CPListElement.create(JavaCore.newContainerEntry(SARLClasspathContainerInitializer.CONTAINER_ID),
            true, project));

    return list;
}

From source file:io.sarl.m2e.SARLProjectConfigurator.java

License:Apache License

/** Invoked to add the source folders.
 *
 * @param facade - the facade of the Maven project.
 * @param config - the configuration.//  ww  w  . j a v a 2 s.  c  o  m
 * @param classpath - the project classpath.
 * @param monitor - the monitor.
 * @throws CoreException if cannot add the source folders.
 */
@SuppressWarnings("checkstyle:magicnumber")
protected void addSourceFolders(IMavenProjectFacade facade, SARLConfiguration config,
        IClasspathDescriptor classpath, IProgressMonitor monitor) throws CoreException {

    assertHasNature(facade.getProject(), SARLEclipseConfig.NATURE_ID);
    assertHasNature(facade.getProject(), SARLEclipseConfig.XTEXT_NATURE_ID);
    assertHasNature(facade.getProject(), JavaCore.NATURE_ID);

    final String encoding = config.getEncoding();

    final SubMonitor subMonitor = SubMonitor.convert(monitor, 4);

    // Add the source folders
    final IPath inputPath = makeFullPath(facade, config.getInput());
    final IFolder inputFolder = ensureFolderExists(facade, inputPath, false, subMonitor);
    if (encoding != null && inputFolder != null && inputFolder.exists()) {
        inputFolder.setDefaultCharset(encoding, monitor);
    }
    classpath.addSourceEntry(inputPath, facade.getOutputLocation(), true);
    subMonitor.worked(1);

    final IPath outputPath = makeFullPath(facade, config.getOutput());
    final IFolder outputFolder = ensureFolderExists(facade, outputPath, true, subMonitor);
    if (encoding != null && outputFolder != null && outputFolder.exists()) {
        outputFolder.setDefaultCharset(encoding, monitor);
    }
    IClasspathEntryDescriptor descriptor = classpath.addSourceEntry(outputPath, facade.getOutputLocation(),
            true);
    descriptor.setClasspathAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, Boolean.TRUE.toString());
    subMonitor.worked(1);

    // Add the test folders
    final IPath testInputPath = makeFullPath(facade, config.getTestInput());
    final IFolder testInputFolder = ensureFolderExists(facade, testInputPath, false, subMonitor);
    if (encoding != null && testInputFolder != null && testInputFolder.exists()) {
        testInputFolder.setDefaultCharset(encoding, monitor);
    }
    classpath.addSourceEntry(testInputPath, facade.getOutputLocation(), true);
    subMonitor.worked(1);

    final IPath testOutputPath = makeFullPath(facade, config.getTestOutput());
    final IFolder testOutputFolder = ensureFolderExists(facade, testOutputPath, true, subMonitor);
    if (encoding != null && testOutputFolder != null && testOutputFolder.exists()) {
        testOutputFolder.setDefaultCharset(encoding, monitor);
    }
    descriptor = classpath.addSourceEntry(testOutputPath, facade.getOutputLocation(), true);
    descriptor.setClasspathAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, Boolean.TRUE.toString());
    subMonitor.done();
}

From source file:org.eclipse.m2e.tests.jdt.JavaCodeGenerationProjectConfiguratorTest.java

License:Open Source License

public void test368333_generatedSourcesFoldersAreNotRemovedDuringConfigurationUpdate() throws Exception {
    IProject project = importProject("368333_missingGeneratedSourceFolders",
            "projects/368333_missingGeneratedSourceFolders", new ResolverConfiguration());
    assertNoErrors(project);//from   w w  w .  j  a va2 s  .  co m

    IJavaProject javaProject = JavaCore.create(project);

    assertClasspath(new String[] { //
            "/368333_missingGeneratedSourceFolders/src/main/java", //
            "/368333_missingGeneratedSourceFolders/src/test/java", //
            "org.eclipse.jdt.launching.JRE_CONTAINER/.*", //
            "org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER", //
            "/368333_missingGeneratedSourceFolders/target/generated-sources/test",//
    }, //
            javaProject.getRawClasspath());

    assertClasspathAttribute(javaProject.getRawClasspath(),
            "/368333_missingGeneratedSourceFolders/src/main/java", IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS,
            null);
    assertClasspathAttribute(javaProject.getRawClasspath(),
            "/368333_missingGeneratedSourceFolders/target/generated-sources/test",
            IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, "true");

    MavenPlugin.getProjectConfigurationManager().updateProjectConfiguration(project, monitor);

    assertClasspath(new String[] { //
            "/368333_missingGeneratedSourceFolders/src/main/java", //
            "/368333_missingGeneratedSourceFolders/src/test/java", //
            "org.eclipse.jdt.launching.JRE_CONTAINER/.*", //
            "org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER", //
            "/368333_missingGeneratedSourceFolders/target/generated-sources/test",//
    }, //
            javaProject.getRawClasspath());

    assertClasspathAttribute(javaProject.getRawClasspath(),
            "/368333_missingGeneratedSourceFolders/src/main/java", IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS,
            null);
    assertClasspathAttribute(javaProject.getRawClasspath(),
            "/368333_missingGeneratedSourceFolders/target/generated-sources/test",
            IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, "true");
}

From source file:org.levigo.m2e.assertj.internal.AssertJProjectConfigurator.java

License:Open Source License

public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath,
        IProgressMonitor monitor) throws CoreException {
    IMavenProjectFacade facade = request.getMavenProjectFacade();

    assertHasNature(request.getProject(), JavaCore.NATURE_ID);

    for (MojoExecution mojoExecution : getMojoExecutions(request, monitor)) {
        File[] sources = getSourceFolders(request, mojoExecution, monitor);

        for (File source : sources) {
            IPath sourcePath = getFullPath(facade, source);

            if (sourcePath != null) {
                IClasspathEntryDescriptor entry = classpath.addSourceEntry(sourcePath,
                        facade.getTestOutputLocation(), true);
                entry.setClasspathAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, "true"); //$NON-NLS-1$
            }/*from   www .j av  a 2  s  .  co m*/
        }
    }
}