com.intellij.openapi.roots.LanguageLevelModuleExtension Java Examples

The following examples show how to use com.intellij.openapi.roots.LanguageLevelModuleExtension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelLightCodeInsightFixtureTestCaseIT.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
    LanguageLevel languageLevel = LanguageLevel.JDK_1_8;
    return new DefaultLightProjectDescriptor() {
        @Override
        public Sdk getSdk() {
            String compilerOption = JpsJavaSdkType.complianceOption(languageLevel.toJavaVersion());
            return JavaSdk.getInstance().createJdk( "java " + compilerOption, BUILD_MOCK_JDK_DIRECTORY + compilerOption, false );
        }

        @Override
        public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
            model.getModuleExtension( LanguageLevelModuleExtension.class ).setLanguageLevel( languageLevel );
        }
    };
}
 
Example #2
Source File: CamelInspectionTestHelper.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
    LanguageLevel languageLevel = LanguageLevel.JDK_1_8;
    return new DefaultLightProjectDescriptor() {
        @Override
        public Sdk getSdk() {
            String compilerOption = JpsJavaSdkType.complianceOption(languageLevel.toJavaVersion());
            return JavaSdk.getInstance().createJdk( "java " + compilerOption, BUILD_MOCK_JDK_DIRECTORY + compilerOption, false );
        }

        @Override
        public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
            model.getModuleExtension( LanguageLevelModuleExtension.class ).setLanguageLevel( languageLevel );
        }
    };
}
 
Example #3
Source File: InitializrModuleBuilder.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
@Override
public void setupRootModel(ModifiableRootModel modifiableRootModel) {
  Sdk moduleOrProjectSdk = getModuleJdk() != null ?
      getModuleJdk() :
      getInstance(modifiableRootModel.getProject()).getProjectSdk();
  if (moduleOrProjectSdk != null) {
    modifiableRootModel.setSdk(moduleOrProjectSdk);
  }

  LanguageLevelModuleExtension languageLevelModuleExtension =
      modifiableRootModel.getModuleExtension(LanguageLevelModuleExtension.class);
  if (languageLevelModuleExtension != null && moduleOrProjectSdk != null) {
    if (safeGetProjectCreationRequest().isJavaVersionSet()) {
      LanguageLevel lastSelectedLanguageLevel =
          parse(safeGetProjectCreationRequest().getJavaVersion().getId());
      if (lastSelectedLanguageLevel != null) {
        JavaSdkVersion lastSelectedJavaSdkVersion = fromLanguageLevel(lastSelectedLanguageLevel);
        JavaSdkVersion moduleOrProjectLevelJavaSdkVersion =
            getInstance().getVersion(moduleOrProjectSdk);
        if (moduleOrProjectLevelJavaSdkVersion != null && moduleOrProjectLevelJavaSdkVersion
            .isAtLeast(lastSelectedJavaSdkVersion)) {
          languageLevelModuleExtension.setLanguageLevel(lastSelectedLanguageLevel);
        }
      }
    }
  }

  doAddContentEntry(modifiableRootModel);
}
 
Example #4
Source File: LombokTestUtil.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static LightProjectDescriptor getProjectDescriptor() {
  return new DefaultLightProjectDescriptor() {
    @Override
    public Sdk getSdk() {
      return JavaSdk.getInstance().createJdk("java 1.8", "lib/mockJDK-1.8", false);
    }

    @Override
    public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model, @NotNull ContentEntry contentEntry) {
      model.getModuleExtension(LanguageLevelModuleExtension.class).setLanguageLevel(LanguageLevel.JDK_1_8);
    }
  };
}