Search in sources :

Example 1 with CommonCompilerArguments

use of org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments in project intellij by bazelbuild.

the class BlazeKotlinSyncPlugin method maybeUpdateCompilerConfig.

/**
 * Update the compiler settings of the project if needed. The language setting applies to both the
 * api version and the language version. Blanket setting this project wide is fine. The rules
 * should catch incorrect usage.
 */
private static void maybeUpdateCompilerConfig(Project project, ProjectViewSet projectViewSet) {
    LanguageVersion languageLevel = BlazeKotlinLanguageVersionSection.getLanguageLevel(projectViewSet);
    String languageLevelVersionString = languageLevel.getVersionString();
    CommonCompilerArguments settings = CommonCompilerArgumentsCompatUtils.getUnfrozenSettings(project);
    boolean updated = false;
    String apiVersion = CommonCompilerArgumentsCompatUtils.getApiVersion(settings);
    String languageVersion = CommonCompilerArgumentsCompatUtils.getLanguageVersion(settings);
    if (apiVersion == null || !apiVersion.equals(languageLevelVersionString)) {
        updated = true;
        CommonCompilerArgumentsCompatUtils.setApiVersion(settings, languageLevelVersionString);
    }
    if (languageVersion == null || !languageVersion.equals(languageLevelVersionString)) {
        updated = true;
        CommonCompilerArgumentsCompatUtils.setLanguageVersion(settings, languageLevelVersionString);
    }
    if (updated) {
        KotlinCommonCompilerArgumentsHolder.Companion.getInstance(project).setSettings(settings);
    }
}
Also used : LanguageVersion(org.jetbrains.kotlin.config.LanguageVersion) CommonCompilerArguments(org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments)

Example 2 with CommonCompilerArguments

use of org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments in project intellij by bazelbuild.

the class KotlinSyncTest method assertViewConfigState.

private void assertViewConfigState(LanguageVersion languageVersion) {
    runBlazeSync(new BlazeSyncParams.Builder("Sync", BlazeSyncParams.SyncMode.INCREMENTAL).addProjectViewTargets(true).build());
    ProjectViewSet projectViewSet = ProjectViewManager.getInstance(getProject()).getProjectViewSet();
    assert projectViewSet != null;
    assertThat(BlazeKotlinLanguageVersionSection.getLanguageLevel(projectViewSet)).isEqualTo(languageVersion);
    // test the compiler reflect the project view.
    CommonCompilerArguments settings = KotlinCommonCompilerArgumentsHolder.Companion.getInstance(getProject()).getSettings();
    assertThat(CommonCompilerArgumentsCompatUtils.getApiVersion(settings)).isEqualTo(languageVersion.getVersionString());
    assertThat(CommonCompilerArgumentsCompatUtils.getLanguageVersion(settings)).isEqualTo(languageVersion.getVersionString());
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) CommonCompilerArguments(org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams)

Aggregations

CommonCompilerArguments (org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments)2 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)1 BlazeSyncParams (com.google.idea.blaze.base.sync.BlazeSyncParams)1 LanguageVersion (org.jetbrains.kotlin.config.LanguageVersion)1