本文整理汇总了Java中com.intellij.openapi.roots.LanguageLevelProjectExtension类的典型用法代码示例。如果您正苦于以下问题:Java LanguageLevelProjectExtension类的具体用法?Java LanguageLevelProjectExtension怎么用?Java LanguageLevelProjectExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LanguageLevelProjectExtension类属于com.intellij.openapi.roots包,在下文中一共展示了LanguageLevelProjectExtension类的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: setUp
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
@Override
protected void setUp() throws Exception
{
super.setUp();
IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory();
TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder( getProjectDescriptor() );
IdeaProjectTestFixture fixture = fixtureBuilder.getFixture();
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture( fixture, new TempDirTestFixtureImpl() );
myFixture.setUp();
myFixture.setTestDataPath( getTestDataPath() );
myModule = myFixture.getModule();
LanguageLevelProjectExtension.getInstance( getProject() ).setLanguageLevel( LanguageLevel.JDK_1_8 );
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: getLanguageLevelInner
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
private LanguageLevel getLanguageLevelInner() {
if (myOriginalFile instanceof PsiJavaFile) {
return ((PsiJavaFile)myOriginalFile).getLanguageLevel();
}
LanguageLevel forcedLanguageLevel = getUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY);
if (forcedLanguageLevel != null) return forcedLanguageLevel;
VirtualFile virtualFile = getVirtualFile();
if (virtualFile == null) virtualFile = getUserData(IndexingDataKeys.VIRTUAL_FILE);
final Project project = getProject();
if (virtualFile == null) {
final PsiFile originalFile = getOriginalFile();
if (originalFile instanceof PsiJavaFile && originalFile != this) {
return ((PsiJavaFile)originalFile).getLanguageLevel();
}
return LanguageLevelProjectExtension.getInstance(project).getLanguageLevel();
}
return JavaPsiImplementationHelper.getInstance(project).getEffectiveLanguageLevel(virtualFile);
}
示例8: JavaCoreProjectEnvironment
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
public JavaCoreProjectEnvironment(Disposable parentDisposable, CoreApplicationEnvironment applicationEnvironment) {
super(parentDisposable, applicationEnvironment);
myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager));
myProject.registerService(JavaPsiImplementationHelper.class, createJavaPsiImplementationHelper());
myProject.registerService(PsiResolveHelper.class, new PsiResolveHelperImpl(myPsiManager));
myProject.registerService(LanguageLevelProjectExtension.class, new CoreLanguageLevelProjectExtension());
myProject.registerService(JavaResolveCache.class, new JavaResolveCache(myMessageBus));
myProject.registerService(JavaCodeStyleSettingsFacade.class, new CoreJavaCodeStyleSettingsFacade());
myProject.registerService(JavaCodeStyleManager.class, new CoreJavaCodeStyleManager());
myPackageIndex = createCorePackageIndex();
myProject.registerService(PackageIndex.class, myPackageIndex);
myFileManager = createCoreFileManager();
myProject.registerService(JavaFileManager.class, myFileManager);
JavaPsiFacadeImpl javaPsiFacade = new JavaPsiFacadeImpl(myProject, myPsiManager, myFileManager, myMessageBus);
myProject.registerService(JavaPsiFacade.class, javaPsiFacade);
}
示例9: setUp
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
final IdeaTestFixtureFactory fixtureFactory = IdeaTestFixtureFactory.getFixtureFactory();
final TestFixtureBuilder<IdeaProjectTestFixture> testFixtureBuilder = fixtureFactory.createFixtureBuilder(getName());
myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(testFixtureBuilder.getFixture());
myFixture.setTestDataPath(PathManagerEx.getTestDataPath() + "/codeInsight/externalAnnotations");
final JavaModuleFixtureBuilder builder = testFixtureBuilder.addModule(JavaModuleFixtureBuilder.class);
new File(myFixture.getTempDirPath() + "/src/").mkdir();
builder.addContentRoot(myFixture.getTempDirPath()).addSourceRoot("src");
builder.setMockJdkLevel(JavaModuleFixtureBuilder.MockJdkLevel.jdk15);
myFixture.setUp();
myFixture.enableInspections(new SillyAssignmentInspection());
addAnnotationsModuleRoot();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(myFixture.getProject());
myLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
}
示例10: 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);
}
}
示例11: testSpaceAfterCommaInEnum
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
public void testSpaceAfterCommaInEnum() throws IncorrectOperationException {
getSettings().SPACE_AFTER_COMMA = true;
final JavaPsiFacade facade = getJavaFacade();
final LanguageLevel effectiveLanguageLevel = LanguageLevelProjectExtension.getInstance(facade.getProject()).getLanguageLevel();
try {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
doTextTest("public enum StringExDirection {\n" + "\n" + " RIGHT_TO_LEFT, LEFT_TO_RIGHT\n" + "\n" + "}",
"public enum StringExDirection {\n" + "\n" + " RIGHT_TO_LEFT, LEFT_TO_RIGHT\n" + "\n" + "}");
}
finally {
LanguageLevelProjectExtension.getInstance(facade.getProject()).setLanguageLevel(effectiveLanguageLevel);
}
}
示例12: testSCR2632
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
public void testSCR2632() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().RIGHT_MARGIN = 20;
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
doTextTest("/**\n" + " * <p />\n" + " * Another paragraph of the description placed after blank line.\n" + " */\n" + "class A{}",
"/**\n" +
" * <p/>\n" +
" * Another paragraph\n" +
" * of the description\n" +
" * placed after\n" +
" * blank line.\n" +
" */\n" +
"class A {\n" +
"}");
}
示例13: testSCR2632_JDK8_LanguageLevel
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
public void testSCR2632_JDK8_LanguageLevel() throws Exception {
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
getSettings().getRootSettings().WRAP_COMMENTS = true;
getSettings().RIGHT_MARGIN = 20;
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_8);
doTextTest("/**\n" + " * <p />\n" + " * Another paragraph of the description placed after blank line.\n" + " */\n" + "class A{}",
"/**\n" +
" * <p>\n" +
" * Another paragraph\n" +
" * of the description\n" +
" * placed after\n" +
" * blank line.\n" +
" */\n" +
"class A {\n" +
"}");
}
示例14: testGenerateSelfClosingPTagIfLanguageLevelNotJava8
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
public void testGenerateSelfClosingPTagIfLanguageLevelNotJava8() throws Exception {
getSettings().getRootSettings().JD_P_AT_EMPTY_LINES = true;
getSettings().getRootSettings().ENABLE_JAVADOC_FORMATTING = true;
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
String before = "/**\n" +
" * Super method\n" +
" *\n" +
" * Super multiple times\n" +
" */\n" +
"public void voo() {\n" +
"}\n";
String after = "/**\n" +
" * Super method\n" +
" * <p/>\n" +
" * Super multiple times\n" +
" */\n" +
"public void voo() {\n" +
"}\n";
doClassTest(before, after);
}
示例15: setProjectSdkAndLanguageLevel
import com.intellij.openapi.roots.LanguageLevelProjectExtension; //导入依赖的package包/类
private static void setProjectSdkAndLanguageLevel(
final Project project, final Sdk sdk, final LanguageLevel javaLanguageLevel) {
UIUtil.invokeAndWaitIfNeeded(
(Runnable)
() ->
ApplicationManager.getApplication()
.runWriteAction(
() -> {
ProjectRootManagerEx rootManager =
ProjectRootManagerEx.getInstanceEx(project);
rootManager.setProjectSdk(sdk);
LanguageLevelProjectExtension ext =
LanguageLevelProjectExtension.getInstance(project);
ext.setLanguageLevel(javaLanguageLevel);
}));
}