diff --git a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
index dc155a59b4c6..bc8d78d106d9 100644
--- a/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
+++ b/platform/lang-impl/src/com/intellij/formatting/FormatProcessor.java
@@ -44,7 +44,7 @@ class FormatProcessor {
private final CodeStyleSettings mySettings;
/**
- * Remembers mappings between backward-shifted aligned block and blocks that cause that shift in order to detected
+ * Remembers mappings between backward-shifted aligned block and blocks that cause that shift in order to detect
* infinite cycles that may occur when, for example following alignment is specified:
*
*
@@ -527,6 +527,13 @@ class FormatProcessor {
return true;
}
+ // Note that we can't just put this check at the method start because at least adjustSpacingByIndentOffset() may perform
+ // block states modification (e.g. define new value for 'allow to use first child indent as block indent' flag).
+ if (offsetResponsibleBlock.getWhiteSpace().isIsReadOnly()) {
+ // We're unable to perform backward shift because white space for the target element is read-only.
+ return true;
+ }
+
// There is a possible case that alignment options are defined incorrectly. Consider the following example:
// int i1;
// int i2, i3;
@@ -538,9 +545,10 @@ class FormatProcessor {
Set blocksCausedRealignment = myBackwardShiftedAlignedBlocks.get(offsetResponsibleBlock);
if (blocksCausedRealignment != null && blocksCausedRealignment.contains(myCurrentBlock)) {
LOG.error(String.format("Formatting error - code block %s is set to be shifted right because of its alignment with "
- + "block %s more than once. I.e. moving the former block because of alignment algo causes "
+ + "block %s more than once. I.e. moving the former block because of alignment algorithm causes "
+ "subsequent block to be shifted right as well - cyclic dependency",
offsetResponsibleBlock.getTextRange(), myCurrentBlock.getTextRange()));
+ blocksCausedRealignment.add(myCurrentBlock);
return true;
}
myBackwardShiftedAlignedBlocks.clear();
diff --git a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
index a1dd93f35073..cacf6cf002bb 100644
--- a/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
+++ b/platform/lang-impl/src/com/intellij/refactoring/BaseRefactoringProcessor.java
@@ -308,7 +308,17 @@ public abstract class BaseRefactoringProcessor {
final PsiElement[] initialElements = viewDescriptor.getElements();
final UsageTarget[] targets = PsiElement2UsageTargetAdapter.convert(initialElements);
- final Usage[] usages = UsageInfo2UsageAdapter.convert(usageInfos);
+ final Ref convertUsagesRef = new Ref();
+ if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
+ @Override
+ public void run() {
+ convertUsagesRef.set(UsageInfo2UsageAdapter.convert(usageInfos));
+ }
+ }, "Preprocess usages", true, myProject)) return;
+
+ if (convertUsagesRef.isNull()) return;
+
+ final Usage[] usages = convertUsagesRef.get();
final UsageViewPresentation presentation = createPresentation(viewDescriptor, usages);
diff --git a/platform/util/testSrc/com/intellij/util/containers/WeaksTestCase.java b/platform/util/testSrc/com/intellij/util/containers/WeaksTestCase.java
index 9d88ab2989ab..6f426d0e7a16 100644
--- a/platform/util/testSrc/com/intellij/util/containers/WeaksTestCase.java
+++ b/platform/util/testSrc/com/intellij/util/containers/WeaksTestCase.java
@@ -45,13 +45,18 @@ public abstract class WeaksTestCase extends TestCase {
protected static void gc() {
System.gc();
- List list = new ArrayList();
- while (Runtime.getRuntime().freeMemory() > 10000) {
- list.add(new byte[1000]);
- }
+ try {
+ List list = new ArrayList();
+ while (Runtime.getRuntime().freeMemory() > 10000) {
+ list.add(new byte[1000]);
+ }
- System.gc();
- list = null;
+ System.gc();
+ list = null;
+ }
+ catch (OutOfMemoryError e) {
+ // ignore
+ }
System.gc();
WeakReference weakReference = new WeakReference(new Object());
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomAntlib.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomAntlib.java
new file mode 100644
index 000000000000..60d59c70ab64
--- /dev/null
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomAntlib.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang.ant.dom;
+
+import com.intellij.util.xml.SubTagList;
+
+import java.util.List;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Jul 8, 2010
+ */
+public abstract class AntDomAntlib extends AntDomElement{
+
+ @SubTagList("typedef")
+ public abstract List getTypedefs();
+
+ @SubTagList("taskdef")
+ public abstract List getTaskdefs();
+
+ @SubTagList("macrodef")
+ public abstract List getMacrodefs();
+
+ @SubTagList("presetdef")
+ public abstract List getPresetdefs();
+
+ @SubTagList("scriptdef")
+ public abstract List getScriptdefs();
+}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomCustomElement.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomCustomElement.java
index f852c9e02284..d0c23b7d8751 100644
--- a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomCustomElement.java
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomCustomElement.java
@@ -27,7 +27,7 @@ public abstract class AntDomCustomElement extends AntDomElement{
@Nullable
public final Class getDefinitionClass() {
final String name = getXmlElementName();
- final String nsKey = getXmlElementNamespaceKey();
+ final String nsKey = getXmlElementNamespace();
return CustomAntElementsRegistry.getInstance(getAntProject()).lookupClass(new XmlName(name, nsKey));
}
}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomExtender.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomExtender.java
index 869cfc14fad1..26888f508b99 100644
--- a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomExtender.java
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomExtender.java
@@ -45,7 +45,11 @@ public class AntDomExtender extends DomExtender{
TAG_MAPPING.put("path", AntDomPath.class);
TAG_MAPPING.put("classpath", AntDomPath.class);
TAG_MAPPING.put("typedef", AntDomTypeDef.class);
- TAG_MAPPING.put("taskdef", AntDomTypeDef.class);
+ TAG_MAPPING.put("taskdef", AntDomTaskdef.class);
+ TAG_MAPPING.put("presetdef", AntDomPresetDef.class);
+ TAG_MAPPING.put("macrodef", AntDomMacroDef.class);
+ TAG_MAPPING.put("scriptdef", AntDomScriptDef.class);
+ TAG_MAPPING.put("antlib", AntDomAntlib.class);
}
public void registerExtensions(@NotNull AntDomElement antDomElement, @NotNull DomExtensionsRegistrar registrar) {
@@ -217,7 +221,8 @@ public class AntDomExtender extends DomExtender{
final CustomAntElementsRegistry registry = CustomAntElementsRegistry.getInstance(element.getAntProject());
final Set result = new HashSet();
for (XmlName variant : registry.getCompletionVariants(element)) {
- result.add(new DummyEvaluatedXmlName(variant, null));
+ final String ns = variant.getNamespaceKey();
+ result.add(new DummyEvaluatedXmlName(variant, ns != null? ns : ""));
}
return result;
}
@@ -230,7 +235,7 @@ public class AntDomExtender extends DomExtender{
@Nullable
public PomTarget findDeclaration(@NotNull DomElement child) {
- XmlName name = new XmlName(child.getXmlElementName(), child.getXmlElementNamespaceKey());
+ XmlName name = new XmlName(child.getXmlElementName(), child.getXmlElementNamespace());
return doFindDeclaration(child.getParent(), name);
}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomMacroDef.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomMacroDef.java
new file mode 100644
index 000000000000..d3d7847e0711
--- /dev/null
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomMacroDef.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang.ant.dom;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Jul 8, 2010
+ */
+public abstract class AntDomMacroDef extends AntDomNamedElement{
+}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPresetDef.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPresetDef.java
new file mode 100644
index 000000000000..837554569d29
--- /dev/null
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomPresetDef.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang.ant.dom;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Jul 8, 2010
+ */
+public abstract class AntDomPresetDef extends AntDomNamedElement{
+}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomRecursiveVisitor.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomRecursiveVisitor.java
index f92c6ec73089..d11992356fb3 100644
--- a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomRecursiveVisitor.java
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomRecursiveVisitor.java
@@ -36,6 +36,22 @@ public class AntDomRecursiveVisitor implements DomElementVisitor{
visitAntDomElement(typedef);
}
+ public void visitTaskDef(AntDomTaskdef typedef) {
+ visitTypeDef(typedef);
+ }
+
+ public void visitMacroDef(AntDomMacroDef macrodef) {
+ visitAntDomElement(macrodef);
+ }
+
+ public void visitPresetDef(AntDomPresetDef presetdef) {
+ visitAntDomElement(presetdef);
+ }
+
+ public void visitScriptDef(AntDomScriptDef scriptdef) {
+ visitAntDomElement(scriptdef);
+ }
+
public void visitTarget(AntDomTarget target) {
visitAntDomElement(target);
}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomScriptDef.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomScriptDef.java
new file mode 100644
index 000000000000..adf423331bac
--- /dev/null
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomScriptDef.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang.ant.dom;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Jul 8, 2010
+ */
+public abstract class AntDomScriptDef extends AntDomNamedElement{
+}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/AntDomTaskdef.java b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomTaskdef.java
new file mode 100644
index 000000000000..53dd264a8cbc
--- /dev/null
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/AntDomTaskdef.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2000-2010 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang.ant.dom;
+
+/**
+ * @author Eugene Zhuravlev
+ * Date: Jul 8, 2010
+ */
+public abstract class AntDomTaskdef extends AntDomTypeDef{
+}
diff --git a/plugins/ant/src/com/intellij/lang/ant/dom/CustomAntElementsRegistry.java b/plugins/ant/src/com/intellij/lang/ant/dom/CustomAntElementsRegistry.java
index 1f7d59d2b03d..dcdfe8a7e1e6 100644
--- a/plugins/ant/src/com/intellij/lang/ant/dom/CustomAntElementsRegistry.java
+++ b/plugins/ant/src/com/intellij/lang/ant/dom/CustomAntElementsRegistry.java
@@ -26,6 +26,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
@@ -59,10 +60,13 @@ public class CustomAntElementsRegistry {
private final Map myCustomElements = new HashMap();
private final Map myErrors = new HashMap();
private final Map myDeclarations = new HashMap();
+ private final Map myNamedLoaders = new HashMap();
private CustomAntElementsRegistry(final AntDomProject antProject) {
antProject.accept(new BaseVisitor() {
public void visitTypeDef(AntDomTypeDef typedef) {
+ // if loaderRef attribute is specified, make sure the loader is built and stored
+ rememberNamedClassLoader(typedef, antProject);
defineCustomElements(typedef, antProject);
}
});
@@ -126,12 +130,11 @@ public class CustomAntElementsRegistry {
private void defineCustomElements(AntDomTypeDef typedef, final AntDomProject antProject) {
final String uri = typedef.getUri().getStringValue();
- final String nsPrefix = (uri == null) ? null : typedef.getXmlTag().getPrefixByNamespace(uri);
final String customTagName = typedef.getName().getStringValue();
final String classname = typedef.getClassName().getStringValue();
if (classname != null && customTagName != null) {
- registerElement(typedef, customTagName, nsPrefix, classname, getClassLoader(collectUrls(typedef), antProject));
+ registerElement(typedef, customTagName, uri, classname, getClassLoader(typedef, antProject));
}
else {
final XmlElement xmlElement = antProject.getXmlElement();
@@ -139,11 +142,11 @@ public class CustomAntElementsRegistry {
if (project != null) {
final String resource = typedef.getResource().getStringValue();
if (resource != null) {
- final ClassLoader loader = getClassLoader(collectUrls(typedef), antProject);
+ final ClassLoader loader = getClassLoader(typedef, antProject);
if (loader != null) {
final InputStream stream = loader.getResourceAsStream(resource);
if (stream != null) {
- loadFromStream(typedef, nsPrefix, resource, loader, stream, project);
+ loadFromStream(typedef, uri, resource, loader, stream, project);
}
}
}
@@ -155,7 +158,7 @@ public class CustomAntElementsRegistry {
try {
final InputStream stream = vf.getInputStream();
if (stream != null) {
- loadFromStream(typedef, nsPrefix, file.getName(), getClassLoader(collectUrls(typedef), antProject), stream, project);
+ loadFromStream(typedef, uri, file.getName(), getClassLoader(typedef, antProject), stream, project);
}
}
catch (IOException e) {
@@ -168,6 +171,24 @@ public class CustomAntElementsRegistry {
}
}
+ private void rememberNamedClassLoader(AntDomTypeDef typedef, AntDomProject antProject) {
+ final String loaderRef = typedef.getLoaderRef().getStringValue();
+ if (loaderRef != null) {
+ if (!myNamedLoaders.containsKey(loaderRef)) {
+ myNamedLoaders.put(loaderRef, createClassLoader(collectUrls(typedef), antProject));
+ }
+ }
+ }
+
+ @Nullable
+ private ClassLoader getClassLoader(AntDomTypeDef typedef, AntDomProject antProject) {
+ final String loaderRef = typedef.getLoaderRef().getStringValue();
+ if (loaderRef != null && myNamedLoaders.containsKey(loaderRef)) {
+ return myNamedLoaders.get(loaderRef);
+ }
+ return createClassLoader(collectUrls(typedef), antProject);
+ }
+
private void loadFromStream(AntDomTypeDef typedef, String nsPrefix, String resource, ClassLoader loader, InputStream stream, final Project project) {
if (isXmlFormat(typedef, resource)) {
// todo
@@ -199,56 +220,53 @@ public class CustomAntElementsRegistry {
}
}
- //static void loadAntlibStream(@NotNull final InputStream antlibStream, final String nsPrefix, Project project) {
- // final StringBuilder builder = StringBuilderSpinAllocator.alloc();
- // try {
- // int nextByte;
- // while ((nextByte = antlibStream.read()) >= 0) {
- // builder.append((char)nextByte);
- // }
- // antlibStream.close();
- // final XmlFile xmlFile = (XmlFile)createDummyFile("dummy.xml", StdFileTypes.XML, builder, project);
- // final XmlDocument document = xmlFile.getDocument();
- // if (document != null) {
- // final XmlTag rootTag = document.getRootTag();
- // if (rootTag == null) return;
- // for (final XmlTag tag : rootTag.getSubTags()) {
- // if (nsPrefix != null && nsPrefix.length() > 0) {
- // try {
- // tag.setName(nsPrefix + ':' + tag.getLocalName());
- // }
- // catch (IncorrectOperationException e) {
- // continue;
- // }
- // }
- // final AntElement newElement = AntElementFactory.createAntElement(element, tag);
- // if (newElement instanceof AntTypeDef) {
- // for (final AntTypeDefinition def : ((AntTypeDef)newElement).getDefinitions()) {
- // if (element instanceof AntTypeDefImpl) {
- // final AntTypeDefImpl td = ((AntTypeDefImpl)element);
- // final AntTypeDefinition[] defs = td.myNewDefinitions != null ? td.myNewDefinitions : AntTypeDefinition.EMPTY_ARRAY;
- // td.myNewDefinitions = ArrayUtil.append(defs, def);
- // ((AntTypeDefinitionImpl)def).setDefiningElement(td);
- // }
- // }
- // }
- // }
- // }
- // }
- // catch (IOException e) {
- // if (element instanceof AntTypeDefImpl) {
- // final AntTypeDefImpl td = ((AntTypeDefImpl)element);
- // td.myClassesLoaded = false;
- // td.myLocalizedError = e.getLocalizedMessage();
- // }
- // }
- // finally {
- // StringBuilderSpinAllocator.dispose(builder);
- // }
- //}
+ /*
+ static void loadAntlibStream(@NotNull final InputStream antlibStream, final String nsPrefix, Project project) {
+ final StringBuilder builder = StringBuilderSpinAllocator.alloc();
+ try {
+ int nextByte;
+ while ((nextByte = antlibStream.read()) >= 0) {
+ builder.append((char)nextByte);
+ }
+ antlibStream.close();
+ final XmlFile xmlFile = (XmlFile)createDummyFile("dummy.xml", StdFileTypes.XML, builder, project);
+ final XmlDocument document = xmlFile.getDocument();
+ if (document != null) {
+ final XmlTag rootTag = document.getRootTag();
+ if (rootTag == null) return;
+ for (final XmlTag tag : rootTag.getSubTags()) {
+ if (nsPrefix != null && nsPrefix.length() > 0) {
+ try {
+ tag.setName(nsPrefix + ':' + tag.getLocalName());
+ }
+ catch (IncorrectOperationException e) {
+ continue;
+ }
+ }
+ final AntElement newElement = AntElementFactory.createAntElement(element, tag);
+ if (newElement instanceof AntTypeDef) {
+ for (final AntTypeDefinition def : ((AntTypeDef)newElement).getDefinitions()) {
+ if (element instanceof AntTypeDefImpl) {
+ final AntTypeDefImpl td = ((AntTypeDefImpl)element);
+ final AntTypeDefinition[] defs = td.myNewDefinitions != null ? td.myNewDefinitions : AntTypeDefinition.EMPTY_ARRAY;
+ td.myNewDefinitions = ArrayUtil.append(defs, def);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (IOException e) {
+ LOG.info(e);
+ }
+ finally {
+ StringBuilderSpinAllocator.dispose(builder);
+ }
+ }
+ */
- private void registerElement(AntDomTypeDef typedef, String customTagName, String nsPrefix, String classname, ClassLoader loader) {
+ private void registerElement(AntDomTypeDef typedef, String customTagName, String nsUri, String classname, ClassLoader loader) {
Class clazz = null;
String error = "";
try {
@@ -266,7 +284,7 @@ public class CustomAntElementsRegistry {
error = e.getMessage();
clazz = null;
}
- final XmlName xmlName = (nsPrefix == null) ? new XmlName(customTagName) : new XmlName(customTagName, nsPrefix);
+ final XmlName xmlName = new XmlName(customTagName, nsUri == null? "" : nsUri);
if (clazz != null) {
myCustomElements.put(xmlName, clazz);
myDeclarations.put(xmlName, typedef);
@@ -283,26 +301,18 @@ public class CustomAntElementsRegistry {
private static boolean isXmlFormat(AntDomTypeDef typedef, @NotNull final String resourceOrFileName) {
final String format = typedef.getFormat().getStringValue();
if (format != null) {
- return format.equals("xml");
+ return "xml".equalsIgnoreCase(format);
}
- return resourceOrFileName.endsWith(".xml");
+ return StringUtil.endsWithIgnoreCase(resourceOrFileName, ".xml");
}
@Nullable
- private static ClassLoader getClassLoader(final List urls, final AntDomProject antProject) {
+ private static ClassLoader createClassLoader(final List urls, final AntDomProject antProject) {
final ClassLoader parentLoader = antProject.getClassLoader();
if (urls.size() == 0) {
return parentLoader;
}
-
- //final ClassLoader cached = LOADERS_CACHE.getClassLoader(urls);
- //if (cached != null && parentLoader == cached.getParent()) {
- // return cached;
- //}
-
- final ClassLoader loader = new AntResourcesClassLoader(urls, parentLoader, false, false);
- //LOADERS_CACHE.setClassLoader(urls, loader);
- return loader;
+ return new AntResourcesClassLoader(urls, parentLoader, false, false);
}
private static List collectUrls(AntDomTypeDef typedef) {
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java
index b48d3c843f7c..9c9e94bb7607 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EJavadocUtil.java
@@ -197,8 +197,8 @@ public class EJavadocUtil {
static void setupJavadocAttributes(Element orderEntry, LibraryOrderEntry libraryOrderEntry, final ModuleRootModel model) {
final List eclipseUrls = new ArrayList();
final String[] docUrls = libraryOrderEntry.getRootUrls(JavadocOrderRootType.getInstance());
- for (String docUrl : docUrls) {
- eclipseUrls.add(toEclipseJavadocPath(model, docUrl));
+ if (docUrls.length > 0) {
+ eclipseUrls.add(toEclipseJavadocPath(model, docUrls[0]));
}
final List children = new ArrayList(orderEntry.getChildren(ATTRIBUTES_TAG));
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java
index c98af4013422..995ecb8ff26e 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java
@@ -64,6 +64,7 @@ public class IdeaSpecificSettings {
@NonNls private static final String SRCROOT_ATTR = "srcroot";
private static final Logger LOG = Logger.getInstance("#" + IdeaSpecificSettings.class.getName());
+ @NonNls private static final String JAVADOCROOT_ATTR = "javadocroot_attr";
private IdeaSpecificSettings() {
}
@@ -106,6 +107,10 @@ public class IdeaSpecificSettings {
appendLibraryScope(model, libElement, libraryByName);
final Library.ModifiableModel modifiableModel = libraryByName.getModifiableModel();
replaceCollapsedByEclipseSourceRoots(libElement, modifiableModel);
+ for (Object r : libElement.getChildren(JAVADOCROOT_ATTR)) {
+ final String url = ((Element)r).getAttributeValue("url");
+ modifiableModel.addRoot(url, JavadocOrderRootType.getInstance());
+ }
replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.SOURCES, RELATIVE_MODULE_SRC);
replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.CLASSES, RELATIVE_MODULE_CLS);
replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, JavadocOrderRootType.getInstance(), RELATIVE_MODULE_JAVADOC);
@@ -176,7 +181,7 @@ public class IdeaSpecificSettings {
final CompilerModuleExtension compilerModuleExtension = model.getModuleExtension(CompilerModuleExtension.class);
- if (compilerModuleExtension.getCompilerOutputPathForTests() != null) {
+ if (compilerModuleExtension.getCompilerOutputUrlForTests() != null) {
final Element pathElement = new Element(IdeaXml.OUTPUT_TEST_TAG);
pathElement.setAttribute(IdeaXml.URL_ATTR, compilerModuleExtension.getCompilerOutputUrlForTests());
root.addContent(pathElement);
@@ -248,6 +253,13 @@ public class IdeaSpecificSettings {
element.addContent(srcElement);
}
+ final String[] javadocUrls = libraryEntry.getRootUrls(JavadocOrderRootType.getInstance());
+ for (int i = 1; i < javadocUrls.length; i++) {
+ Element javadocElement = new Element(JAVADOCROOT_ATTR);
+ javadocElement.setAttribute("url", javadocUrls[i]);
+ element.addContent(javadocElement);
+ }
+
for (String srcUrl : libraryEntry.getRootUrls(OrderRootType.SOURCES)) {
appendModuleRelatedRoot(element, srcUrl, RELATIVE_MODULE_SRC, model);
}
diff --git a/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/expected/.classpath b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/expected/.classpath
new file mode 100644
index 000000000000..4b571b36ea65
--- /dev/null
+++ b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/expected/.classpath
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/expected/ws-internals.eml b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/expected/ws-internals.eml
new file mode 100644
index 000000000000..7dfadd07d41e
--- /dev/null
+++ b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/expected/ws-internals.eml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/srcvariableidea1/test.jar b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/srcvariableidea1/test.jar
new file mode 100644
index 000000000000..69d35ecffe38
Binary files /dev/null and b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/srcvariableidea1/test.jar differ
diff --git a/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/test/.classpath b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/test/.classpath
new file mode 100644
index 000000000000..f62ed8d1c84a
--- /dev/null
+++ b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/test/.classpath
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/test/.project b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/test/.project
new file mode 100644
index 000000000000..3c7030a86519
--- /dev/null
+++ b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/test/.project
@@ -0,0 +1,17 @@
+
+
+ ws-internals
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/variableidea/test.jar b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/variableidea/test.jar
new file mode 100644
index 000000000000..69d35ecffe38
Binary files /dev/null and b/plugins/eclipse/testData/modification/replacedExistingWithMultipleJavadocs/variableidea/test.jar differ
diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLibrariesModificationsTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLibrariesModificationsTest.java
index 15a431bc6764..a18977e3d81d 100644
--- a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLibrariesModificationsTest.java
+++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLibrariesModificationsTest.java
@@ -22,6 +22,7 @@ package org.jetbrains.idea.eclipse;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.JavadocOrderRootType;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.OrderRootType;
@@ -74,10 +75,15 @@ public class EclipseLibrariesModificationsTest extends EclipseVarsTest {
}
public void testReplacedExistingWithVariablesCantReplaceSrc() throws Exception {
- doTestExisting(new String[]{"/variableidea/test.jar!/"}, new String[]{"/srcvariableidea1/test.jar!/"});
+ doTestExisting(new String[]{"/variableidea/test.jar!/"}, new String[]{"/srcvariableidea1/test.jar!/"}, new String[0]);
}
- private void doTestExisting(String[] classRoots, String[] sourceRoots) throws Exception {
+ public void testReplacedExistingWithMultipleJavadocs() throws Exception {
+ doTestExisting(new String[]{"/variableidea/test.jar!/"}, new String[]{},
+ new String[]{"/srcvariableidea1/test.jar!/", "/srcvariableidea11/test.jar!/"});
+ }
+
+ private void doTestExisting(String[] classRoots, String[] sourceRoots, String[] javadocs) throws Exception {
final Project project = getProject();
final String path = project.getBaseDir().getPath() + "/test";
final Module module = EclipseClasspathTest.setUpModule(path, project);
@@ -94,11 +100,19 @@ public class EclipseLibrariesModificationsTest extends EclipseVarsTest {
for (String oldSrcRoot : oldSrcRoots) {
libModifiableModel.removeRoot(oldSrcRoot, OrderRootType.SOURCES);
}
+
+ final String[] oldJdcRoots = libModifiableModel.getUrls(JavadocOrderRootType.getInstance());
+ for (String oldJavadocRoot : oldJdcRoots) {
+ libModifiableModel.removeRoot(oldJavadocRoot, JavadocOrderRootType.getInstance());
+ }
for (String classRoot : classRoots) {
libModifiableModel.addRoot(parentUrl + classRoot, OrderRootType.CLASSES);
}
for (String sourceRoot : sourceRoots) {
libModifiableModel.addRoot(parentUrl + sourceRoot, OrderRootType.SOURCES);
+ }
+ for (String javadocRoot : javadocs) {
+ libModifiableModel.addRoot(parentUrl + javadocRoot, JavadocOrderRootType.getInstance());
}
libModifiableModel.commit();
model.commit();
diff --git a/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java b/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java
index 38f6f51d89b9..a5c8b06681d4 100644
--- a/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java
+++ b/xml/dom-impl/src/com/intellij/xml/impl/dom/AbstractDomChildrenDescriptor.java
@@ -48,10 +48,18 @@ public abstract class AbstractDomChildrenDescriptor implements XmlElementDescrip
final CustomDomChildrenDescription customDescription = domElement.getGenericInfo().getCustomNameChildrenDescription();
if (customDescription != null) {
+ final XmlTag xmlTag = domElement.getXmlTag();
for (final EvaluatedXmlName name : customDescription.getTagNameDescriptor().getCompletionVariants(domElement)) {
xmlElementDescriptors.add(new AbstractDomChildrenDescriptor(myManager) {
@Override
public String getDefaultName() {
+ final String ns = xmlTag != null? name.getNamespace(xmlTag, (XmlFile)xmlTag.getContainingFile()) : null;
+ if (ns != null) {
+ final String prefix = xmlTag.getPrefixByNamespace(ns);
+ if (prefix != null) {
+ return prefix + ":" + name.getXmlName().getLocalName();
+ }
+ }
return name.getXmlName().getLocalName();
}