use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-plugins by JetBrains.
the class FacetDetectionTest method testDetectBundlorFacet.
@Test
public void testDetectBundlorFacet() {
ModuleManager moduleManager = ModuleManager.getInstance(myFixture.getProject());
Module t2 = moduleManager.findModuleByName("t2");
assertNotNull(t2);
OsmorcFrameworkDetector detector = new OsmorcFrameworkDetector();
ElementPattern<FileContent> filter = detector.createSuitableFilePattern();
VirtualFile manifestFile = myTempDirFixture.getFile("t2/src/META-INF/template.mf");
assertThat(filter.accepts(FileContentImpl.createByFile(manifestFile)), equalTo(true));
OsmorcFacetConfiguration facetConfiguration = detector.createConfiguration(Collections.singletonList(manifestFile));
assertNotNull(facetConfiguration);
assertThat(facetConfiguration.getManifestLocation(), equalTo(manifestFile.getPath()));
assertThat(facetConfiguration.isUseProjectDefaultManifestFileLocation(), equalTo(false));
OsmorcFacet facet = OsmorcFacetType.getInstance().createFacet(t2, "OSGi", facetConfiguration, null);
ModifiableRootModel model = ModuleRootManager.getInstance(t2).getModifiableModel();
try {
detector.setupFacet(facet, model);
assertThat(facetConfiguration.getManifestLocation(), equalTo(""));
assertThat(facetConfiguration.getBundlorFileLocation(), equalTo("src/META-INF/template.mf"));
assertThat(facetConfiguration.isUseBundlorFile(), equalTo(true));
} finally {
model.dispose();
}
}
use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-plugins by JetBrains.
the class FacetDetectionTest method testDetectFacet.
@Test
public void testDetectFacet() {
Module t0 = ModuleManager.getInstance(myFixture.getProject()).findModuleByName("t0");
assertNotNull(t0);
OsmorcFrameworkDetector detector = new OsmorcFrameworkDetector();
ElementPattern<FileContent> filter = detector.createSuitableFilePattern();
VirtualFile manifestFile = myTempDirFixture.getFile("t0/src/META-INF/MANIFEST.MF");
assertThat(filter.accepts(FileContentImpl.createByFile(manifestFile)), equalTo(true));
OsmorcFacetConfiguration facetConfiguration = detector.createConfiguration(Collections.singletonList(manifestFile));
assertNotNull(facetConfiguration);
assertThat(facetConfiguration.getManifestLocation(), equalTo(manifestFile.getPath()));
assertThat(facetConfiguration.isUseProjectDefaultManifestFileLocation(), equalTo(false));
OsmorcFacet facet = OsmorcFacetType.getInstance().createFacet(t0, "OSGi", facetConfiguration, null);
ModifiableRootModel model = ModuleRootManager.getInstance(t0).getModifiableModel();
try {
detector.setupFacet(facet, model);
assertThat(facetConfiguration.getManifestLocation(), equalTo("src/META-INF/MANIFEST.MF"));
} finally {
model.dispose();
}
}
use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-plugins by JetBrains.
the class DartProjectGenerator method generateProject.
@Override
public final void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir, @NotNull final DartProjectWizardData data, @NotNull final Module module) {
ApplicationManager.getApplication().runWriteAction(() -> {
final ModifiableRootModel modifiableModel = ModifiableModelsProvider.SERVICE.getInstance().getModuleModifiableModel(module);
DartModuleBuilder.setupProject(modifiableModel, baseDir, data);
ModifiableModelsProvider.SERVICE.getInstance().commitModuleModifiableModel(modifiableModel);
});
}
use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-plugins by JetBrains.
the class VFSUtilTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final File dir = createTempDirectory();
updateRoots(new Updater() {
@Override
public void update(ModifiableRootModel modifiableModel) {
myContentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
try {
VirtualFile src = myContentRoot.createChildDirectory(this, "src");
myContentEntry = modifiableModel.addContentEntry(myContentRoot);
myContentEntry.addSourceFolder(src, false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject());
myContentRoot = rootManager.getContentRoots()[0];
mySourceRoot = rootManager.getContentSourceRoots()[0];
VFSUtil._setProject(getProject());
}
use of com.intellij.openapi.roots.ModifiableRootModel in project intellij-plugins by JetBrains.
the class VFSUtilTest method updateRoots.
private void updateRoots(final Updater updater) {
ApplicationManager.getApplication().runWriteAction(() -> {
try {
ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(getModule()).getModifiableModel();
updater.update(modifiableModel);
modifiableModel.commit();
} catch (Throwable e) {
throw new RuntimeException(e);
}
});
}
Aggregations