Search in sources :

Example 1 with CompilerEncodingConfiguration

use of org.jetbrains.jps.incremental.CompilerEncodingConfiguration in project intellij-community by JetBrains.

the class CompilerEncodingConfigurationTest method test.

public void test() {
    loadProject("/jps/jps-builders/testData/compilerEncoding/compilerEncoding.ipr");
    JpsEncodingProjectConfiguration projectConfig = JpsEncodingConfigurationService.getInstance().getEncodingConfiguration(myProject);
    assertNotNull(projectConfig);
    // overridden by file's internal encoding
    assertEncoding("UTF-8", "moduleA/src/dir/with-encoding.xml", projectConfig);
    assertEncoding("windows-1251", "moduleA/src/dir/with-encoding.txt", projectConfig);
    assertEncoding("UTF-8", "moduleA/src/dir/without-encoding.xml", projectConfig);
    assertEncoding("UTF-8", "moduleA/src/dir/without-encoding.txt", projectConfig);
    assertEncoding("UTF-8", "moduleA/src/dir/non-existent.xml", projectConfig);
    assertEncoding("windows-1252", "moduleB/src/non-existent.xml", projectConfig);
    final CompilerEncodingConfiguration compilerEncodingConfiguration = new CompilerEncodingConfiguration(myModel, myRootIndex);
    for (JpsModule module : myProject.getModules()) {
        final String moduleEncoding = compilerEncodingConfiguration.getPreferredModuleEncoding(module);
        if ("moduleA".equals(module.getName())) {
            assertEquals("UTF-8", moduleEncoding);
        } else if ("moduleB".equals(module.getName())) {
            assertNull(moduleEncoding);
        } else if ("moduleC".equals(module.getName())) {
            assertEquals("windows-1252", moduleEncoding);
        } else {
            fail("Unexpected module in project: " + module.getName());
        }
    }
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) CompilerEncodingConfiguration(org.jetbrains.jps.incremental.CompilerEncodingConfiguration)

Aggregations

CompilerEncodingConfiguration (org.jetbrains.jps.incremental.CompilerEncodingConfiguration)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1