当前位置: 首页>>代码示例>>Java>>正文


Java LanguageLevelProjectExtension.getInstance方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.LanguageLevelProjectExtension.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java LanguageLevelProjectExtension.getInstance方法的具体用法?Java LanguageLevelProjectExtension.getInstance怎么用?Java LanguageLevelProjectExtension.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.LanguageLevelProjectExtension的用法示例。


在下文中一共展示了LanguageLevelProjectExtension.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectSdk

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
private void selectSdk(@NotNull final Project project) {
    Validate.notNull(project);

    final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);

    final Sdk projectSdk = projectRootManager.getProjectSdk();

    if (null == projectSdk) {
        return;
    }

    if (StringUtils.isNotBlank(projectSdk.getVersionString())) {
        final JavaSdkVersion sdkVersion = JdkVersionUtil.getVersion(projectSdk.getVersionString());
        final LanguageLevelProjectExtension languageLevelExt = LanguageLevelProjectExtension.getInstance(project);

        if (sdkVersion.getMaxLanguageLevel() != languageLevelExt.getLanguageLevel()) {
            languageLevelExt.setLanguageLevel(sdkVersion.getMaxLanguageLevel());
        }
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:ImportProjectProgressModalWindow.java

示例2: testEnum1

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testEnum1() throws Exception
{
    final Project project = getProject();
    final LanguageLevelProjectExtension llpExtension = LanguageLevelProjectExtension.getInstance(project);
    LanguageLevel oldLevel = llpExtension.getLanguageLevel();
    llpExtension.setLanguageLevel(LanguageLevel.JDK_1_5);
    configureByFile("/com/wrq/rearranger/Enum1Test.java");
    final PsiFile file = getFile();
    final Document doc = PsiDocumentManager.getInstance(project).getDocument(file);
    rs = RearrangerSettings.getSettingsFromFile(new File(InteractiveTest.DEFAULT_CONFIGURATION));
    rs.setAskBeforeRearranging(false);
    rs.getNewlinesAtEOF().setForce(true);
    rs.getNewlinesAtEOF().setnBlankLines(1);
    rs.setRearrangeInnerClasses(true);
    rs.getExtractedMethodsSettings().setBelowFirstCaller(true);
    final RearrangerActionHandler rah = new RearrangerActionHandler();
    rah.rearrangeDocument(project, file, rs, doc);
    super.checkResultByFile("/com/wrq/rearranger/Enum1Result.java");
    llpExtension.setLanguageLevel(oldLevel);
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:21,代码来源:RearrangerTest.java

示例3: testEnum2

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testEnum2() throws Exception
{
    final Project project = getProject();
    final LanguageLevelProjectExtension llpExtension = LanguageLevelProjectExtension.getInstance(project);
    LanguageLevel oldLevel = llpExtension.getLanguageLevel();
    llpExtension.setLanguageLevel(LanguageLevel.JDK_1_5);
    configureByFile("/com/wrq/rearranger/Enum2Test.java");
    final PsiFile file = getFile();
    final Document doc = PsiDocumentManager.getInstance(project).getDocument(file);
    rs = RearrangerSettings.getSettingsFromFile(new File(InteractiveTest.DEFAULT_CONFIGURATION));
    rs.setAskBeforeRearranging(false);
    rs.setRearrangeInnerClasses(true);
    rs.getAfterClassRBrace().setForce(false);
    final RearrangerActionHandler rah = new RearrangerActionHandler();
    rah.rearrangeDocument(project, file, rs, doc);
    super.checkResultByFile("/com/wrq/rearranger/Enum2Result.java");
    llpExtension.setLanguageLevel(oldLevel);
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:19,代码来源:RearrangerTest.java

示例4: testEnum2A

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testEnum2A() throws Exception
{
    final Project project = getProject();
    final LanguageLevelProjectExtension llpExtension = LanguageLevelProjectExtension.getInstance(project);
    LanguageLevel oldLevel = llpExtension.getLanguageLevel();
    llpExtension.setLanguageLevel(LanguageLevel.JDK_1_5);
    configureByFile("/com/wrq/rearranger/Enum2Test.java");
    final PsiFile file = getFile();
    final Document doc = PsiDocumentManager.getInstance(project).getDocument(file);
    rs = RearrangerSettings.getSettingsFromFile(new File(InteractiveTest.DEFAULT_CONFIGURATION));
    rs.setAskBeforeRearranging(false);
    rs.setRearrangeInnerClasses(false);
    rs.getAfterClassRBrace().setForce(false);
    final RearrangerActionHandler rah = new RearrangerActionHandler();
    rah.rearrangeDocument(project, file, rs, doc);
    super.checkResultByFile("/com/wrq/rearranger/Enum2AResult.java");
    llpExtension.setLanguageLevel(oldLevel);
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:19,代码来源:RearrangerTest.java

示例5: testEnumSelection

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testEnumSelection() throws Exception
{
    configureByFile("/com/wrq/rearranger/RearrangementTest47.java");
    final PsiFile file = getFile();
    final Project project = getProject();
    final LanguageLevelProjectExtension llpExtension = LanguageLevelProjectExtension.getInstance(project);
    LanguageLevel oldLevel = llpExtension.getLanguageLevel();
    llpExtension.setLanguageLevel(LanguageLevel.JDK_1_5);
    final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
    final RearrangerActionHandler rah = new RearrangerActionHandler();
    FieldAttributes fa = new FieldAttributes();
    fa.getStAttr().setValue(true);
    rs.addItem(fa, 0);
    InnerClassAttributes ica = new InnerClassAttributes();
    ica.getEnumAttr().setValue(true);
    rs.addItem(ica, 1);
    rah.rearrangeDocument(getProject(), file, rs, doc);
    super.checkResultByFile("/com/wrq/rearranger/RearrangementResult47.java");
    llpExtension.setLanguageLevel(oldLevel);
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:21,代码来源:RearrangerTest.java

示例6: testAfterNew15

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testAfterNew15() throws Exception {
  final LanguageLevelProjectExtension ll = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel old = ll.getLanguageLevel();
  ll.setLanguageLevel(LanguageLevel.JDK_1_5);

  try {
    final String path = BASE_PATH;
    configureByFile(path + "/AfterNew15.java");
    performSmartCompletion();
    select('\n', getSelected());
    checkResultByFile(path + "/AfterNew15-out.java");
  }
  finally {
    ll.setLanguageLevel(old);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CompletionStyleTest.java

示例7: isModified

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
@Override
@SuppressWarnings({"SimplifiableIfStatement"})
public boolean isModified() {
  LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(myProject);
  if (!extension.getLanguageLevel().equals(myLanguageLevelCombo.getSelectedLevel()) ||
       extension.isDefault() != myLanguageLevelCombo.isDefault()) {
    return true;
  }
  final String compilerOutput = getOriginalCompilerOutputUrl();
  if (!Comparing.strEqual(FileUtil.toSystemIndependentName(VfsUtilCore.urlToPath(compilerOutput)),
                          FileUtil.toSystemIndependentName(myProjectCompilerOutput.getText()))) return true;
  if (myProjectJdkConfigurable.isModified()) return true;
  if (myProjectName != null) {
    if (!myProjectName.getText().trim().equals(myProject.getName())) return true;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ProjectConfigurable.java

示例8: testLanguageLevelForApi21

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
@Test @IdeGuiTest
public void testLanguageLevelForApi21() {
  // Verifies that creating a project with L will set the language level correctly
  // both in the generated Gradle model as well as in the synced project and modules

  // "20+" here should change to 21 as soon as L goes out of preview state
  IdeFrameFixture projectFrame = newProject("Test Application").withBriefNames().withMinSdk("20+").create();

  IdeaAndroidProject appAndroidProject = projectFrame.getAndroidProjectForModule("app");
  AndroidProject model = appAndroidProject.getDelegate();
  ApiVersion minSdkVersion = model.getDefaultConfig().getProductFlavor().getMinSdkVersion();
  assertNotNull("minSdkVersion", minSdkVersion);

  // If this test fails, verify that
  //   (1) you have the L preview installed in the SDK on the test machine
  //   (2) the associated JDK is JDK 7 or higher
  assertThat(minSdkVersion.getApiString()).as("minSdkVersion API").isEqualTo("L");
  assertThat(appAndroidProject.getJavaLanguageLevel()).as("Gradle Java language level").isSameAs(LanguageLevel.JDK_1_7);
  LanguageLevelProjectExtension projectExt = LanguageLevelProjectExtension.getInstance(projectFrame.getProject());
  assertThat(projectExt.getLanguageLevel()).as("Project Java language level").isSameAs(LanguageLevel.JDK_1_7);
  for (Module module : ModuleManager.getInstance(projectFrame.getProject()).getModules()) {
    LanguageLevelModuleExtension moduleExt = LanguageLevelModuleExtensionImpl.getInstance(module);
    assertThat(moduleExt.getLanguageLevel()).as("Gradle Java language level in module " + module.getName()).isNull();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NewProjectTest.java

示例9: test

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void test() throws Exception {
  final UnnecessaryReturnInspection inspection = new UnnecessaryReturnInspection();
  inspection.ignoreInThenBranch = true;
  final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel level = levelProjectExtension.getLanguageLevel();
  try {
    levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
    doTest("com/siyeh/igtest/controlflow/unnecessary_return", new LocalInspectionToolWrapper(inspection), "java 1.8");
  }
  finally {
    levelProjectExtension.setLanguageLevel(level);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:UnnecessaryReturnInspectionTest.java

示例10: test

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void test() throws Exception {
  final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel level = levelProjectExtension.getLanguageLevel();
  try {
    levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
    doTest("com/siyeh/igtest/inheritance/interface_never_implemented",
           new LocalInspectionToolWrapper(new InterfaceNeverImplementedInspection()), "java 1.8");
  }
  finally {
    levelProjectExtension.setLanguageLevel(level);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:InterfaceNeverImplementedInspectionTest.java

示例11: test

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void test() throws Exception {
  final UnnecessaryParenthesesInspection inspection = new UnnecessaryParenthesesInspection();
  inspection.ignoreParenthesesOnConditionals = true;
  final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel level = levelProjectExtension.getLanguageLevel();
  try {
    levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
    doTest("com/siyeh/igtest/style/unnecessary_parentheses",
           new LocalInspectionToolWrapper(inspection), "java 1.8");
  }
  finally {
    levelProjectExtension.setLanguageLevel(level);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UnnecessaryParenthesesInspectionTest.java

示例12: setLanguageLevel

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
@SuppressWarnings("MethodMayBeStatic")
public void setLanguageLevel(@NotNull final LanguageLevel languageLevel, @NotNull Project project) {
  final LanguageLevelProjectExtension languageLevelExtension = LanguageLevelProjectExtension.getInstance(project);
  if (languageLevelExtension.getLanguageLevel().isAtLeast(languageLevel)) {
    return;
  }
  ExternalSystemApiUtil.executeProjectChangeAction(new DisposeAwareProjectChange(project) {
    @Override
    public void execute() {
      languageLevelExtension.setLanguageLevel(languageLevel);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaProjectDataService.java

示例13: doTestString

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
private void doTestString() {
  final LanguageLevelProjectExtension languageLevelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel oldLanguageLevel = languageLevelProjectExtension.getLanguageLevel();
  languageLevelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_7);
  try {
    doTest();
  }
  finally {
    languageLevelProjectExtension.setLanguageLevel(oldLanguageLevel);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:CreateSwitchTest.java

示例14: testStaticToInterface

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testStaticToInterface() throws Exception {
  final LanguageLevelProjectExtension levelProjectExtension = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel level = levelProjectExtension.getLanguageLevel();
  try {
    levelProjectExtension.setLanguageLevel(LanguageLevel.JDK_1_8);
    doTest("A", "B", 0);
  }
  finally {
    levelProjectExtension.setLanguageLevel(level);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MoveMembersTest.java

示例15: testFromNestedToOuterMethodRef

import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入方法依赖的package包/类
public void testFromNestedToOuterMethodRef() throws Exception {
  final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject());
  final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
  try {
    projectExtension.setLanguageLevel(LanguageLevel.HIGHEST);
    doTest("Outer.Inner", "Outer", true, VisibilityUtil.ESCALATE_VISIBILITY, 0);
  }
  finally {
    projectExtension.setLanguageLevel(oldLevel);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MoveMembersTest.java


注:本文中的com.intellij.openapi.roots.LanguageLevelProjectExtension.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。