Search in sources :

Example 51 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class JavaFxModuleUtil method isInJavaFxModule.

private static boolean isInJavaFxModule(@NotNull PsiFile file) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile != null) {
        final Project project = file.getProject();
        final Module fileModule = ModuleUtilCore.findModuleForFile(virtualFile, project);
        if (fileModule != null) {
            return getCachedJavaFxModules(project).contains(fileModule);
        }
    }
    return false;
}
Also used : Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module)

Example 52 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class StructureImportingTest method testSettingTargetLevel.

public void testSettingTargetLevel() throws Exception {
    JavacConfiguration.getOptions(myProject, JavacConfiguration.class).ADDITIONAL_OPTIONS_STRING = "-Xmm500m -Xms128m -target 1.5";
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <plugins>" + "    <plugin>" + "      <artifactId>maven-compiler-plugin</artifactId>" + "        <configuration>" + "          <target>1.3</target>" + "        </configuration>" + "     </plugin>" + "  </plugins>" + "</build>");
    assertEquals("-Xmm500m -Xms128m", JavacConfiguration.getOptions(myProject, JavacConfiguration.class).ADDITIONAL_OPTIONS_STRING.trim());
    Module module = getModule("project");
    String targetLevel = CompilerConfiguration.getInstance(myProject).getBytecodeTargetLevel(module);
    assertEquals("1.3", targetLevel);
}
Also used : JavacConfiguration(com.intellij.compiler.impl.javaCompiler.javac.JavacConfiguration) Module(com.intellij.openapi.module.Module)

Example 53 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class StructureImportingTest method testSettingTargetLevelFromDefaultCompileExecutionConfiguration.

public void testSettingTargetLevelFromDefaultCompileExecutionConfiguration() throws Exception {
    importProject("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<build>" + "  <plugins>" + "    <plugin>" + "      <groupId>org.apache.maven.plugins</groupId>" + "      <artifactId>maven-compiler-plugin</artifactId>" + "      <executions>" + "        <execution>" + "          <id>default-compile</id>" + "             <configuration>" + "                <target>1.9</target>" + "             </configuration>" + "        </execution>" + "      </executions>" + "    </plugin>" + "  </plugins>" + "</build>");
    assertModules("project");
    Module module = getModule("project");
    String targetLevel = CompilerConfiguration.getInstance(myProject).getBytecodeTargetLevel(module);
    assertEquals("1.9", targetLevel);
}
Also used : Module(com.intellij.openapi.module.Module)

Example 54 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class ReimportingTest method testKeepingModuleGroups.

public void testKeepingModuleGroups() throws Exception {
    final Module m = getModule("project");
    new WriteCommandAction.Simple(myProject) {

        @Override
        protected void run() throws Throwable {
            ModifiableModuleModel model = ModuleManager.getInstance(myProject).getModifiableModel();
            model.setModuleGroupPath(m, new String[] { "group" });
            model.commit();
        }
    }.execute().throwException();
    importProject();
    assertModuleGroupPath("project", "group");
}
Also used : ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) Module(com.intellij.openapi.module.Module)

Example 55 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class Generator method exposeForm.

/**
   * @param rootContainer output parameter; should be LwRootContainer[1]
   */
public static FormProperty[] exposeForm(final Project project, final VirtualFile formFile, final LwRootContainer[] rootContainer) throws MyException {
    final Module module = ModuleUtil.findModuleForFile(formFile, project);
    LOG.assertTrue(module != null);
    final PsiPropertiesProvider propertiesProvider = new PsiPropertiesProvider(module);
    final Document doc = FileDocumentManager.getInstance().getDocument(formFile);
    final LwRootContainer _rootContainer;
    try {
        _rootContainer = Utils.getRootContainer(doc.getText(), propertiesProvider);
    } catch (AlienFormFileException e) {
        throw new MyException(e.getMessage());
    } catch (Exception e) {
        throw new MyException(UIDesignerBundle.message("error.cannot.process.form.file", e));
    }
    rootContainer[0] = _rootContainer;
    final String classToBind = _rootContainer.getClassToBind();
    if (classToBind == null) {
        throw new MyException(UIDesignerBundle.message("error.form.is.not.bound.to.a.class"));
    }
    final PsiClass boundClass = FormEditingUtil.findClassToBind(module, classToBind);
    if (boundClass == null) {
        throw new MyException(UIDesignerBundle.message("error.bound.class.does.not.exist", classToBind));
    }
    final ArrayList<FormProperty> result = new ArrayList<>();
    final MyException[] exception = new MyException[1];
    FormEditingUtil.iterate(_rootContainer, new FormEditingUtil.ComponentVisitor<LwComponent>() {

        public boolean visit(final LwComponent component) {
            final String binding = component.getBinding();
            if (binding == null) {
                return true;
            }
            final PsiField[] fields = boundClass.getFields();
            PsiField field = null;
            for (int i = fields.length - 1; i >= 0; i--) {
                if (binding.equals(fields[i].getName())) {
                    field = fields[i];
                    break;
                }
            }
            if (field == null) {
                exception[0] = new MyException(UIDesignerBundle.message("error.field.not.found.in.class", binding, classToBind));
                return false;
            }
            final PsiClass fieldClass = getClassByType(field.getType());
            if (fieldClass == null) {
                exception[0] = new MyException(UIDesignerBundle.message("error.invalid.binding.field.type", binding, classToBind));
                return false;
            }
            if (instanceOf(fieldClass, JTextComponent.class.getName())) {
                result.add(new FormProperty(component, "getText", "setText", String.class.getName()));
            } else if (instanceOf(fieldClass, JCheckBox.class.getName())) {
                result.add(new FormProperty(component, "isSelected", "setSelected", boolean.class.getName()));
            }
            return true;
        }
    });
    if (exception[0] != null) {
        throw exception[0];
    }
    return result.toArray(new FormProperty[result.size()]);
}
Also used : ArrayList(java.util.ArrayList) AlienFormFileException(com.intellij.uiDesigner.compiler.AlienFormFileException) LwRootContainer(com.intellij.uiDesigner.lw.LwRootContainer) Document(com.intellij.openapi.editor.Document) IncorrectOperationException(com.intellij.util.IncorrectOperationException) AlienFormFileException(com.intellij.uiDesigner.compiler.AlienFormFileException) LwComponent(com.intellij.uiDesigner.lw.LwComponent) Module(com.intellij.openapi.module.Module) PsiPropertiesProvider(com.intellij.uiDesigner.PsiPropertiesProvider) FormEditingUtil(com.intellij.uiDesigner.FormEditingUtil)

Aggregations

Module (com.intellij.openapi.module.Module)1893 VirtualFile (com.intellij.openapi.vfs.VirtualFile)585 Project (com.intellij.openapi.project.Project)379 NotNull (org.jetbrains.annotations.NotNull)330 Nullable (org.jetbrains.annotations.Nullable)267 File (java.io.File)185 PsiFile (com.intellij.psi.PsiFile)147 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)134 ArrayList (java.util.ArrayList)118 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)112 Sdk (com.intellij.openapi.projectRoots.Sdk)95 PsiElement (com.intellij.psi.PsiElement)89 PsiDirectory (com.intellij.psi.PsiDirectory)77 ModuleManager (com.intellij.openapi.module.ModuleManager)65 PsiClass (com.intellij.psi.PsiClass)65 IOException (java.io.IOException)61 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)57 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)57 List (java.util.List)57 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)51