Generics, JUnit 4 Project: http://git-wip-us.apache.org/repos/asf/ant-ivyde/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivyde/commit/f808b0b4 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivyde/tree/f808b0b4 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivyde/diff/f808b0b4
Branch: refs/heads/master Commit: f808b0b4f178c2c77a8fe03b22e3e4299a83cb4b Parents: ca17491 Author: Gintas Grigelionis <[email protected]> Authored: Mon Nov 6 00:00:03 2017 +0100 Committer: Gintas Grigelionis <[email protected]> Committed: Mon Nov 6 00:00:03 2017 +0100 ---------------------------------------------------------------------- org.apache.ivyde.eclipse/.classpath | 2 +- .../completion/IvyCodeCompletionProcessor.java | 24 ++-- .../common/ivyfile/IvyFileResourceListener.java | 14 +- .../common/ivyfile/IvyModuleDescriptorFile.java | 22 ++- .../ivyfile/IvyModuleDescriptorModel.java | 102 +++++++------- .../common/ivysettings/IvySettingsFile.java | 12 +- .../common/ivysettings/IvySettingsModel.java | 47 +++---- .../org/apache/ivyde/common/model/IvyFile.java | 10 +- .../org/apache/ivyde/common/model/IvyModel.java | 27 ++-- .../org/apache/ivyde/common/model/IvyTag.java | 31 ++--- .../apache/ivyde/eclipse/NopMessageLogger.java | 6 +- .../apache/ivyde/eclipse/cp/ClasspathSetup.java | 6 +- .../cp/IvyClasspathContainerConfiguration.java | 8 +- .../eclipse/cp/IvyClasspathContainerHelper.java | 11 +- .../apache/ivyde/eclipse/cp/SettingsSetup.java | 15 +- .../ivyde/internal/eclipse/CachedIvy.java | 9 +- .../ivyde/internal/eclipse/IvyDEMessage.java | 2 +- .../IvyDERuntimeClasspathEntryResolver.java | 33 ++--- .../ivyde/internal/eclipse/IvyNature.java | 10 +- .../ivyde/internal/eclipse/IvyPlugin.java | 32 ++--- .../cpcontainer/ClasspathEntriesResolver.java | 21 +-- .../IvyClasspathContainerConfAdapter.java | 6 +- .../cpcontainer/IvyClasspathContainerImpl.java | 8 +- .../IvyClasspathContainerMapper.java | 17 +-- .../IvyClasspathContainerSerializer.java | 35 +++-- .../cpcontainer/IvyClasspathContainerState.java | 2 +- .../cpcontainer/IvyClasspathInitializer.java | 17 ++- .../eclipse/cpcontainer/IvyClasspathUtil.java | 19 ++- .../eclipse/cpcontainer/IvydeContainerPage.java | 22 +-- .../eclipse/handlers/AbstractIvyDEHandler.java | 49 +++---- .../eclipse/handlers/AddIvyNatureHandler.java | 12 +- .../eclipse/handlers/OpenIvyFileHandler.java | 10 +- .../eclipse/handlers/RefreshHandler.java | 6 +- .../eclipse/handlers/ReloadSettingsHandler.java | 6 +- .../handlers/RemoveIvyNatureHandler.java | 12 +- .../eclipse/handlers/ResolveAllHandler.java | 12 +- .../eclipse/handlers/ResolveHandler.java | 6 +- .../ViewReverseDependenciesHandler.java | 7 +- .../internal/eclipse/resolve/IvyResolveJob.java | 60 +++----- .../internal/eclipse/resolve/IvyResolver.java | 32 ++--- .../eclipse/retrieve/RetrieveSetupManager.java | 25 ++-- .../retrieve/StandaloneRetrieveSerializer.java | 17 +-- .../retrieve/StandaloneRetrieveSetupState.java | 2 +- .../eclipse/revdepexplorer/IvyUtil.java | 34 ++--- .../MultiRevDependencyDescriptor.java | 56 +++----- .../eclipse/revdepexplorer/SyncIvyFilesJob.java | 39 +++--- .../internal/eclipse/ui/AdvancedSetupTab.java | 2 +- .../internal/eclipse/ui/ConfTableViewer.java | 41 +++--- .../internal/eclipse/ui/FileListEditor.java | 20 ++- .../internal/eclipse/ui/IvyFilePathText.java | 8 +- .../eclipse/ui/NewIvyDEContainerWizard.java | 5 +- .../eclipse/ui/SettingsSetupEditor.java | 8 +- .../internal/eclipse/ui/console/IvyConsole.java | 12 +- .../ui/console/IvyConsoleFilterAction.java | 23 ++-- .../eclipse/ui/console/IvyDEMessageLogger.java | 6 +- .../ui/editors/IvyModuleDescriptorEditor.java | 15 +- .../eclipse/ui/editors/IvySettingsEditor.java | 14 +- .../eclipse/ui/editors/xml/ColorManager.java | 19 ++- .../ui/editors/xml/EclipseIvyModelSettings.java | 5 +- .../eclipse/ui/menu/CleanCacheAction.java | 11 +- .../ui/menu/IvyMenuContributionItem.java | 136 ++++++++----------- .../eclipse/ui/menu/RetrieveAction.java | 2 +- .../ui/preferences/IvyDEProjectPreferences.java | 24 ++-- .../ui/preferences/PreferenceConstants.java | 9 +- .../internal/eclipse/ui/views/ReportView.java | 6 +- .../ui/views/ReverseDependencyExplorerView.java | 14 +- .../workspaceresolver/IvyDEStrategy.java | 20 +-- .../workspaceresolver/WorkspaceResolver.java | 3 +- .../WorkspaceResourceChangeListener.java | 54 +++----- .../common/ivyfile/IvyFileUpdaterTest.java | 16 ++- .../ivyde/common/model/IvyFileUtilTest.java | 57 +++++--- 71 files changed, 651 insertions(+), 834 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/.classpath ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/.classpath b/org.apache.ivyde.eclipse/.classpath index 74f2f57..09c139e 100644 --- a/org.apache.ivyde.eclipse/.classpath +++ b/org.apache.ivyde.eclipse/.classpath @@ -21,7 +21,7 @@ <classpathentry kind="src" path="src/java"/> <classpathentry kind="src" path="test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="bin"/> </classpath> http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java index 958f144..9859e57 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/completion/IvyCodeCompletionProcessor.java @@ -20,7 +20,6 @@ package org.apache.ivyde.common.completion; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -47,7 +46,7 @@ public class IvyCodeCompletionProcessor { */ public CodeCompletionProposal[] computeCompletionProposals(IvyFile ivyfile, int caretOffset) { model.refreshIfNeeded(ivyfile); - List propList = new ArrayList(); + List<CodeCompletionProposal> propList = new ArrayList<>(); if (ivyfile.inTag()) { String tagName = ivyfile.getTagName(); if (ivyfile.readyForValue()) { @@ -60,8 +59,7 @@ public class IvyCodeCompletionProcessor { computeStructureProposals(ivyfile, propList, caretOffset); } - return (CodeCompletionProposal[]) propList.toArray( - new CodeCompletionProposal[propList.size()]); + return propList.toArray(new CodeCompletionProposal[propList.size()]); } /** @@ -73,7 +71,7 @@ public class IvyCodeCompletionProcessor { * @param propList List<CodeCompletionProposal> * @param caretOffset ditto */ - private void computeTagAttributeProposals(String tagName, IvyFile ivyfile, List propList, + private void computeTagAttributeProposals(String tagName, IvyFile ivyfile, List<CodeCompletionProposal> propList, int caretOffset) { String qualifier = ivyfile.getQualifier(); int qlen = qualifier.length(); @@ -90,11 +88,9 @@ public class IvyCodeCompletionProcessor { return; } errorMessage = null; - List atts = tag.getAttributes(); - Map existingAtts = ivyfile.getAllAttsValues(); + Map<String, String> existingAtts = ivyfile.getAllAttsValues(); // Loop through all proposals - for (Iterator iter = atts.iterator(); iter.hasNext();) { - IvyTagAttribute att = (IvyTagAttribute) iter.next(); + for (IvyTagAttribute att : tag.getAttributes()) { if (att.getName().startsWith(qualifier) && !existingAtts.containsKey(att.getName())) { // Yes -- compute whole proposal text @@ -120,7 +116,7 @@ public class IvyCodeCompletionProcessor { * @param propList List<CodeCompletionProposal> * @param caretOffset ditto */ - private void computeValueProposals(String tagName, IvyFile ivyfile, List propList, + private void computeValueProposals(String tagName, IvyFile ivyfile, List<CodeCompletionProposal> propList, int caretOffset) { String parent = null; String tag = ivyfile.getTagName(); @@ -157,7 +153,7 @@ public class IvyCodeCompletionProcessor { * @param propList List<CodeCompletionProposal> * @param caretOffset int */ - private void computeStructureProposals(IvyFile ivyfile, List propList, int caretOffset) { + private void computeStructureProposals(IvyFile ivyfile, List<CodeCompletionProposal> propList, int caretOffset) { String parent = ivyfile.getParentTagName(); String qualifier = ivyfile.getQualifier(); int qlen = qualifier.length(); @@ -183,7 +179,7 @@ public class IvyCodeCompletionProcessor { } } - List childs = null; + List<IvyTag> childs = null; if (parent != null) { String parentParent = ivyfile.getParentTagName(ivyfile.getStringIndexBackward("<" @@ -199,9 +195,7 @@ public class IvyCodeCompletionProcessor { childs = Collections.singletonList(model.getRootIvyTag()); } errorMessage = null; - for (Iterator iter = childs.iterator(); iter.hasNext();) { - IvyTag child = (IvyTag) iter.next(); - + for (IvyTag child : childs) { // Check if proposal matches qualifier if (child.getStartTag().startsWith(qualifier)) { for (Proposal prop : child.getProposals()) { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java index b191369..ef0455e 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyFileResourceListener.java @@ -18,10 +18,9 @@ package org.apache.ivyde.common.ivyfile; import java.io.File; -import java.util.Iterator; -import java.util.List; import org.apache.ivyde.eclipse.IvyDEException; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; import org.apache.ivyde.internal.eclipse.IvyPlugin; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; @@ -67,15 +66,12 @@ public class IvyFileResourceListener implements IResourceChangeListener { if (javaProject == null) { return; } - List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper - .getContainers(javaProject); - Iterator containerIter = containers.iterator(); - while (containerIter.hasNext()) { - IvyClasspathContainerImpl container = (IvyClasspathContainerImpl) containerIter.next(); + for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(javaProject)) { + IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container; try { - File containerIvyFile = container.getState().getIvyFile(); + File containerIvyFile = ivycp.getState().getIvyFile(); if (containerIvyFile.equals(resourceFile.getLocation().toFile())) { - container.launchResolve(false, null); + ivycp.launchResolve(false, null); return; } } catch (IvyDEException e) { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java index 47d6277..16268aa 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorFile.java @@ -45,23 +45,20 @@ public class IvyModuleDescriptorFile extends IvyFile { } public String[] getConfigurationNames() { - Pattern p = CONFIGURATIONS_START_PATTERN; - Matcher m = p.matcher(getDoc()); + Matcher m = CONFIGURATIONS_START_PATTERN.matcher(getDoc()); if (m.find()) { int start = m.end(); - p = CONFIGURATIONS_END_PATTERN; - m = p.matcher(getDoc()); + m = CONFIGURATIONS_END_PATTERN.matcher(getDoc()); int end = getDoc().length(); if (m.find(start)) { end = m.start(); } - p = CONF_PATTERN; - m = p.matcher(getDoc()); - List ret = new ArrayList(); + m = CONF_PATTERN.matcher(getDoc()); + List<String> ret = new ArrayList<>(); for (boolean found = m.find(start); found && m.end() < end; found = m.find()) { ret.add(m.group(1)); } - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } else { return new String[] {"default"}; } @@ -77,13 +74,12 @@ public class IvyModuleDescriptorFile extends IvyFile { } public String getDependencyOrganisation() { - Map otherAttValues = getAllAttsValues(); + Map<String, String> otherAttValues = getAllAttsValues(); return getDependencyOrganisation(otherAttValues); } - public String getDependencyOrganisation(Map otherAttValues) { - return otherAttValues != null && otherAttValues.get("org") != null ? (String) otherAttValues - .get("org") - : getOrganisation(); + public String getDependencyOrganisation(Map<String, String> otherAttValues) { + return (otherAttValues != null && otherAttValues.get("org") != null) + ? otherAttValues.get("org") : getOrganisation(); } } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java index a51f5f7..631f521 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivyfile/IvyModuleDescriptorModel.java @@ -20,7 +20,10 @@ package org.apache.ivyde.common.ivyfile; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -101,13 +104,13 @@ public class IvyModuleDescriptorModel extends IvyModel { "the name of the organisation of the parent module.", false); parentOrgAtt.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - List ret = listDependencyTokenValues(att.getName(), ivyFile); + List<String> ret = listDependencyTokenValues(att.getName(), ivyFile); ret.add(getSettings().getDefaultOrganization()); String org = ((IvyModuleDescriptorFile) ivyFile).getOrganisation(); if (org != null) { ret.add(org); } - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } }); extend.addAttribute(parentOrgAtt); @@ -115,8 +118,8 @@ public class IvyModuleDescriptorModel extends IvyModel { "the module name of the parent module", true); parentModuleAtt.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - List ret = listDependencyTokenValues(att.getName(), ivyFile); - return (String[]) ret.toArray(new String[ret.size()]); + List<String> ret = listDependencyTokenValues(att.getName(), ivyFile); + return ret.toArray(new String[ret.size()]); } }); extend.addAttribute(parentModuleAtt); @@ -158,9 +161,9 @@ public class IvyModuleDescriptorModel extends IvyModel { child.addAttribute(new IvyTagAttribute("url", "an url pointing to the repository.", true, new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - Map allAttsValues = ivyFile.getAllAttsValues(); + Map<String, String> allAttsValues = ivyFile.getAllAttsValues(); if (allAttsValues != null) { - String name = (String) allAttsValues.get("name"); + String name = allAttsValues.get("name"); if ("ibiblio".equals(name)) { return new String[] {"http://www.ibiblio.org/maven/"}; } else if ("ivyrep".equals(name)) { @@ -175,9 +178,9 @@ public class IvyModuleDescriptorModel extends IvyModel { "an ivy pattern to find modules on this repository", false); reppatternTagAttribute.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - Map allAttsValues = ivyFile.getAllAttsValues(); + Map<String, String> allAttsValues = ivyFile.getAllAttsValues(); if (allAttsValues != null) { - String name = (String) allAttsValues.get("name"); + String name = allAttsValues.get("name"); if ("ibiblio".equals(name)) { return new String[] {"[module]/[type]s/[artifact]-[revision].[ext]"}; } else if ("ivyrep".equals(name)) { @@ -259,7 +262,7 @@ public class IvyModuleDescriptorModel extends IvyModel { }); conf.addAttribute(deprecatedTagAttribute); configurations.addChildIvyTag(conf); - List allConf = new ArrayList(); + List<IvyTag> allConf = new ArrayList<>(); allConf.add(conf); addTag(conf.getName(), allConf); ivyTag.addChildIvyTag(configurations); @@ -302,8 +305,8 @@ public class IvyModuleDescriptorModel extends IvyModel { public String[] getPossibleValuesForAttribute(String att, IvyFile ivyfile) { String[] r = super.getPossibleValuesForAttribute(att, ivyfile); if (r == null) { // listing can be used even for extra attributes - List ret = listDependencyTokenValues(att, ivyfile); - return (String[]) ret.toArray(new String[ret.size()]); + List<String> ret = listDependencyTokenValues(att, ivyfile); + return ret.toArray(new String[ret.size()]); } else { return r; } @@ -313,13 +316,13 @@ public class IvyModuleDescriptorModel extends IvyModel { "the name of the organisation of the dependency.", false); orgAtt.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - List ret = listDependencyTokenValues(att.getName(), ivyFile); + List<String> ret = listDependencyTokenValues(att.getName(), ivyFile); ret.add(getSettings().getDefaultOrganization()); String org = ((IvyModuleDescriptorFile) ivyFile).getOrganisation(); if (org != null) { ret.add(org); } - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } }); @@ -328,8 +331,8 @@ public class IvyModuleDescriptorModel extends IvyModel { true); module.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - List ret = listDependencyTokenValues(att.getName(), ivyFile); - return (String[]) ret.toArray(new String[ret.size()]); + List<String> ret = listDependencyTokenValues(att.getName(), ivyFile); + return ret.toArray(new String[ret.size()]); } }); dependency.addAttribute(module); @@ -337,8 +340,8 @@ public class IvyModuleDescriptorModel extends IvyModel { "the branch of the dependency. \nDo not set if not needed.", false); branch.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - List ret = listDependencyTokenValues(att.getName(), ivyFile); - return (String[]) ret.toArray(new String[ret.size()]); + List<String> ret = listDependencyTokenValues(att.getName(), ivyFile); + return ret.toArray(new String[ret.size()]); } }); dependency.addAttribute(branch); @@ -348,9 +351,9 @@ public class IvyModuleDescriptorModel extends IvyModel { + " matching revision.", true); rev.setValueProvider(new IValueProvider() { public String[] getValuesfor(IvyTagAttribute att, IvyFile ivyFile) { - List ret = listDependencyTokenValues(att.getName(), ivyFile); + List<String> ret = listDependencyTokenValues(att.getName(), ivyFile); ret.add("latest.integration"); - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } }); dependency.addAttribute(rev); @@ -373,17 +376,17 @@ public class IvyModuleDescriptorModel extends IvyModel { if (arrowIndex > -1) { // we are looking for a dep conf String org = ((IvyModuleDescriptorFile) ivyFile).getDependencyOrganisation(); - Map otherAttValues = ivyFile.getAllAttsValues(); + Map<String, String> otherAttValues = ivyFile.getAllAttsValues(); if (org != null && otherAttValues != null && otherAttValues.get("name") != null && otherAttValues.get("rev") != null) { otherAttValues.remove("org"); - String branch = (String) otherAttValues.remove("branch"); + String branch = otherAttValues.remove("branch"); otherAttValues.remove("conf"); otherAttValues.remove("force"); otherAttValues.remove("transitive"); otherAttValues.remove("changing"); - return getDependencyConfs(org, (String) otherAttValues.remove("name"), - branch, (String) otherAttValues.remove("rev"), otherAttValues, + return getDependencyConfs(org, otherAttValues.remove("name"), + branch, otherAttValues.remove("rev"), otherAttValues, qualifier, base, arrowIndex); } @@ -409,13 +412,13 @@ public class IvyModuleDescriptorModel extends IvyModel { for (int i = 0; i < confs.length; i++) { confs[i] = base + confs[i]; } - List ret = new ArrayList(Arrays.asList(confs)); + List<String> ret = new ArrayList<>(Arrays.asList(confs)); ret.add("*"); - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } private String[] getDependencyConfs(String org, String name, String branch, String rev, - Map otherAtts, String qualifier, StringBuffer base, int arrowIndex) { + Map<String, String> otherAtts, String qualifier, StringBuffer base, int arrowIndex) { Ivy ivy = getIvy(); if (ivy == null) { return null; @@ -431,8 +434,7 @@ public class IvyModuleDescriptorModel extends IvyModel { qualifier = qualifier.substring(1); } ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions()); - ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev, - otherAtts); + ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, branch, rev, otherAtts); DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false); try { DependencyResolver resolver = ivy.getSettings().getResolver(mrid); @@ -447,9 +449,9 @@ public class IvyModuleDescriptorModel extends IvyModel { for (int i = 0; i < confs.length; i++) { confs[i] = base + confs[i]; } - List ret = new ArrayList(Arrays.asList(confs)); + List<String> ret = new ArrayList<>(Arrays.asList(confs)); ret.add("*"); - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } catch (ParseException e) { getSettings().logError("The dependencies of " + mrid + " could not be parsed", e); @@ -472,7 +474,7 @@ public class IvyModuleDescriptorModel extends IvyModel { Ivy ivy = getIvy(); int[] indexes = ivyFile.getParentTagIndex(); if (indexes != null && ivy != null) { - Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1); + Map<String, String> otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1); String org = ((IvyModuleDescriptorFile) ivyFile) .getDependencyOrganisation(otherAttValues); if (org != null && otherAttValues != null @@ -491,8 +493,7 @@ public class IvyModuleDescriptorModel extends IvyModel { ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions()); ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, - (String) otherAttValues.get("name"), (String) otherAttValues - .get("rev")); + otherAttValues.get("name"), otherAttValues.get("rev")); DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor( mrid, false); try { @@ -502,9 +503,9 @@ public class IvyModuleDescriptorModel extends IvyModel { for (int i = 0; i < confs.length; i++) { confs[i] = base + confs[i]; } - List ret = new ArrayList(Arrays.asList(confs)); + List<String> ret = new ArrayList<>(Arrays.asList(confs)); ret.add("*"); - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } catch (ParseException e) { getSettings().logError( "The dependencies of " + mrid + " could not be parsed", e); @@ -533,7 +534,7 @@ public class IvyModuleDescriptorModel extends IvyModel { if (indexes == null) { return new String[] {"*"}; } - Map otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1); + Map<String, String> otherAttValues = ivyFile.getAllAttsValues(indexes[0] + 1); String org = ((IvyModuleDescriptorFile) ivyFile) .getDependencyOrganisation(otherAttValues); if (org == null || otherAttValues == null || otherAttValues.get("name") == null @@ -543,14 +544,14 @@ public class IvyModuleDescriptorModel extends IvyModel { ResolveData data = new ResolveData(ivy.getResolveEngine(), new ResolveOptions()); ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, - (String) otherAttValues.get("name"), (String) otherAttValues.get("rev")); + otherAttValues.get("name"), otherAttValues.get("rev")); DefaultDependencyDescriptor ddd = new DefaultDependencyDescriptor(mrid, false); try { String[] confs = ivy.getSettings().getResolver(mrid) .getDependency(ddd, data).getDescriptor().getConfigurationsNames(); - List ret = new ArrayList(Arrays.asList(confs)); + List<String> ret = new ArrayList<>(Arrays.asList(confs)); ret.add("*"); - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } catch (ParseException e) { getSettings().logError("The dependencies of " + mrid + " could not be parsed", e); @@ -561,12 +562,12 @@ public class IvyModuleDescriptorModel extends IvyModel { conf3.addChildIvyTag(mapped); addTag(mapped); - String[] matcherNames = new String[0]; + Collection<String> matcherNames = Collections.emptySet(); Ivy ivy = getIvy(); if (ivy != null) { - matcherNames = ivy.getSettings().getMatcherNames().toArray(new String[0]); + matcherNames = ivy.getSettings().getMatcherNames(); } - ListValueProvider matcherNamesProvider = new ListValueProvider(matcherNames); + ListValueProvider matcherNamesProvider = new ListValueProvider(matcherNames.toArray(new String[matcherNames.size()])); IvyTag artifact2 = new IvyTag("artifact", "defines artifacts restriction \n" + "use only if you do not control dependency ivy file"); @@ -698,8 +699,8 @@ public class IvyModuleDescriptorModel extends IvyModel { return "ivy-module"; } - List listDependencyTokenValues(String att, IvyFile ivyfile) { - Map allAttsValues = ivyfile.getAllAttsValues(); + private List<String> listDependencyTokenValues(String att, IvyFile ivyfile) { + Map<String, String> allAttsValues = ivyfile.getAllAttsValues(); String org = ((IvyModuleDescriptorFile) ivyfile).getOrganisation(); if (org != null && !allAttsValues.containsKey("org")) { allAttsValues.put("org", org); @@ -707,8 +708,8 @@ public class IvyModuleDescriptorModel extends IvyModel { return listDependencyTokenValues(att, allAttsValues); } - private List listDependencyTokenValues(String att, Map otherAttValues) { - List ret = new ArrayList(); + private List<String> listDependencyTokenValues(String att, Map<String, String> otherAttValues) { + List<String> ret = new ArrayList<>(); Ivy ivy = getIvy(); if (ivy != null) { replaceToken(otherAttValues, "org", IvyPatternHelper.ORGANISATION_KEY); @@ -722,7 +723,10 @@ public class IvyModuleDescriptorModel extends IvyModel { String stdAtt = standardiseDependencyAttribute(att); otherAttValues.remove(stdAtt); - String[] revs = ivy.listTokenValues(stdAtt, otherAttValues); + // transform otherAttValues into Map required by Ivy + Map<String, Object> ivyAttrs = new HashMap<>(); + ivyAttrs.putAll(otherAttValues); + String[] revs = ivy.listTokenValues(stdAtt, ivyAttrs); if (revs != null) { ret.addAll(Arrays.asList(revs)); } @@ -730,8 +734,8 @@ public class IvyModuleDescriptorModel extends IvyModel { return ret; } - private void replaceToken(Map otherAttValues, String oldToken, String newToken) { - String val = (String) otherAttValues.remove(oldToken); + private void replaceToken(Map<String, String> otherAttValues, String oldToken, String newToken) { + String val = otherAttValues.remove(oldToken); if (val != null) { otherAttValues.put(newToken, val); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java index c3e3711..8636859 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsFile.java @@ -54,7 +54,7 @@ public class IvySettingsFile extends IvyFile { } public URL[] getClasspathUrls() { - List urls = new ArrayList(); + List<URL> urls = new ArrayList<>(); Matcher m = CLASSPATH_URL_PATTERN.matcher(getDoc()); while (m.find()) { try { @@ -75,11 +75,11 @@ public class IvySettingsFile extends IvyFile { } } } - return (URL[]) urls.toArray(new URL[urls.size()]); + return urls.toArray(new URL[urls.size()]); } private String substitute(String str) { - Map variables = new HashMap(); + Map<String, String> variables = new HashMap<>(); if (file.getParentFile() != null) { URI settingsDirUri = file.getParentFile().toURI(); variables.put("ivy.settings.dir", settingsDirUri.toString()); @@ -87,8 +87,8 @@ public class IvySettingsFile extends IvyFile { return IvyPatternHelper.substituteVariables(str, variables); } - public Map/* <String,String> */getTypedefs() { - Map p = getDefaultTypedefs(); + public Map<Object, Object> getTypedefs() { + Map<Object, Object> p = getDefaultTypedefs(); Matcher m = TYPEDEF_PATTERN.matcher(getDoc()); while (m.find()) { p.put(substitute(m.group(1)), substitute(m.group(2))); @@ -96,7 +96,7 @@ public class IvySettingsFile extends IvyFile { return p; } - public static Map/* <String,String> */getDefaultTypedefs() { + public static Map<Object, Object> getDefaultTypedefs() { Properties p = new Properties(); try { p.load(XmlSettingsParser.class.getResourceAsStream("typedef.properties")); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java index b2baa53..7ed1af4 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/ivysettings/IvySettingsModel.java @@ -21,7 +21,6 @@ import java.io.File; import java.lang.reflect.Method; import java.net.URLClassLoader; import java.util.Arrays; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -50,7 +49,7 @@ public class IvySettingsModel extends IvyModel { private String loaded = null; private final File file; private ClassLoader cl; - private Map typedefClasses; + private Map<String, Class<?>> typedefClasses; public IvySettingsModel(IvyModelSettings settings, File file) { super(settings); @@ -225,26 +224,23 @@ public class IvySettingsModel extends IvyModel { addTag(ivyTag); } - private void addTypedefChildren(IvyTag tag, Map children) { - for (Iterator it = children.entrySet().iterator(); it.hasNext();) { - Entry entry = (Entry) it.next(); - Class clazz = (Class) entry.getValue(); - String childName = (String) entry.getKey(); - tag.addChildIvyTag(typedefedTag(childName, clazz)); + private void addTypedefChildren(IvyTag tag, Map<String, Class<?>> children) { + for (Entry<String, Class<?>> entry : children.entrySet()) { + tag.addChildIvyTag(typedefedTag(entry.getKey(), entry.getValue())); } } - private IvyTag typedefedTag(String tagName, final Class clazz) { - IvyTag child = new IvyTag(tagName) { + private IvyTag typedefedTag(String tagName, final Class<?> clazz) { + return new IvyTag(tagName) { // we lazy load children, since we may have a loop in children (chain can contain chain) // causing a stack overflow if we try to recursively add typedefed children private boolean init = false; - public List getAttributes() { + public List<IvyTagAttribute> getAttributes() { init(); return super.getAttributes(); } - public List getChilds() { + public List<IvyTag> getChilds() { init(); return super.getChilds(); } @@ -307,10 +303,9 @@ public class IvySettingsModel extends IvyModel { } } }; - return child; } - protected boolean isSupportedChildType(Class type) { + protected boolean isSupportedChildType(Class<?> type) { return !Void.TYPE.equals(type) && !String.class.equals(type) && !Character.class.equals(type) && !char.class.equals(type) @@ -321,7 +316,7 @@ public class IvySettingsModel extends IvyModel { && !Class.class.equals(type); } - private boolean isSupportedAttributeType(Class type) { + private boolean isSupportedAttributeType(Class<?> type) { if (String.class.isAssignableFrom(type) || Character.class.equals(type) || char.class.equals(type) || Boolean.class.equals(type) || boolean.class.equals(type) @@ -348,17 +343,16 @@ public class IvySettingsModel extends IvyModel { } } - private Map/*<String,Class>*/ getTypedefClasses(IvySettingsFile file, ClassLoader cl) { - Map typedefs = file.getTypedefs(); + private Map<String, Class<?>> getTypedefClasses(IvySettingsFile file, ClassLoader cl) { + Map<Object, Object> typedefs = file.getTypedefs(); return getTypedefClasses(cl, typedefs); } - private Map getTypedefClasses(ClassLoader cl, Map typedefs) { - Map/*<String,Class>*/ classes = new LinkedHashMap(); - for (Iterator it = typedefs.entrySet().iterator(); it.hasNext();) { - Entry entry = (Entry) it.next(); + private Map<String, Class<?>> getTypedefClasses(ClassLoader cl, Map<Object, Object> typedefs) { + Map<String, Class<?>> classes = new LinkedHashMap<>(); + for (Entry<Object, Object> entry : typedefs.entrySet()) { try { - classes.put(entry.getKey(), cl.loadClass((String) entry.getValue())); + classes.put((String) entry.getKey(), cl.loadClass((String) entry.getValue())); } catch (ClassNotFoundException e) { // ignored } @@ -366,11 +360,10 @@ public class IvySettingsModel extends IvyModel { return classes; } - private Map/*<String,Class>*/ getChildClasses(Map/*<String,Class>*/ classes, Class type) { - Map/*<String,Class>*/ childClasses = new LinkedHashMap(); - for (Iterator it = classes.entrySet().iterator(); it.hasNext();) { - Entry entry = (Entry) it.next(); - if (type.isAssignableFrom((Class) entry.getValue())) { + private Map<String, Class<?>> getChildClasses(Map<String, Class<?>> classes, Class<?> type) { + Map<String, Class<?>> childClasses = new LinkedHashMap<>(); + for (Entry<String, Class<?>> entry : classes.entrySet()) { + if (type.isAssignableFrom(entry.getValue())) { childClasses.put(entry.getKey(), entry.getValue()); } } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java index 9a73c68..88273f7 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyFile.java @@ -143,12 +143,12 @@ public abstract class IvyFile { return doc.indexOf(string, documentOffset); } - public Map getAllAttsValues() { + public Map<String, String> getAllAttsValues() { return getAllAttsValues(currentOffset); } - public Map getAllAttsValues(int documentOffset) { - Map result = new HashMap(); + public Map<String, String> getAllAttsValues(int documentOffset) { + Map<String, String> result = new HashMap<>(); int start = reversed.indexOf('<', getReverseOffset(documentOffset)); if (start != -1) { @@ -285,7 +285,7 @@ public abstract class IvyFile { int parentEndTagIndex = -1; boolean parentEndTagReached = false; boolean inSimpleTag = false; - Stack stack = new Stack(); + Stack<String> stack = new Stack<>(); while (offset > 0) { char c = doc.charAt(--offset); if (c == '>' && doc.charAt(offset - 1) != '-') { @@ -313,7 +313,7 @@ public abstract class IvyFile { if (doc.charAt(offset + 1) != '!' && doc.charAt(offset + 1) != '?') { // not a doc tag or xml if (!stack.isEmpty()) { // we found the closing tag before - String closedName = (String) stack.peek(); + String closedName = stack.peek(); if (closedName.equalsIgnoreCase(doc.substring(offset + 1, offset + 1 + closedName.length()))) { stack.pop(); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java index 0b1d8a8..7b6e2d6 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyModel.java @@ -18,8 +18,8 @@ package org.apache.ivyde.common.model; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -27,7 +27,7 @@ import java.util.Properties; import org.apache.ivy.Ivy; public abstract class IvyModel { - private final Map model = new HashMap(); + private final Map<String, List<IvyTag>> model = new HashMap<>(); private Properties defaults; @@ -39,18 +39,12 @@ public abstract class IvyModel { } public IvyTag getIvyTag(String tagName, String parentName) { - Object tag = model.get(tagName); - if (tag instanceof List) { - List all = (List) tag; - for (Iterator iter = all.iterator(); iter.hasNext();) { - IvyTag t = (IvyTag) iter.next(); - if (t.getParent() != null && t.getParent().getName().equals(parentName)) { - return t; - } + for (IvyTag tag : model.get(tagName)) { + if (tag.getParent() != null && tag.getParent().getName().equals(parentName)) { + return tag; } - return null; } - return (IvyTag) tag; + return null; } private void loadDefaults() { @@ -77,15 +71,16 @@ public abstract class IvyModel { return settings; } - protected void addTag(String name, List list) { + protected void addTag(String name, List<IvyTag> list) { model.put(name, list); } public void addTag(IvyTag ivyTag) { if (!model.containsKey(ivyTag.getName())) { - model.put(ivyTag.getName(), ivyTag); - for (Iterator it = ivyTag.getChilds().iterator(); it.hasNext();) { - IvyTag child = (IvyTag) it.next(); + List<IvyTag> list = new ArrayList<>(); + list.add(ivyTag); + model.put(ivyTag.getName(), list); + for (IvyTag child : ivyTag.getChilds()) { addTag(child); } } else { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java index 1a79d2d..1f34749 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/IvyTag.java @@ -36,9 +36,9 @@ public class IvyTag { private String doc; - private Map attributes = new HashMap(); + private final Map<String, IvyTagAttribute> attributes = new HashMap<>(); - private List childs = new ArrayList(); + private final List<IvyTag> childs = new ArrayList<>(); private boolean allowNoChild = true; @@ -53,8 +53,8 @@ public class IvyTag { public IvyTag(String name, IvyTagAttribute[] atts) { super(); this.name = name; - for (int i = 0; i < atts.length; i++) { - addAttribute(atts[i]); + for (IvyTagAttribute att : atts) { + addAttribute(att); } } @@ -66,8 +66,8 @@ public class IvyTag { public IvyTag(String name, String doc, IvyTagAttribute[] atts) { this.name = name; this.doc = doc; - for (int i = 0; i < atts.length; i++) { - addAttribute(atts[i]); + for (IvyTagAttribute att : atts) { + addAttribute(att); } } @@ -94,11 +94,11 @@ public class IvyTag { return childs.size() > 0; } - public List getAttributes() { - return new ArrayList(attributes.values()); + public List<IvyTagAttribute> getAttributes() { + return new ArrayList<>(attributes.values()); } - public List getChilds() { + public List<IvyTag> getChilds() { return childs; } @@ -149,7 +149,7 @@ public class IvyTag { } public String[] getPossibleValuesForAttribute(String att, IvyFile ivyfile) { - IvyTagAttribute ivyTagAttribute = (IvyTagAttribute) attributes.get(att); + IvyTagAttribute ivyTagAttribute = attributes.get(att); if (ivyTagAttribute == null) { return null; } @@ -158,13 +158,13 @@ public class IvyTag { String qualifier = ivyfile.getAttributeValueQualifier(); String[] values = provider.getValuesfor(ivyTagAttribute, ivyfile); if (values != null) { - Set ret = new HashSet(values.length); + Set<String> ret = new HashSet<>(values.length); for (String value : values) { if (value.startsWith(qualifier)) { ret.add(value); } } - return (String[]) ret.toArray(new String[ret.size()]); + return ret.toArray(new String[ret.size()]); } else { return null; } @@ -175,8 +175,7 @@ public class IvyTag { } public String getPossibleDocForValue(String value, IvyFile ivyfile) { - IvyTagAttribute ivyTagAttribute = (IvyTagAttribute) attributes.get(ivyfile - .getAttributeName()); + IvyTagAttribute ivyTagAttribute = attributes.get(ivyfile.getAttributeName()); if (ivyTagAttribute == null) { return null; } @@ -196,7 +195,7 @@ public class IvyTag { } public Proposal[] getProposals() { - List ret = new ArrayList(); + List<Proposal> ret = new ArrayList<>(); // Yes -- compute whole proposal text String text = getStartTag() + getEndTag(); // Derive cursor position @@ -206,7 +205,7 @@ public class IvyTag { if (allowNoChild && getChilds().size() > 0) { ret.add(new Proposal("<" + getName() + " />", cursor, getDoc())); } - return (Proposal[]) ret.toArray(new Proposal[ret.size()]); + return ret.toArray(new Proposal[ret.size()]); } } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java index 37a88a2..84934dd 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/NopMessageLogger.java @@ -62,15 +62,15 @@ public class NopMessageLogger implements MessageLogger { // no nothing } - public List getProblems() { + public List<String> getProblems() { return Collections.emptyList(); } - public List getWarns() { + public List<String> getWarns() { return Collections.emptyList(); } - public List getErrors() { + public List<String> getErrors() { return Collections.emptyList(); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java index 90fb6ed..b6dfc0a 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/ClasspathSetup.java @@ -24,7 +24,7 @@ public class ClasspathSetup { private boolean resolveInWorkspace; - private List/* <String> */acceptedTypes; + private List<String> acceptedTypes; private boolean alphaOrder; @@ -61,11 +61,11 @@ public class ClasspathSetup { this.resolveInWorkspace = resolveInWorkspace; } - public List getAcceptedTypes() { + public List<String> getAcceptedTypes() { return acceptedTypes; } - public void setAcceptedTypes(List acceptedTypes) { + public void setAcceptedTypes(List<String> acceptedTypes) { this.acceptedTypes = acceptedTypes; } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java index 76eebd9..d1e2983 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerConfiguration.java @@ -17,7 +17,7 @@ */ package org.apache.ivyde.eclipse.cp; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.ivyde.internal.eclipse.IvyPlugin; @@ -37,7 +37,7 @@ public class IvyClasspathContainerConfiguration { private String ivyXmlPath; - private List/* <String> */confs = Arrays.asList(new String[] {"*"}); + private List<String> confs = Collections.singletonList("*"); private SettingsSetup settingsSetup = new SettingsSetup(); @@ -111,11 +111,11 @@ public class IvyClasspathContainerConfiguration { this.ivyXmlPath = ivyXmlPath; } - public List getConfs() { + public List<String> getConfs() { return confs; } - public void setConfs(List confs) { + public void setConfs(List<String> confs) { this.confs = confs; } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java index 5f07f24..0d64c52 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/IvyClasspathContainerHelper.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import org.apache.ivyde.internal.eclipse.IvyPlugin; @@ -56,13 +55,11 @@ public final class IvyClasspathContainerHelper { if (selection == null) { return null; } - for (@SuppressWarnings("unchecked") - Iterator<Object> it = selection.iterator(); it.hasNext();) { - Object element = it.next(); - IvyClasspathContainerImpl cp = (IvyClasspathContainerImpl) IvyPlugin.adapt(element, + for (Object element : selection.toList()) { + IvyClasspathContainerImpl ivycp = IvyPlugin.adapt(element, IvyClasspathContainerImpl.class); - if (cp != null) { - return cp; + if (ivycp != null) { + return ivycp; } if (element instanceof ClassPathContainer) { // FIXME: we shouldn't check against internal JDT API but they are not adaptable to http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java index ae9c0b9..0f86a0d 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cp/SettingsSetup.java @@ -18,7 +18,6 @@ package org.apache.ivyde.eclipse.cp; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.apache.ivyde.eclipse.IvyDEException; @@ -35,7 +34,7 @@ public class SettingsSetup { private String ivySettingsPath; - private List/* <String> */propertyFiles = new ArrayList(); + private List<String> propertyFiles = new ArrayList<>(); private boolean loadSettingsOnDemand = false; @@ -67,17 +66,15 @@ public class SettingsSetup { this.ivySettingsPath = ivySettingsPath; } - public List getRawPropertyFiles() { + public List<String> getRawPropertyFiles() { return propertyFiles; } - public List getResolvedPropertyFiles() throws IvyDEException { - List resolvedProps = new ArrayList(); + public List<String> getResolvedPropertyFiles() throws IvyDEException { + List<String> resolvedProps = new ArrayList<>(); IStringVariableManager manager = VariablesPlugin.getDefault().getStringVariableManager(); try { - Iterator it = propertyFiles.iterator(); - while (it.hasNext()) { - String propFile = (String) it.next(); + for (String propFile : propertyFiles) { String resolvedProp = manager.performStringSubstitution(propFile, false); resolvedProps.add(resolvedProp); } @@ -88,7 +85,7 @@ public class SettingsSetup { return resolvedProps; } - public void setPropertyFiles(List propertyFiles) { + public void setPropertyFiles(List<String> propertyFiles) { this.propertyFiles = propertyFiles; } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java index 5d2ab2e..ae54c64 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java @@ -25,7 +25,6 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.text.ParseException; import java.util.Collection; -import java.util.Iterator; import java.util.Properties; import org.apache.ivy.Ivy; @@ -88,7 +87,7 @@ public abstract class CachedIvy { protected abstract ResolvedPath getIvyUserDir(); - protected abstract Collection getPropertyFiles() throws IvyDEException; + protected abstract Collection<String> getPropertyFiles() throws IvyDEException; protected abstract boolean isResolveInWorkspace(); @@ -248,14 +247,12 @@ public abstract class CachedIvy { if (ivyUserDir.isSet()) { ivySettings.setDefaultIvyUserDir(ivyUserDir.getFile()); } - Collection propFiles = getPropertyFiles(); + Collection<String> propFiles = getPropertyFiles(); if (propFiles == null || propFiles.isEmpty()) { IvyDEMessage.verbose("No property files to load"); } else { IvyDEMessage.verbose(propFiles.size() + " property file(s) to load"); - Iterator iter = propFiles.iterator(); - while (iter.hasNext()) { - String file = (String) iter.next(); + for (String file : propFiles) { InputStream is; Path p = new Path(file); IvyDEMessage.debug("Loading property file " + p); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java index 8ad228b..9ec0ed4 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDEMessage.java @@ -90,7 +90,7 @@ public class IvyDEMessage { } } - public static List getProblems() { + public static List<String> getProblems() { return getLogger().getProblems(); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java index 8e63c79..d85161c 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyDERuntimeClasspathEntryResolver.java @@ -18,7 +18,7 @@ package org.apache.ivyde.internal.eclipse; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.apache.ivyde.internal.eclipse.cpcontainer.ClasspathEntriesResolver; @@ -106,10 +106,9 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr } else { cpes = ivycp.getClasspathEntries(); } - List resolved = new ArrayList(cpes.length); - List projects = new ArrayList(); - for (int i = 0; i < cpes.length; i++) { - IClasspathEntry cpe = cpes[i]; + List<IRuntimeClasspathEntry> resolved = new ArrayList<>(cpes.length); + List<IJavaProject> projects = new ArrayList<>(); + for (IClasspathEntry cpe : cpes) { if (cpe.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IProject p = ResourcesPlugin.getWorkspace().getRoot() .getProject(cpe.getPath().segment(0)); @@ -120,11 +119,10 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr .newProjectRuntimeClasspathEntry(jp); resolved.add(classpath); IRuntimeClasspathEntry[] entries = JavaRuntime.resolveRuntimeClasspathEntry( - classpath, jp); - for (int j = 0; j < entries.length; j++) { - IRuntimeClasspathEntry e = entries[j]; + classpath, jp); + for (IRuntimeClasspathEntry e : entries) { if (!resolved.contains(e)) { - resolved.add(entries[j]); + resolved.add(e); } } } @@ -139,7 +137,7 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr // set classpath property IRuntimeClasspathEntry[] result = new IRuntimeClasspathEntry[resolved.size()]; for (int i = 0; i < result.length; i++) { - result[i] = (IRuntimeClasspathEntry) resolved.get(i); + result[i] = resolved.get(i); result[i].setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES); } return result; @@ -154,16 +152,13 @@ public class IvyDERuntimeClasspathEntryResolver implements IRuntimeClasspathEntr return new IRuntimeClasspathEntry[] {entry}; } - IRuntimeClasspathEntry2 entry2 = (IRuntimeClasspathEntry2) entry; - IRuntimeClasspathEntry[] entries = entry2.getRuntimeClasspathEntries(null); - List resolved = new ArrayList(); - for (int i = 0; i < entries.length; i++) { - IRuntimeClasspathEntry[] temp = JavaRuntime.resolveRuntimeClasspathEntry(entries[i], - project); - resolved.addAll(Arrays.asList(temp)); + IRuntimeClasspathEntry[] entries = ((IRuntimeClasspathEntry2) entry).getRuntimeClasspathEntries(null); + List<IRuntimeClasspathEntry> resolved = new ArrayList<>(); + for (IRuntimeClasspathEntry ent : entries) { + IRuntimeClasspathEntry[] temp = JavaRuntime.resolveRuntimeClasspathEntry(ent, project); + Collections.addAll(resolved, temp); } - return (IRuntimeClasspathEntry[]) resolved.toArray(new IRuntimeClasspathEntry[resolved - .size()]); + return resolved.toArray(new IRuntimeClasspathEntry[resolved.size()]); } public IVMInstall resolveVMInstall(IClasspathEntry entry) throws CoreException { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java index 39a77e7..ee6267c 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyNature.java @@ -50,16 +50,16 @@ public class IvyNature implements IProjectNature { return; } IClasspathEntry[] classpathEntries = javaProject.getRawClasspath(); - List newEntries = new ArrayList(); + List<IClasspathEntry> newEntries = new ArrayList<>(); - for (int i = 0; i < classpathEntries.length; i++) { - if (!IvyClasspathContainerHelper.isIvyClasspathContainer(classpathEntries[i].getPath())) { - newEntries.add(classpathEntries[i]); + for (IClasspathEntry classpathEntry : classpathEntries) { + if (!IvyClasspathContainerHelper.isIvyClasspathContainer(classpathEntry.getPath())) { + newEntries.add(classpathEntry); } } if (newEntries.size() != classpathEntries.length) { - IClasspathEntry[] newClasspathEntries = (IClasspathEntry[]) newEntries + IClasspathEntry[] newClasspathEntries = newEntries .toArray(new IClasspathEntry[newEntries.size()]); javaProject.setRawClasspath(newClasspathEntries, null); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java index ea5dce0..952d88e 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/IvyPlugin.java @@ -20,8 +20,6 @@ package org.apache.ivyde.internal.eclipse; import java.io.File; import java.util.Collections; import java.util.Enumeration; -import java.util.Iterator; -import java.util.List; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.regex.Matcher; @@ -33,7 +31,6 @@ import org.apache.ivyde.eclipse.IvyDEsecurityHelper; import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyAttachmentManager; -import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerSerializer; import org.apache.ivyde.internal.eclipse.resolve.IvyResolveJob; import org.apache.ivyde.internal.eclipse.retrieve.RetrieveSetupManager; @@ -270,15 +267,11 @@ public class IvyPlugin extends AbstractUIPlugin { void prefStoreChanged() throws JavaModelException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IJavaModel javaModel = JavaCore.create(workspace.getRoot()); - IJavaProject[] projects = javaModel.getJavaProjects(); - for (int i = 0; i < projects.length; i++) { - List<IvyClasspathContainer> containers = IvyClasspathContainerHelper - .getContainers(projects[i]); - Iterator<IvyClasspathContainer> itContainers = containers.iterator(); - while (itContainers.hasNext()) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainers.next(); - if (!ivycp.getConf().isSettingsProjectSpecific()) { - ivycp.launchResolve(false, null); + for (IJavaProject project : javaModel.getJavaProjects()) { + for (IvyClasspathContainer container : IvyClasspathContainerHelper + .getContainers(project)) { + if (!container.getConf().isSettingsProjectSpecific()) { + container.launchResolve(false, null); } } } @@ -405,6 +398,7 @@ public class IvyPlugin extends AbstractUIPlugin { * Returns the string from the plugin's resource bundle, or 'key' if not found. * * @param key String + * @return String */ public static String getResourceString(String key) { ResourceBundle bundle = IvyPlugin.getDefault().getResourceBundle(); @@ -418,6 +412,7 @@ public class IvyPlugin extends AbstractUIPlugin { /** * Utility class that tries to adapt a non null object to the specified type * + * @param <T> type * @param object * the object to adapt * @param type @@ -425,13 +420,14 @@ public class IvyPlugin extends AbstractUIPlugin { * @return the adapted object */ - public static/* <T> T */Object adapt(Object object, Class/* <T> */type) { + @SuppressWarnings("unchecked") + public static <T> T adapt(Object object, Class<T> type) { if (type.isInstance(object)) { - return /* (T) */object; + return (T) object; } else if (object instanceof IAdaptable) { - return /* (T) */((IAdaptable) object).getAdapter(type); + return (T) ((IAdaptable) object).getAdapter(type); } - return /* (T) */Platform.getAdapterManager().getAdapter(object, type); + return (T) Platform.getAdapterManager().getAdapter(object, type); } /** @@ -451,8 +447,8 @@ public class IvyPlugin extends AbstractUIPlugin { return null; } - public Enumeration getKeys() { - return Collections.enumeration(Collections.EMPTY_LIST); + public Enumeration<String> getKeys() { + return Collections.emptyEnumeration(); } }; http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java index aa82ac0..f256995 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/ClasspathEntriesResolver.java @@ -23,9 +23,11 @@ import java.util.Set; import org.apache.ivy.Ivy; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; +import org.apache.ivy.core.module.id.ModuleId; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.core.report.ArtifactDownloadReport; import org.apache.ivy.core.report.ResolveReport; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerConfiguration; import org.apache.ivyde.eclipse.cp.RetrieveSetup; import org.apache.ivyde.internal.eclipse.IvyDEMessage; @@ -45,11 +47,11 @@ public class ClasspathEntriesResolver extends IvyResolver { private ResolveReport resolveReport; - public ClasspathEntriesResolver(IvyClasspathContainerImpl ivycp, boolean usePreviousResolveIfExist) { - super(ivycp.getConf().getIvyXmlPath(), ivycp.getConf().getConfs(), ivycp.getConf() - .getJavaProject() == null ? null : ivycp.getConf().getJavaProject().getProject()); - this.conf = ivycp.getConf(); - setUsePreviousResolveIfExist(ivycp.getConf().getInheritedAdvancedSetup().isUseExtendedResolveId()); + public ClasspathEntriesResolver(IvyClasspathContainer container, boolean usePreviousResolveIfExist) { + super(container.getConf().getIvyXmlPath(), container.getConf().getConfs(), container.getConf() + .getJavaProject() == null ? null : container.getConf().getJavaProject().getProject()); + this.conf = container.getConf(); + setUsePreviousResolveIfExist(conf.getInheritedAdvancedSetup().isUseExtendedResolveId()); setUsePreviousResolveIfExist(usePreviousResolveIfExist); setTransitiveResolve(conf.getInheritedClasspathSetup().isTransitiveResolve()); if (conf.getInheritedClasspathSetup().isRetrievedClasspath()) { @@ -88,11 +90,10 @@ public class ClasspathEntriesResolver extends IvyResolver { * @param mapper IvyClasspathContainerMapper * @param artifactReports Set<ArtifactDownloadReport> */ - private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper, Set artifactReports) { - ArtifactDownloadReport[] reports = (ArtifactDownloadReport[]) artifactReports - .toArray(new ArtifactDownloadReport[0]); + private void warnIfDuplicates(Ivy ivy, IvyClasspathContainerMapper mapper, Set<ArtifactDownloadReport> artifactReports) { + ArtifactDownloadReport[] reports = artifactReports.toArray(new ArtifactDownloadReport[0]); - Set duplicates = new HashSet(); + Set<ModuleId> duplicates = new HashSet<>(); for (int i = 0; i < reports.length - 1; i++) { if (!mapper.accept(reports[i].getArtifact())) { @@ -121,7 +122,7 @@ public class ClasspathEntriesResolver extends IvyResolver { StringBuilder buffer = new StringBuilder("There are some duplicates entries due to conflicts" + " between the resolved configurations " + conf.getConfs()); buffer.append(":\n - "); - Iterator it = duplicates.iterator(); + Iterator<ModuleId> it = duplicates.iterator(); while (it.hasNext()) { buffer.append(it.next()); if (it.hasNext()) { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java index 8ec1d60..1a26aad 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerConfAdapter.java @@ -88,7 +88,7 @@ public final class IvyClasspathContainerConfAdapter { private static void loadV0(IvyClasspathContainerConfiguration conf, IPath path) { // load some configuration that can be loaded conf.setIvyXmlPath(path.removeFirstSegments(1).removeLastSegments(1).toString()); - List confs = IvyClasspathUtil.split(path.lastSegment()); + List<String> confs = IvyClasspathUtil.split(path.lastSegment()); if (confs.isEmpty()) { confs = Collections.singletonList("*"); } @@ -315,7 +315,7 @@ public final class IvyClasspathContainerConfAdapter { RetrieveSetupManager manager = IvyPlugin.getDefault().getRetrieveSetupManager(); IProject project = conf.getJavaProject().getProject(); - List retrieveSetups; + List<StandaloneRetrieveSetup> retrieveSetups; try { retrieveSetups = manager.getSetup(project); } catch (IOException e) { @@ -485,7 +485,7 @@ public final class IvyClasspathContainerConfAdapter { path.append(URLEncoder.encode(value, "UTF-8")); } - private static void append(StringBuffer path, String name, List values) + private static void append(StringBuffer path, String name, List<String> values) throws UnsupportedEncodingException { append(path, name, IvyClasspathUtil.concat(values)); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java index 68f0a16..2af1b6c 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerImpl.java @@ -147,10 +147,10 @@ public class IvyClasspathContainerImpl implements IClasspathContainer, IvyClassp Display.getDefault().asyncExec(new Runnable() { public void run() { if (conf.getInheritedClasspathSetup().isAlphaOrder()) { - Arrays.sort(entries, new Comparator() { - public int compare(Object o1, Object o2) { - return ((IClasspathEntry) o1).getPath().lastSegment() - .compareTo(((IClasspathEntry) o2).getPath().lastSegment()); + Arrays.sort(entries, new Comparator<IClasspathEntry>() { + public int compare(IClasspathEntry o1, IClasspathEntry o2) { + return (o1.getPath().lastSegment() + .compareTo(o2.getPath().lastSegment())); } }); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java index 7e9ceb6..f6cde60 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/cpcontainer/IvyClasspathContainerMapper.java @@ -103,7 +103,6 @@ public class IvyClasspathContainerMapper { } public IClasspathEntry[] map() { - IClasspathEntry[] classpathEntries; Collection<IClasspathEntry> paths = new LinkedHashSet<>(); IvyDEMessage.verbose("Building classpath from " + all.size() + " resolved artifact(s)"); @@ -168,9 +167,8 @@ public class IvyClasspathContainerMapper { } } - classpathEntries = paths.toArray(new IClasspathEntry[paths.size()]); - return classpathEntries; + return paths.toArray(new IClasspathEntry[paths.size()]); } private IClasspathEntry buildEntry(ArtifactDownloadReport artifact, IAccessRule[] rules, @@ -228,16 +226,15 @@ public class IvyClasspathContainerMapper { if (bundleInfo == null || !classpathSetup.isReadOSGiMetadata()) { return null; } - IAccessRule[] rules = new IAccessRule[bundleInfo.getExports().size() + 1]; - int i = 0; + List<IAccessRule> rules = new ArrayList<>(bundleInfo.getExports().size() + 1); for (ExportPackage exportPackage : bundleInfo.getExports()) { - rules[i++] = JavaCore.newAccessRule( + rules.add(JavaCore.newAccessRule( new Path(exportPackage.getName().replace('.', IPath.SEPARATOR) + "/*"), - IAccessRule.K_ACCESSIBLE); + IAccessRule.K_ACCESSIBLE)); } - rules[i++] = JavaCore.newAccessRule(new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE - | IAccessRule.IGNORE_IF_BETTER); - return rules; + rules.add(JavaCore.newAccessRule(new Path("**/*"), IAccessRule.K_NON_ACCESSIBLE + | IAccessRule.IGNORE_IF_BETTER)); + return rules.toArray(new IAccessRule[rules.size()]); } private Path getArtifactPath(ArtifactDownloadReport artifact, String innerPath) {
