use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class DomFileDescriptionTest method testChangeCustomDomness.
public void testChangeCustomDomness() throws Throwable {
getDomManager().registerFileDescription(new DomFileDescription<MyElement>(MyElement.class, "xxx") {
@Override
public boolean isMyFile(@NotNull final XmlFile file, @Nullable final Module module) {
return file.getText().contains("foo");
}
}, myDisposable);
final XmlFile file = (XmlFile) createFile("xxx.xml", "<xxx zzz=\"foo\"><boy/><boy/><xxx/>");
final MyElement boy = getDomManager().getFileElement(file, MyElement.class).getRootElement().getBoys().get(0);
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
file.getDocument().getRootTag().setAttribute("zzz", "bar");
}
}.execute();
assertFalse(getDomManager().isDomFile(file));
assertFalse(boy.isValid());
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class DomBasicsTest method testCopyingFromNonEmptyToEmpty.
public void testCopyingFromNonEmptyToEmpty() throws Throwable {
Module module = new MockModule(getTestRootDisposable());
final MyElement element1 = getDomManager().createMockElement(MyElement.class, module, false);
final MyElement element2 = getDomManager().createMockElement(MyElement.class, module, false);
element2.ensureTagExists();
assertNull(element2.getChild().getChild().getGenericValue().getStringValue());
element1.getChild().getChild().getGenericValue().setStringValue("abc");
new WriteCommandAction(getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
element2.copyFrom(element1);
}
}.execute();
assertEquals("abc", element2.getChild().getChild().getGenericValue().getStringValue());
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class XmlTagImpl method getImplicitNamespaceDescriptor.
@Nullable
private XmlNSDescriptor getImplicitNamespaceDescriptor(String ns) {
PsiFile file = getContainingFile();
if (file == null)
return null;
Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
for (ImplicitNamespaceDescriptorProvider provider : Extensions.getExtensions(ImplicitNamespaceDescriptorProvider.EP_NAME)) {
XmlNSDescriptor nsDescriptor = provider.getNamespaceDescriptor(module, ns, file);
if (nsDescriptor != null)
return nsDescriptor;
}
}
return null;
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class AntTasksProvider method getAntObjects.
private static Map<String, Class> getAntObjects(final GroovyFile groovyFile) {
final Project project = groovyFile.getProject();
final Module module = ModuleUtilCore.findModuleForPsiElement(groovyFile);
Set<VirtualFile> jars = new HashSet<>();
if (module != null) {
ContainerUtil.addAll(jars, OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots());
}
if (groovyFile.isScript() && GroovyScriptUtil.getScriptType(groovyFile) instanceof GantScriptType) {
jars.addAll(GantScriptType.additionalScopeFiles(groovyFile));
}
final ArrayList<URL> urls = new ArrayList<>();
for (VirtualFile jar : jars) {
VirtualFile localFile = PathUtil.getLocalFile(jar);
if (localFile.getFileSystem() instanceof LocalFileSystem) {
urls.add(VfsUtilCore.convertToURL(localFile.getUrl()));
}
}
AntClassLoader loader;
synchronized (ourLock) {
final Map<List<URL>, AntClassLoader> map = CachedValuesManager.getManager(project).getParameterizedCachedValue(project, KEY, PROVIDER, false, project);
loader = map.get(urls);
if (loader == null) {
map.put(urls, loader = new AntClassLoader(urls));
}
}
return loader.getAntObjects();
}
use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.
the class GantScriptType method additionalScopeFiles.
public static List<VirtualFile> additionalScopeFiles(@NotNull GroovyFile file) {
final Module module = ModuleUtilCore.findModuleForPsiElement(file);
if (module != null) {
final String sdkHome = GantUtils.getSdkHomeFromClasspath(module);
if (sdkHome != null) {
return Collections.emptyList();
}
}
final GantSettings gantSettings = GantSettings.getInstance(file.getProject());
final VirtualFile home = gantSettings.getSdkHome();
if (home == null) {
return Collections.emptyList();
}
return gantSettings.getClassRoots();
}
Aggregations