diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java index b2ba34dd8ddf..cac162a388e5 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesArtifactIdConverter.java @@ -15,8 +15,24 @@ */ package org.jetbrains.idea.maven.dom.converters; +import com.intellij.codeInsight.completion.CompletionType; +import com.intellij.codeInsight.completion.InsertHandler; +import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.codeInsight.lookup.LookupElementBuilder; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiElement; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; import com.intellij.util.xml.ConvertContext; +import com.intellij.util.xml.DomElement; +import com.intellij.util.xml.DomManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.dom.model.MavenDomArtifactCoordinates; +import org.jetbrains.idea.maven.dom.model.MavenDomDependency; import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager; import org.jetbrains.idea.maven.model.MavenArtifact; import org.jetbrains.idea.maven.model.MavenId; @@ -46,9 +62,85 @@ public class MavenArtifactCoordinatesArtifactIdConverter extends MavenArtifactCo return false; } + @Nullable + @Override + public LookupElement createLookupElement(String s) { + LookupElementBuilder res = LookupElementBuilder.create(s); + res = res.withInsertHandler(MavenArtifactInsertHandler.INSTANCE); + return res; + } + @Override protected Set doGetVariants(MavenId id, MavenProjectIndicesManager manager) { if (StringUtil.isEmptyOrSpaces(id.getGroupId())) return Collections.emptySet(); return manager.getArtifactIds(id.getGroupId()); } + + private static class MavenArtifactInsertHandler implements InsertHandler { + + public static final InsertHandler INSTANCE = new MavenArtifactInsertHandler(); + + @Override + public void handleInsert(final InsertionContext context, LookupElement item) { + context.commitDocument(); + + XmlFile xmlFile = (XmlFile)context.getFile(); + + PsiElement element = xmlFile.findElementAt(context.getStartOffset()); + XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class); + if (tag == null) return; + + XmlTag dependencyTag = tag.getParentTag(); + + DomElement domElement = DomManager.getDomManager(context.getProject()).getDomElement(dependencyTag); + if (!(domElement instanceof MavenDomDependency)) return; + + MavenDomArtifactCoordinates dependency = (MavenDomArtifactCoordinates)domElement; + + String artifactId = item.getLookupString(); + + String groupId = dependency.getGroupId().getStringValue(); + if (StringUtil.isEmpty(groupId)) { + String g = getUniqueGroupIdOrNull(context.getProject(), artifactId); + if (g != null) { + dependency.getGroupId().setStringValue(g); + groupId = g; + } + else { + if (groupId == null) { + dependency.getGroupId().setStringValue(""); + } + + XmlTag groupIdTag = dependency.getGroupId().getXmlTag(); + context.getEditor().getCaretModel().moveToOffset(groupIdTag.getValue().getTextRange().getStartOffset()); + + MavenDependencyCompletionUtil.invokeCompletion(context, CompletionType.SMART); + + return; + } + } + + MavenDependencyCompletionUtil.completeVersion(context, dependency, groupId, artifactId); + } + + private static String getUniqueGroupIdOrNull(@NotNull Project project, @NotNull String artifactId) { + MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(project); + + String res = null; + + for (String groupId : manager.getGroupIds()) { + if (manager.getArtifactIds(groupId).contains(artifactId)) { + if (res == null) { + res = groupId; + } + else { + return null; // There are more then one appropriate groupId. + } + } + } + + return res; + } + } + } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java index 3301e63e3699..4ef73ee0952b 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java @@ -315,12 +315,12 @@ public abstract class MavenArtifactCoordinatesConverter extends ResolvingConvert public Set getVariants(MavenId id, MavenProjectIndicesManager manager, MavenDomShortArtifactCoordinates coordinates) { if (StringUtil.isEmpty(id.getGroupId())) { Set result = new THashSet(); - if (DomUtil.hasXml(coordinates.getGroupId())) { - for (String each : manager.getGroupIds()) { - id = new MavenId(each, id.getArtifactId(), id.getVersion()); - result.addAll(super.getVariants(id, manager, coordinates)); - } + + for (String each : manager.getGroupIds()) { + id = new MavenId(each, id.getArtifactId(), id.getVersion()); + result.addAll(super.getVariants(id, manager, coordinates)); } + return result; } return super.getVariants(id, manager, coordinates); diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java index 17874ffeba0f..5cffc360a0d0 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesGroupIdConverter.java @@ -1,8 +1,21 @@ package org.jetbrains.idea.maven.dom.converters; +import com.intellij.codeInsight.completion.InsertHandler; +import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiElement; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.xml.XmlFile; +import com.intellij.psi.xml.XmlTag; import com.intellij.util.containers.hash.HashSet; import com.intellij.util.xml.ConvertContext; +import com.intellij.util.xml.DomElement; +import com.intellij.util.xml.DomManager; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.maven.dom.model.MavenDomArtifactCoordinates; +import org.jetbrains.idea.maven.dom.model.MavenDomDependency; import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager; import org.jetbrains.idea.maven.model.MavenArtifact; import org.jetbrains.idea.maven.model.MavenId; @@ -36,6 +49,14 @@ public class MavenArtifactCoordinatesGroupIdConverter extends MavenArtifactCoord return manager.getGroupIds(); } + @Nullable + @Override + public LookupElement createLookupElement(String s) { + LookupElementBuilder res = LookupElementBuilder.create(s); + res = res.withInsertHandler(MavenGroupIdInsertHandler.INSTANCE); + return res; + } + @Override public Collection getSmartVariants(ConvertContext convertContext) { Set groupIds = new HashSet(); @@ -50,4 +71,33 @@ public class MavenArtifactCoordinatesGroupIdConverter extends MavenArtifactCoord } return groupIds; } + + private static class MavenGroupIdInsertHandler implements InsertHandler { + + public static final InsertHandler INSTANCE = new MavenGroupIdInsertHandler(); + + @Override + public void handleInsert(final InsertionContext context, LookupElement item) { + context.commitDocument(); + + XmlFile xmlFile = (XmlFile)context.getFile(); + + PsiElement element = xmlFile.findElementAt(context.getStartOffset()); + XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class); + if (tag == null) return; + + XmlTag dependencyTag = tag.getParentTag(); + + DomElement domElement = DomManager.getDomManager(context.getProject()).getDomElement(dependencyTag); + if (!(domElement instanceof MavenDomDependency)) return; + + MavenDomArtifactCoordinates dependency = (MavenDomArtifactCoordinates)domElement; + + String artifactId = dependency.getArtifactId().getStringValue(); + if (StringUtil.isEmpty(artifactId)) return; + + MavenDependencyCompletionUtil.completeVersion(context, dependency, item.getLookupString(), artifactId); + } + } + } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyCompletionUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyCompletionUtil.java new file mode 100644 index 000000000000..81066993f42e --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenDependencyCompletionUtil.java @@ -0,0 +1,112 @@ +/* + * Copyright 2000-2013 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 org.jetbrains.idea.maven.dom.converters; + +import com.intellij.codeInsight.completion.CodeCompletionHandlerBase; +import com.intellij.codeInsight.completion.CompletionType; +import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.Processor; +import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.xml.DomElement; +import com.intellij.util.xml.DomUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils; +import org.jetbrains.idea.maven.dom.model.*; +import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager; + +import java.util.Set; + +/** + * @author Sergey Evdokimov + */ +public class MavenDependencyCompletionUtil { + + public static MavenDomDependency findManagedDependency(MavenDomProjectModel domModel, Project project, + @NotNull final String groupId, @NotNull final String artifactId) { + + final Ref ref = new Ref(); + + MavenDomProjectProcessorUtils.processDependenciesInDependencyManagement(domModel, + new Processor() { + @Override + public boolean process(MavenDomDependency dependency) { + if (groupId.equals(dependency.getGroupId().getStringValue()) + && + artifactId.equals( + dependency.getArtifactId().getStringValue())) { + ref.set(dependency); + return true; + } + return false; + } + }, project); + + return ref.get(); + } + + private static boolean isInsideManagedDependency(MavenDomArtifactCoordinates dependency) { + DomElement parent = dependency.getParent(); + if (!(parent instanceof MavenDomDependencies)) return false; + + return parent.getParent() instanceof MavenDomDependencyManagement; + } + + public static void completeVersion(@NotNull InsertionContext context, + @NotNull MavenDomArtifactCoordinates dependency, + @NotNull String groupId, @NotNull String artifactId) { + if (!StringUtil.isEmpty(dependency.getVersion().getStringValue())) return; + + Project project = context.getProject(); + + if (!isInsideManagedDependency(dependency)) { + MavenDomProjectModel model = DomUtil.getFileElement(dependency).getRootElement(); + if (findManagedDependency(model, project, groupId, artifactId) != null) { + return; + } + } + + MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(project); + + Set versions = manager.getVersions(groupId, artifactId); + if (versions.size() == 1) { + dependency.getVersion().setStringValue(ContainerUtil.getFirstItem(versions)); + return; + } + + dependency.getVersion().setStringValue(""); + + int versionPosition = dependency.getVersion().getXmlTag().getValue().getTextRange().getStartOffset(); + + context.getEditor().getCaretModel().moveToOffset(versionPosition); + + if (versions.size() > 0) { + invokeCompletion(context, CompletionType.BASIC); + } + } + + public static void invokeCompletion(@NotNull final InsertionContext context, final CompletionType completionType) { + context.setLaterRunnable(new Runnable() { + @Override + public void run() { + new CodeCompletionHandlerBase(completionType).invokeCompletion(context.getProject(), context.getEditor()); + } + }); + } + +} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomShortArtifactCoordinates.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomShortArtifactCoordinates.java index f75b3d447c59..ed0aa1e51cfd 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomShortArtifactCoordinates.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/MavenDomShortArtifactCoordinates.java @@ -17,12 +17,13 @@ package org.jetbrains.idea.maven.dom.model; import com.intellij.spellchecker.xml.NoSpellchecking; import com.intellij.util.xml.Convert; +import com.intellij.util.xml.DomElement; import com.intellij.util.xml.GenericDomValue; import com.intellij.util.xml.Required; import org.jetbrains.idea.maven.dom.converters.MavenArtifactCoordinatesArtifactIdConverter; import org.jetbrains.idea.maven.dom.converters.MavenArtifactCoordinatesGroupIdConverter; -public interface MavenDomShortArtifactCoordinates { +public interface MavenDomShortArtifactCoordinates extends DomElement { @Required @NoSpellchecking @Convert(MavenArtifactCoordinatesGroupIdConverter.class) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenDependenciesCompletionProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenDependenciesCompletionProvider.java index 21d35fa07485..ac212bd9bb57 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenDependenciesCompletionProvider.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenDependenciesCompletionProvider.java @@ -6,7 +6,6 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.icons.AllIcons; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -15,12 +14,10 @@ import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlText; import com.intellij.psi.xml.XmlTokenType; -import com.intellij.util.Processor; import com.intellij.util.xml.DomElement; import com.intellij.util.xml.DomFileElement; import com.intellij.util.xml.DomManager; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils; +import org.jetbrains.idea.maven.dom.converters.MavenDependencyCompletionUtil; import org.jetbrains.idea.maven.dom.model.MavenDomDependency; import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel; import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager; @@ -67,29 +64,6 @@ public class MavenDependenciesCompletionProvider extends CompletionContributor { } } - private static MavenDomDependency findManagedDependency(MavenDomProjectModel domModel, Project project, - @NotNull final String groupId, @NotNull final String artifactId) { - - final Ref ref = new Ref(); - - MavenDomProjectProcessorUtils.processDependenciesInDependencyManagement(domModel, - new Processor() { - @Override - public boolean process(MavenDomDependency dependency) { - if (groupId.equals(dependency.getGroupId().getStringValue()) - && - artifactId.equals( - dependency.getArtifactId().getStringValue())) { - ref.set(dependency); - return false; - } - return true; - } - }, project); - - return ref.get(); - } - private static class MavenDependencyInsertHandler implements InsertHandler { public static final InsertHandler INSTANCE = new MavenDependencyInsertHandler(); @@ -111,7 +85,8 @@ public class MavenDependenciesCompletionProvider extends CompletionContributor { boolean shouldInvokeCompletion = false; - MavenDomDependency managedDependency = findManagedDependency(domModel.getRootElement(), context.getProject(), groupId, artifactId); + MavenDomDependency managedDependency = MavenDependencyCompletionUtil.findManagedDependency(domModel.getRootElement(), + context.getProject(), groupId, artifactId); if (managedDependency == null) { String value = "" + groupId + "\n" + "" + artifactId + "\n" + @@ -153,12 +128,7 @@ public class MavenDependenciesCompletionProvider extends CompletionContributor { } if (shouldInvokeCompletion) { - context.setLaterRunnable(new Runnable() { - @Override - public void run() { - new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(context.getProject(), context.getEditor()); - } - }); + MavenDependencyCompletionUtil.invokeCompletion(context, CompletionType.BASIC); } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenPomXmlCompletionTagListenerContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenPomXmlCompletionTagListenerContributor.java index 2a02adbabc0e..f62c67c1d649 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenPomXmlCompletionTagListenerContributor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenPomXmlCompletionTagListenerContributor.java @@ -17,6 +17,7 @@ import com.intellij.util.xml.DomFileDescription; import com.intellij.util.xml.DomManager; import org.jetbrains.idea.maven.dom.MavenDomProjectModelDescription; import org.jetbrains.idea.maven.dom.MavenDomUtil; +import org.jetbrains.idea.maven.dom.converters.MavenDependencyCompletionUtil; import org.jetbrains.idea.maven.dom.model.MavenDomDependency; import java.util.Set; @@ -71,12 +72,7 @@ public class MavenPomXmlCompletionTagListenerContributor extends CompletionContr new ReformatCodeProcessor(context.getProject(), context.getFile(), xmlTag.getTextRange(), true).run(); - context.setLaterRunnable(new Runnable() { - @Override - public void run() { - new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(context.getProject(), context.getEditor()); - } - }); + MavenDependencyCompletionUtil.invokeCompletion(context, CompletionType.BASIC); } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenSmartCompletionContributor.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenSmartCompletionContributor.java index e4b1c51c854b..f56ec2685bd3 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenSmartCompletionContributor.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/model/completion/MavenSmartCompletionContributor.java @@ -20,8 +20,7 @@ import com.intellij.codeInsight.completion.CompletionContributor; import com.intellij.codeInsight.completion.CompletionParameters; import com.intellij.codeInsight.completion.CompletionResultSet; import com.intellij.codeInsight.completion.CompletionType; -import com.intellij.openapi.application.AccessToken; -import com.intellij.openapi.application.ApplicationManager; +import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.impl.source.xml.TagNameReference; @@ -63,11 +62,19 @@ public class MavenSmartCompletionContributor extends CompletionContributor { Converter converter = reference.getConverter(); if (converter instanceof MavenSmartConverter) { - result.addAll(((MavenSmartConverter)converter).getSmartVariants(reference.getConvertContext())); + Collection variants = ((MavenSmartConverter)converter).getSmartVariants(reference.getConvertContext()); + if (converter instanceof ResolvingConverter) { + addVariants((ResolvingConverter)converter, variants, result); + } + else { + result.addAll(variants); + } } else if (converter instanceof ResolvingConverter) { //noinspection unchecked - result.addAll(((ResolvingConverter)converter).getVariants(reference.getConvertContext())); + ResolvingConverter resolvingConverter = (ResolvingConverter)converter; + Collection variants = resolvingConverter.getVariants(reference.getConvertContext()); + addVariants(resolvingConverter, variants, result); } } else { @@ -78,6 +85,18 @@ public class MavenSmartCompletionContributor extends CompletionContributor { return result; } + private static void addVariants(ResolvingConverter converter, Collection variants, Collection result) { + for (T variant : variants) { + LookupElement lookupElement = converter.createLookupElement(variant); + if (lookupElement != null) { + result.add(lookupElement); + } + else { + result.add(variant); + } + } + } + @NotNull private static PsiReference[] getReferences(CompletionParameters parameters) { PsiElement psiElement = parameters.getPosition().getParent(); diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3.1/_maven.repositories b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/_maven.repositories new file mode 100644 index 000000000000..a29e8ae77799 --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/_maven.repositories @@ -0,0 +1,6 @@ +#NOTE: This is an internal implementation file, its format can be changed without prior notice. +#Fri Mar 01 18:02:46 MSK 2013 +asm-3.3.1.pom>remote-repos= +asm-3.3.1.jar>remote-repos= +asm-3.3.1.jar>central= +asm-3.3.1.pom>central= diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.jar b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.jar new file mode 100644 index 000000000000..9e4c1e6ccff8 Binary files /dev/null and b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.jar differ diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.jar.sha1 b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.jar.sha1 new file mode 100644 index 000000000000..ffa8db63a5d8 --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.jar.sha1 @@ -0,0 +1 @@ +1d5f20b4ea675e6fab6ab79f1cd60ec268ddc015 diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.pom b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.pom new file mode 100644 index 000000000000..4b4cea601f97 --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.pom @@ -0,0 +1,14 @@ + + 4.0.0 + + + asm-parent + asm + 3.3.1 + + + ASM Core + asm + jar + + diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.pom.sha1 b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.pom.sha1 new file mode 100644 index 000000000000..819f1114743a --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3.1/asm-3.3.1.pom.sha1 @@ -0,0 +1 @@ +bbcde0189656fa6cc671f27437432ac7e7f95673 diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3/_maven.repositories b/plugins/maven/src/test/data/local1/asm/asm/3.3/_maven.repositories new file mode 100644 index 000000000000..7097771b1f76 --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3/_maven.repositories @@ -0,0 +1,4 @@ +#NOTE: This is an internal implementation file, its format can be changed without prior notice. +#Mon Mar 25 15:17:33 MSK 2013 +asm-3.3.pom>remote-repos= +asm-3.3.jar>remote-repos= diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.jar b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.jar new file mode 100644 index 000000000000..c7930a29d907 Binary files /dev/null and b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.jar differ diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.jar.sha1 b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.jar.sha1 new file mode 100644 index 000000000000..c09efaa38611 --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.jar.sha1 @@ -0,0 +1 @@ +fb0f302a91a376fd5cfe23167c419375e8fc9b8f diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.pom b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.pom new file mode 100644 index 000000000000..9a857ba5344a --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.pom @@ -0,0 +1,14 @@ + + 4.0.0 + + + asm-parent + asm + 3.3 + + + ASM Core + asm + jar + + diff --git a/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.pom.sha1 b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.pom.sha1 new file mode 100644 index 000000000000..307ba96c5a51 --- /dev/null +++ b/plugins/maven/src/test/data/local1/asm/asm/3.3/asm-3.3.pom.sha1 @@ -0,0 +1 @@ +3a860b74b902e6f67fa389c336984792826025a1 diff --git a/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.jar b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.jar new file mode 100644 index 000000000000..1cd1525b2503 Binary files /dev/null and b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.jar differ diff --git a/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.jar.sha1 b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.jar.sha1 new file mode 100644 index 000000000000..aa020ca3e172 --- /dev/null +++ b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.jar.sha1 @@ -0,0 +1 @@ +b1b6ea3b7e4aa4f492509a4952029cd8e48019ad ./commons-io-2.4.jar diff --git a/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.pom b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.pom new file mode 100644 index 000000000000..99bdc7f87779 --- /dev/null +++ b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.pom @@ -0,0 +1,323 @@ + + + + + org.apache.commons + commons-parent + 25 + + 4.0.0 + commons-io + commons-io + 2.4 + Commons IO + + 2002 + +The Commons IO library contains utility classes, stream implementations, file filters, +file comparators, endian transformation classes, and much more. + + + http://commons.apache.org/io/ + + + jira + http://issues.apache.org/jira/browse/IO + + + + + apache.website + Apache Commons IO Site + ${commons.deployment.protocol}://people.apache.org/www/commons.apache.org/${commons.componentid} + + + + + scm:svn:http://svn.apache.org/repos/asf/commons/proper/io/trunk + scm:svn:https://svn.apache.org/repos/asf/commons/proper/io/trunk + http://svn.apache.org/viewvc/commons/proper/io/trunk + + + + + Scott Sanders + sanders + sanders@apache.org + + + Java Developer + + + + dIon Gillard + dion + dion@apache.org + + + Java Developer + + + + Nicola Ken Barozzi + nicolaken + nicolaken@apache.org + + + Java Developer + + + + Henri Yandell + bayard + bayard@apache.org + + + Java Developer + + + + Stephen Colebourne + scolebourne + + + Java Developer + + 0 + + + Jeremias Maerki + jeremias + jeremias@apache.org + + + Java Developer + + +1 + + + Matthew Hawthorne + matth + matth@apache.org + + + Java Developer + + + + Martin Cooper + martinc + martinc@apache.org + + + Java Developer + + + + Rob Oxspring + roxspring + roxspring@apache.org + + + Java Developer + + + + Jochen Wiedmann + jochen + jochen.wiedmann@gmail.com + + + Niall Pemberton + niallp + + Java Developer + + + + Jukka Zitting + jukka + + Java Developer + + + + Gary Gregory + ggregory + ggregory@apache.org + http://www.garygregory.com + -5 + + + + + + Rahul Akolkar + + + Jason Anderson + + + Nathan Beyer + + + Emmanuel Bourg + + + Chris Eldredge + + + Magnus Grimsell + + + Jim Harrington + + + Thomas Ledoux + + + Andy Lehane + + + Marcelo Liberato + + + Alban Peignier + alban.peignier at free.fr + + + Ian Springer + + + Masato Tezuka + + + James Urie + + + Frank W. Zammetti + + + + + + junit + junit + 4.10 + test + + + + + 1.6 + 1.6 + io + RC1 + 2.4 + (requires JDK 1.6+) + 2.2 + (requires JDK 1.5+) + IO + 12310477 + + + org.apache.commons.io; + org.apache.commons.io.comparator; + org.apache.commons.io.filefilter; + org.apache.commons.io.input; + org.apache.commons.io.output;version=1.4.9999;-noimport:=true, + + org.apache.commons.io; + org.apache.commons.io.comparator; + org.apache.commons.io.filefilter; + org.apache.commons.io.input; + org.apache.commons.io.output; + org.apache.commons.io.*;version=${project.version};-noimport:=true + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + pertest + + -Xmx25M + + + **/*Test*.class + + + **/*AbstractTestCase* + **/testtools/** + + **/*$* + + + + + maven-assembly-plugin + + + src/main/assembly/bin.xml + src/main/assembly/src.xml + + gnu + + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.9.1 + + ${basedir}/checkstyle.xml + false + + + + org.codehaus.mojo + findbugs-maven-plugin + 2.4.0 + + Normal + Default + ${basedir}/findbugs-exclude-filter.xml + + + + org.apache.rat + apache-rat-plugin + + + src/test/resources/**/*.bin + .pmd + + + + + + diff --git a/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.pom.sha1 b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.pom.sha1 new file mode 100644 index 000000000000..1dce7443d4f9 --- /dev/null +++ b/plugins/maven/src/test/data/local1/commons-io/commons-io/2.4/commons-io-2.4.pom.sha1 @@ -0,0 +1 @@ +9ece23effe8bce3904f3797a76b1ba6ab681e1b9 ./commons-io-2.4.pom diff --git a/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/_maven.repositories b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/_maven.repositories new file mode 100644 index 000000000000..c4400d2cab0b --- /dev/null +++ b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/_maven.repositories @@ -0,0 +1,4 @@ +#NOTE: This is an internal implementation file, its format can be changed without prior notice. +#Tue Apr 09 20:46:20 MSD 2013 +asm-4.1.pom>remote-repos= +asm-4.1.jar>remote-repos= diff --git a/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.jar b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.jar new file mode 100644 index 000000000000..648e7b0d567a Binary files /dev/null and b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.jar differ diff --git a/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.jar.sha1 b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.jar.sha1 new file mode 100644 index 000000000000..fca9878081d2 --- /dev/null +++ b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.jar.sha1 @@ -0,0 +1 @@ +ad568238ee36a820bd6c6806807e8a14ea34684d diff --git a/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.pom b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.pom new file mode 100644 index 000000000000..731a3300af78 --- /dev/null +++ b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.pom @@ -0,0 +1,44 @@ + + + + 4.0.0 + + + asm-parent + org.ow2.asm + 4.1 + + + ASM Core + asm + jar + + diff --git a/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.pom.sha1 b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.pom.sha1 new file mode 100644 index 000000000000..55dbfe0430ba --- /dev/null +++ b/plugins/maven/src/test/data/local1/org/ow2/asm/asm/4.1/asm-4.1.pom.sha1 @@ -0,0 +1 @@ +14520f912710fa80079305bdcf8d52bd68764b60 diff --git a/plugins/maven/src/test/data/local1_index/_2.cfs b/plugins/maven/src/test/data/local1_index/_2.cfs deleted file mode 100644 index 6a84f0a7a873..000000000000 Binary files a/plugins/maven/src/test/data/local1_index/_2.cfs and /dev/null differ diff --git a/plugins/maven/src/test/data/local1_index/_7.cfs b/plugins/maven/src/test/data/local1_index/_7.cfs new file mode 100644 index 000000000000..abee3bb3d98a Binary files /dev/null and b/plugins/maven/src/test/data/local1_index/_7.cfs differ diff --git a/plugins/maven/src/test/data/local1_index/segments.gen b/plugins/maven/src/test/data/local1_index/segments.gen index e9fa6008becd..e76c9033a6ad 100644 Binary files a/plugins/maven/src/test/data/local1_index/segments.gen and b/plugins/maven/src/test/data/local1_index/segments.gen differ diff --git a/plugins/maven/src/test/data/local1_index/segments_3 b/plugins/maven/src/test/data/local1_index/segments_3 deleted file mode 100644 index 4d8270f7604e..000000000000 Binary files a/plugins/maven/src/test/data/local1_index/segments_3 and /dev/null differ diff --git a/plugins/maven/src/test/data/local1_index/segments_8 b/plugins/maven/src/test/data/local1_index/segments_8 new file mode 100644 index 000000000000..0de34bd5741e Binary files /dev/null and b/plugins/maven/src/test/data/local1_index/segments_8 differ diff --git a/plugins/maven/src/test/data/local1_index/timestamp b/plugins/maven/src/test/data/local1_index/timestamp index 8af1c7a7fa59..f7e2da32b8c9 100644 Binary files a/plugins/maven/src/test/data/local1_index/timestamp and b/plugins/maven/src/test/data/local1_index/timestamp differ diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java index 2b257d97e00a..506815f8e7e9 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java @@ -56,7 +56,7 @@ public class MavenDependencyCompletionAndResolutionTest extends MavenDomWithIndi " " + ""); - assertCompletionVariants(myProjectPom, "junit", "jmock", "test"); + assertCompletionVariantsInclude(myProjectPom, "junit", "jmock", "test"); } public void testArtifactIdCompletion() throws Exception { @@ -89,20 +89,6 @@ public class MavenDependencyCompletionAndResolutionTest extends MavenDomWithIndi assertCompletionVariants(myProjectPom); } - public void testDoNotCompleteArtifactIdIfNoGroupId() throws Exception { - createProjectPom("test" + - "project" + - "1" + - - "" + - " " + - " " + - " " + - ""); - - assertCompletionVariants(myProjectPom); // should not throw - } - public void testVersionCompletion() throws Exception { createProjectPom("test" + "project" + diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySmartCompletionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySmartCompletionTest.java index 7642c1a57e35..68eabbc955e3 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySmartCompletionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencySmartCompletionTest.java @@ -1,8 +1,10 @@ package org.jetbrains.idea.maven.dom; import com.intellij.codeInsight.completion.CompletionType; +import com.intellij.codeInsight.lookup.LookupElement; import java.io.IOException; +import java.util.Arrays; /** * @author Sergey Evdokimov @@ -141,4 +143,322 @@ public class MavenDependencySmartCompletionTest extends MavenDomWithIndicesTestC "\n")); } + public void testCompletionArtifactIdThenVersion() throws IOException { + importProject("test" + + "project" + + "1"); + + createProjectPom("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " juni\n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.completeBasic(); + assertSize(1, elements); + + myFixture.type('\n'); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " junit\n" + + " junit\n" + + " \n" + + " \n" + + "\n")); + + myFixture.getLookupElementStrings().containsAll(Arrays.asList("3.8.1", "4.0")); + } + + public void testCompletionArtifactIdThenGroupIdThenInsertVersion() throws IOException { + importProject("test" + + "project" + + "1"); + + createProjectPom("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " as\n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.completeBasic(); + assertSize(1, elements); + + myFixture.type('\n'); + + assertUnorderedElementsAreEqual(myFixture.getLookupElementStrings(), "asm", "org.ow2.asm"); + + myFixture.type("org\n"); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " org.ow2.asm\n" + + " asm\n" + + " 4.1\n" + + " \n" + + "\n")); + } + + public void testCompletionArtifactIdThenGroupIdThenCompleteVersion() throws IOException { + importProject("test" + + "project" + + "1"); + + createProjectPom("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " as\n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.completeBasic(); + assertSize(1, elements); + + myFixture.type('\n'); + + assertUnorderedElementsAreEqual(myFixture.getLookupElementStrings(), "asm", "org.ow2.asm"); + + myFixture.type("asm\n"); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " asm\n" + + " asm\n" + + " \n" + + " \n" + + "\n")); + + myFixture.getLookupElementStrings().equals(Arrays.asList("3.3", "3.3.1")); + } + + public void testCompletionArtifactIdWithFullInsert() throws IOException { + importProject("test" + + "project" + + "1"); + + createProjectPom("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " common-i\n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.completeBasic(); + assertSize(1, elements); + + myFixture.type('\n'); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + "\n")); + } + + public void testCompletionArtifactIdInsideManagedDependency() throws IOException { + importProject("test" + + "project" + + "1"); + + createProjectPom("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " \n" + + " commons-i\n" + + " \n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.completeBasic(); + assertSize(1, elements); + myFixture.type('\n'); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + "\n")); + } + + public void testCompletionArtifactIdWithManagedDependency() throws IOException { + importProject("test" + + "project" + + "1\n" + + "" + + " \n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + " \n"); + + createProjectPom("test" + + "project" + + "1\n" + + " \n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + " \n" + + + "\n" + + " \n" + + " common-i\n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.completeBasic(); + assertSize(1, elements); + myFixture.type('\n'); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + " \n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + " \n" + + + "\n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " \n" + + "\n" + )); + } + + public void testCompletionGroupIdWithManagedDependency() throws IOException { + importProject("test" + + "project" + + "1\n" + + "" + + "\n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + "\n"); + + createProjectPom("test" + + "project" + + "1\n" + + "\n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + "\n" + + + "\n" + + " \n" + + " commons-i\n" + + " commons-io\n" + + " \n" + + "\n"); + + myFixture.configureFromExistingVirtualFile(myProjectPom); + + LookupElement[] elements = myFixture.complete(CompletionType.SMART); + assertNull(elements); +// assertSize(1, elements); +// myFixture.type('\n'); + + myFixture.checkResult(createPomXml("test" + + "project" + + "1\n" + + + "\n" + + " \n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " 2.4\n" + + " \n" + + " \n" + + "\n" + + + "\n" + + " \n" + + " commons-io\n" + + " commons-io\n" + + " \n" + + "\n" + )); + } + } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.java index 2c1728711c5f..c22d06b4e24b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenParentCompletionAndResolutionTest.java @@ -34,9 +34,9 @@ public class MavenParentCompletionAndResolutionTest extends MavenDomWithIndicesT "" + " " + " junit" + - " " + + " " + ""); - assertCompletionVariants(myProjectPom, "junit", "jmock", "test"); + assertCompletionVariantsInclude(myProjectPom, "junit", "jmock", "test"); createProjectPom("test" + "project" + diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java index a7d10fe81c8a..11c3fce704d3 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenPluginCompletionAndResolutionTest.java @@ -823,7 +823,7 @@ public class MavenPluginCompletionAndResolutionTest extends MavenDomWithIndicesT assertCompletionVariants(myProjectPom); } - @Bombed(year = 2013, month = Calendar.MARCH, day = 25, user = "sergey.evdokimov") + @Bombed(year = 2014, month = Calendar.MARCH, day = 25, user = "sergey.evdokimov") public void testDocumentationForParameter() throws Exception { createProjectPom("test" + "project" + diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java index 1a989942d3f3..c411299ffbef 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenIndicesTest.java @@ -81,7 +81,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { MavenIndex i = myIndices.add("id", myRepositoryHelper.getTestDataPath("local1"), MavenIndex.Kind.LOCAL); myIndices.updateOrRepair(i, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(i.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); } public void testCreatingAndUpdatingLocalWhenNoDirectory() throws Exception { @@ -97,7 +97,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { myIndices.updateOrRepair(i1, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); myIndices.updateOrRepair(i2, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); assertUnorderedElementsAreEqual(i2.getGroupIds(), "jmock"); } @@ -108,7 +108,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { myIndices.updateOrRepair(i1, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); myIndices.updateOrRepair(i2, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); assertUnorderedElementsAreEqual(i2.getGroupIds(), "jmock"); } @@ -119,8 +119,8 @@ public class MavenIndicesTest extends MavenIndicesTestCase { myIndices.updateOrRepair(i1, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); myIndices.updateOrRepair(i2, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit"); - assertUnorderedElementsAreEqual(i2.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); + assertUnorderedElementsAreEqual(i2.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); } public void testAddingWithoutUpdate() throws Exception { @@ -132,7 +132,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { MavenIndex i = myIndices.add("id", myRepositoryHelper.getTestDataPath("local1"), MavenIndex.Kind.LOCAL); myIndices.updateOrRepair(i, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(i.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); myRepositoryHelper.delete("local1"); myRepositoryHelper.copy("local2", "local1"); @@ -240,7 +240,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { myIndices.updateOrRepair(i1, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); myIndices.updateOrRepair(i2, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(i1.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); assertUnorderedElementsAreEqual(i2.getGroupIds(), "jmock"); shutdownIndices(); @@ -253,7 +253,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { assertUnorderedElementsAreEqual(myIndices.getIndices().get(1).getGroupIds(), "jmock"); myIndices.updateOrRepair(myIndices.getIndices().get(0), false, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(myIndices.getIndices().get(0).getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(myIndices.getIndices().get(0).getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); } public void testDoNotLoadSameIndexTwice() throws Exception { @@ -318,7 +318,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { assertTrue(index.getGroupIds().isEmpty()); myIndices.updateOrRepair(myIndices.getIndices().get(0), false, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(index.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(index.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); } public void testRepairingIndicesOnReadWhileAddingArtifact() throws Exception { @@ -337,7 +337,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { assertTrue(index.getGroupIds().isEmpty()); myIndices.updateOrRepair(myIndices.getIndices().get(0), false, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(index.getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(index.getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); } public void testCorrectlyClosingIndicesOnRemoteFacadeShutdown() throws Exception { @@ -390,7 +390,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { MavenIndex i = myIndices.add("id", myRepositoryHelper.getTestDataPath("local1"), MavenIndex.Kind.LOCAL); myIndices.updateOrRepair(i, true, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS); - assertUnorderedElementsAreEqual(i.getGroupIds(), "junit", "jmock"); + assertUnorderedElementsAreEqual(i.getGroupIds(), "junit", "jmock", "asm", "commons-io", "org.ow2.asm"); assertUnorderedElementsAreEqual(i.getArtifactIds("junit"), "junit"); assertUnorderedElementsAreEqual(i.getArtifactIds("jmock"), "jmock"); @@ -414,7 +414,7 @@ public class MavenIndicesTest extends MavenIndicesTestCase { shutdownIndices(); initIndices(); - assertUnorderedElementsAreEqual(myIndices.getIndices().get(0).getGroupIds(), "junit"); + assertUnorderedElementsAreEqual(myIndices.getIndices().get(0).getGroupIds(), "junit", "asm", "commons-io", "org.ow2.asm"); } public void testHasArtifactInfo() throws Exception { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java index 8ee0e5599192..4018e23ac023 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/indices/MavenSearcherTest.java @@ -89,8 +89,11 @@ public class MavenSearcherTest extends MavenIndicesTestCase { public void testArtifactSearch() throws Exception { assertArtifactSearchResults("", + "asm:asm:3.3.1 asm:asm:3.3", + "commons-io:commons-io:2.4", "jmock:jmock:1.2.0 jmock:jmock:1.1.0 jmock:jmock:1.0.0", - "junit:junit:4.0 junit:junit:3.8.2 junit:junit:3.8.1"); + "junit:junit:4.0 junit:junit:3.8.2 junit:junit:3.8.1", + "org.ow2.asm:asm:4.1"); assertArtifactSearchResults("j *1*", "jmock:jmock:1.2.0 jmock:jmock:1.1.0 jmock:jmock:1.0.0", "junit:junit:3.8.1");