use of org.jetbrains.lang.manifest.psi.ManifestFile in project intellij-plugins by JetBrains.
the class OsgiManifestPsiTest method testBundleReference.
public void testBundleReference() {
ManifestFile file = createFile("Require-Bundle: org.apache.felix.framework\n");
PsiReference ref = file.findReferenceAt(16);
assertNotNull(ref);
PsiElement target = ref.resolve();
assertTrue(String.valueOf(target), target instanceof Header);
assertEquals("Bundle-SymbolicName", ((Header) target).getName());
}
use of org.jetbrains.lang.manifest.psi.ManifestFile in project intellij-plugins by JetBrains.
the class OsgiPsiUtilTest method doTest.
private void doTest(String original, String expected, final boolean replace) {
myFixture.configureByText("MANIFEST.MF", original);
WriteCommandAction.runWriteCommandAction(null, () -> {
ManifestFile manifestFile = (ManifestFile) myFixture.getFile();
if (replace) {
OsgiPsiUtil.setHeader(manifestFile, "TestHeader", "TestValue");
} else {
OsgiPsiUtil.appendToHeader(manifestFile, "TestHeader", "TestValue");
}
});
myFixture.checkResult(expected);
}
use of org.jetbrains.lang.manifest.psi.ManifestFile in project intellij-plugins by JetBrains.
the class BundleManifestCache method getManifest.
@Nullable
public BundleManifest getManifest(@NotNull Module module) {
OsmorcFacet facet = OsmorcFacet.getInstance(module);
if (facet == null)
return null;
CachedValue<BundleManifest> value = myCache.get(facet);
if (value == null) {
value = myManager.createCachedValue(() -> {
OsmorcFacetConfiguration configuration = facet.getConfiguration();
BundleManifest manifest = null;
List<Object> dependencies = ContainerUtil.newSmartList(configuration);
switch(configuration.getManifestGenerationMode()) {
case Manually:
{
PsiFile manifestFile = findInModuleRoots(facet.getModule(), configuration.getManifestLocation());
if (manifestFile instanceof ManifestFile) {
manifest = readManifest((ManifestFile) manifestFile);
dependencies.add(manifestFile);
} else {
dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
}
break;
}
case OsmorcControlled:
{
Map<String, String> map = ContainerUtil.newHashMap(configuration.getAdditionalPropertiesAsMap());
map.put(Constants.BUNDLE_SYMBOLICNAME, configuration.getBundleSymbolicName());
map.put(Constants.BUNDLE_VERSION, configuration.getBundleVersion());
map.put(Constants.BUNDLE_ACTIVATOR, configuration.getBundleActivator());
manifest = new BundleManifest(map);
break;
}
case Bnd:
{
PsiFile bndFile = findInModuleRoots(facet.getModule(), configuration.getBndFileLocation());
if (bndFile != null) {
manifest = readProperties(bndFile);
dependencies.add(bndFile);
} else {
dependencies.add(PsiModificationTracker.MODIFICATION_COUNT);
}
break;
}
case Bundlor:
// not supported
break;
}
return CachedValueProvider.Result.create(manifest, dependencies);
}, false);
myCache.put(facet, value);
}
return value.getValue();
}
Aggregations