mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -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:
|
||||
* <p/>
|
||||
* <pre>
|
||||
@@ -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<LeafBlockWrapper> 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();
|
||||
|
||||
@@ -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<Usage[]> convertUsagesRef = new Ref<Usage[]>();
|
||||
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);
|
||||
|
||||
|
||||
@@ -45,13 +45,18 @@ public abstract class WeaksTestCase extends TestCase {
|
||||
|
||||
protected static void gc() {
|
||||
System.gc();
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
while (Runtime.getRuntime().freeMemory() > 10000) {
|
||||
list.add(new byte[1000]);
|
||||
}
|
||||
try {
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
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<Object> weakReference = new WeakReference<Object>(new Object());
|
||||
|
||||
@@ -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<AntDomTypeDef> getTypedefs();
|
||||
|
||||
@SubTagList("taskdef")
|
||||
public abstract List<AntDomTypeDef> getTaskdefs();
|
||||
|
||||
@SubTagList("macrodef")
|
||||
public abstract List<AntDomTypeDef> getMacrodefs();
|
||||
|
||||
@SubTagList("presetdef")
|
||||
public abstract List<AntDomTypeDef> getPresetdefs();
|
||||
|
||||
@SubTagList("scriptdef")
|
||||
public abstract List<AntDomTypeDef> getScriptdefs();
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,11 @@ public class AntDomExtender extends DomExtender<AntDomElement>{
|
||||
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<AntDomElement>{
|
||||
final CustomAntElementsRegistry registry = CustomAntElementsRegistry.getInstance(element.getAntProject());
|
||||
final Set<EvaluatedXmlName> result = new HashSet<EvaluatedXmlName>();
|
||||
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<AntDomElement>{
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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{
|
||||
}
|
||||
@@ -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{
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
}
|
||||
@@ -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{
|
||||
}
|
||||
@@ -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<XmlName, Class> myCustomElements = new HashMap<XmlName, Class>();
|
||||
private final Map<XmlName, String> myErrors = new HashMap<XmlName, String>();
|
||||
private final Map<XmlName, AntDomElement> myDeclarations = new HashMap<XmlName, AntDomElement>();
|
||||
private final Map<String, ClassLoader> myNamedLoaders = new HashMap<String, ClassLoader>();
|
||||
|
||||
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<URL> urls, final AntDomProject antProject) {
|
||||
private static ClassLoader createClassLoader(final List<URL> 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<URL> collectUrls(AntDomTypeDef typedef) {
|
||||
|
||||
@@ -197,8 +197,8 @@ public class EJavadocUtil {
|
||||
static void setupJavadocAttributes(Element orderEntry, LibraryOrderEntry libraryOrderEntry, final ModuleRootModel model) {
|
||||
final List<String> eclipseUrls = new ArrayList<String>();
|
||||
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));
|
||||
|
||||
+13
-1
@@ -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);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="var" path="variable/test.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="jar:file:/$ROOT$/srcvariableidea1/test.jar!/" />
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="bin" />
|
||||
</classpath>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component>
|
||||
<exclude-output />
|
||||
<contentEntry url="file://$MODULE_DIR$" />
|
||||
<lib name="test.jar" scope="COMPILE">
|
||||
<javadocroot_attr url="jar://$MODULE_DIR$/../srcvariableidea11/test.jar!/" />
|
||||
</lib>
|
||||
</component>
|
||||
BIN
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="var" path="variable/test.jar"/>
|
||||
<classpathentry kind="output" path="bin" />
|
||||
</classpath>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ws-internals</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
BIN
Binary file not shown.
+16
-2
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user