Search in sources :

Example 36 with LanguageLevel

use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.

the class IdeaTestUtil method withLevel.

public static void withLevel(final Module module, final LanguageLevel level, final Runnable r) {
    final LanguageLevelProjectExtension projectExt = LanguageLevelProjectExtension.getInstance(module.getProject());
    final LanguageLevel projectLevel = projectExt.getLanguageLevel();
    final LanguageLevel moduleLevel = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
    try {
        projectExt.setLanguageLevel(level);
        setModuleLanguageLevel(module, level);
        r.run();
    } finally {
        setModuleLanguageLevel(module, moduleLevel);
        projectExt.setLanguageLevel(projectLevel);
    }
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Example 37 with LanguageLevel

use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.

the class IdeaTestUtil method setModuleLanguageLevel.

public static void setModuleLanguageLevel(Module module, final LanguageLevel level, Disposable parentDisposable) {
    LanguageLevel prev = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
    setModuleLanguageLevel(module, level);
    Disposer.register(parentDisposable, () -> setModuleLanguageLevel(module, prev));
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel)

Example 38 with LanguageLevel

use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.

the class ProjectConfigurable method createUIComponents.

private void createUIComponents() {
    myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {

        @Override
        protected LanguageLevel getDefaultLevel() {
            Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
            if (sdk == null)
                return null;
            JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
            return version == null ? null : version.getMaxLanguageLevel();
        }
    };
    final JTextField textField = new JTextField();
    final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
    outputPathsChooserDescriptor.setHideIgnored(false);
    BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
    myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
    FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
Also used : JavaSdkVersion(com.intellij.openapi.projectRoots.JavaSdkVersion) BrowseFilesListener(com.intellij.ide.util.BrowseFilesListener) LanguageLevel(com.intellij.pom.java.LanguageLevel) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) FieldPanel(com.intellij.ui.FieldPanel)

Example 39 with LanguageLevel

use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.

the class PsiJavaParserFacadeImpl method createTypeElementFromText.

@NotNull
@Override
public PsiTypeElement createTypeElementFromText(@NotNull final String text, @Nullable final PsiElement context) throws IncorrectOperationException {
    final LanguageLevel level = level(context);
    final DummyHolder holder = DummyHolderFactory.createHolder(myManager, new JavaDummyElement(text, TYPE, level), context);
    final PsiElement element = SourceTreeToPsiMap.treeElementToPsi(holder.getTreeElement().getFirstChildNode());
    if (!(element instanceof PsiTypeElement)) {
        throw new IncorrectOperationException("Incorrect type '" + text + "' (" + level + ")");
    }
    return (PsiTypeElement) element;
}
Also used : JavaDummyElement(com.intellij.psi.impl.source.JavaDummyElement) LanguageLevel(com.intellij.pom.java.LanguageLevel) DummyHolder(com.intellij.psi.impl.source.DummyHolder) IncorrectOperationException(com.intellij.util.IncorrectOperationException) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with LanguageLevel

use of com.intellij.pom.java.LanguageLevel in project intellij-community by JetBrains.

the class JavaFileElementType method serialize.

@Override
public void serialize(@NotNull PsiJavaFileStub stub, @NotNull StubOutputStream dataStream) throws IOException {
    dataStream.writeBoolean(stub.isCompiled());
    LanguageLevel level = stub.getLanguageLevel();
    dataStream.writeByte(level != null ? level.ordinal() : -1);
    dataStream.writeName(stub.getPackageName());
}
Also used : LanguageLevel(com.intellij.pom.java.LanguageLevel)

Aggregations

LanguageLevel (com.intellij.pom.java.LanguageLevel)98 LanguageLevelProjectExtension (com.intellij.openapi.roots.LanguageLevelProjectExtension)21 Nullable (org.jetbrains.annotations.Nullable)14 Module (com.intellij.openapi.module.Module)13 NotNull (org.jetbrains.annotations.NotNull)9 Sdk (com.intellij.openapi.projectRoots.Sdk)8 JavaPsiFacade (com.intellij.psi.JavaPsiFacade)7 Project (com.intellij.openapi.project.Project)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 File (java.io.File)6 IOException (java.io.IOException)5 IncorrectOperationException (com.intellij.util.IncorrectOperationException)4 LocalInspectionToolWrapper (com.intellij.codeInspection.ex.LocalInspectionToolWrapper)3 Lexer (com.intellij.lexer.Lexer)3 LanguageLevelModuleExtension (com.intellij.openapi.roots.LanguageLevelModuleExtension)3 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 JavaProjectData (com.intellij.externalSystem.JavaProjectData)2 DisposeAwareProjectChange (com.intellij.openapi.externalSystem.util.DisposeAwareProjectChange)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)2