diff options
author | Alexander Kurtakov | 2016-03-02 19:41:05 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2016-03-02 19:54:11 +0000 |
commit | f562c7ab0b00eed80a4ece7b6cbfd7225bc263ee (patch) | |
tree | 93820c6e7f9f85aafa2e8056f26ec40c8512f99c /org.eclipse.help | |
parent | ef01a2b8597da5458c382678ed51f82312f4ead6 (diff) | |
download | eclipse.platform.ua-f562c7ab0b00eed80a4ece7b6cbfd7225bc263ee.tar.gz eclipse.platform.ua-f562c7ab0b00eed80a4ece7b6cbfd7225bc263ee.tar.xz eclipse.platform.ua-f562c7ab0b00eed80a4ece7b6cbfd7225bc263ee.zip |
Bug 488210 - Generify org.eclipse.help plugin
Last bunch of generifications.
Slight modification to o.e.help.webapp to adapt to the more generic type
returned.
Change-Id: If0a213273cdbe6d732a6a56959d887aa08e53f5f
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'org.eclipse.help')
15 files changed, 71 insertions, 79 deletions
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java b/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java index 8a0566a98..d18c16103 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/HelpData.java @@ -109,7 +109,7 @@ public class HelpData { * Returns a list of strings which are the IDs of the tocs/categories listed * in tocOrder. */ - public synchronized List getTocOrder() { + public synchronized List<String> getTocOrder() { if (tocOrder == null) { loadHelpData(); } @@ -131,7 +131,7 @@ public class HelpData { * Returns a set of strings which are the IDs of the indexes listed * in the hidden section. */ - public synchronized Set getHiddenIndexes() { + public synchronized Set<String> getHiddenIndexes() { if (hiddenIndexes == null) { loadHelpData(); } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/Topic.java b/org.eclipse.help/src/org/eclipse/help/internal/Topic.java index f7a83fbd9..d2ce6b1de 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/Topic.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/Topic.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -60,12 +60,12 @@ public class Topic extends UAElement implements ITopic2 { @Override public ITopic[] getSubtopics() { - return (ITopic[])getChildren(ITopic.class); + return getChildren(ITopic.class); } @Override public ICriteria[] getCriteria() { - return (ICriteria[]) getChildren(ICriteria.class); + return getChildren(ICriteria.class); } public void setHref(String href) { diff --git a/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java b/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java index 9217175db..e2bfd87dc 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/UAElement.java @@ -189,7 +189,8 @@ public class UAElement implements IUAElement { return children.toArray(new UAElement[children.size()]); } - public Object getChildren(Class<?> clazz) { + @SuppressWarnings("unchecked") + public <T> T[] getChildren(Class<T> clazz) { IUAElement[] children = getChildren(); if (children.length > 0) { List<Object> list = new ArrayList<>(); @@ -199,9 +200,9 @@ public class UAElement implements IUAElement { list.add(child); } } - return list.toArray((Object[])Array.newInstance(clazz, list.size())); + return list.toArray((T[]) Array.newInstance(clazz, list.size())); } - return Array.newInstance(clazz, 0); + return (T[]) Array.newInstance(clazz, 0); } public String getElementName() { diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java b/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java index 851f5ab5b..bc6123147 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/context/Context.java @@ -87,12 +87,12 @@ public class Context extends UAElement implements IContext3 { @Override public ICommandLink[] getRelatedCommands() { - return (ICommandLink[])getChildren(ICommandLink.class); + return getChildren(ICommandLink.class); } @Override public IHelpResource[] getRelatedTopics() { - return (IHelpResource[])getChildren(IHelpResource.class); + return getChildren(IHelpResource.class); } @Override diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java index e5aa86219..9c7626ddd 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java @@ -109,7 +109,7 @@ public class ContextFileProvider extends AbstractContextProvider { @Override public String[] getPlugins() { - Map<String, ?> associations = getPluginAssociations(); + Map<String, ContextFile[]> associations = getPluginAssociations(); return associations.keySet().toArray(new String[associations.size()]); } @@ -150,7 +150,7 @@ public class ContextFileProvider extends AbstractContextProvider { * as a mapping of short IDs to Context objects (shortContextId -> Context). */ public Map<String, Context>[] getPluginContexts(String pluginId, String locale) { - List<Map> maps = new ArrayList<>(); + List<Map<String, Context>> maps = new ArrayList<>(); Map<String, ContextFile[]> associations = getPluginAssociations(); ContextFile[] descriptors = associations.get(pluginId); for (int i=0;i<descriptors.length;++i) { diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java index e11b6a18b..f4f54342d 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java @@ -87,17 +87,14 @@ public class ContextManager { id = contextId.substring(index+1); String warning = "Registered Context Provider IDs:\n"; //$NON-NLS-1$ - Iterator iter = contextIDsByPluginId.keySet().iterator(); + Iterator<String> iter = contextIDsByPluginId.keySet().iterator(); warning+="--------------------------------\n"; //$NON-NLS-1$ - while (iter.hasNext()) - { - String pluginID = (String)iter.next(); - List contextIDList = contextIDsByPluginId.get(pluginID); - for (int c=0;c<contextIDList.size();c++) - { - if (((String)contextIDList.get(c)).equalsIgnoreCase(id)) - { - potentialMatches.add(pluginID+'.'+(String)contextIDList.get(c)); + while (iter.hasNext()) { + String pluginID = iter.next(); + List<String> contextIDList = contextIDsByPluginId.get(pluginID); + for (int c = 0; c < contextIDList.size(); c++) { + if (contextIDList.get(c).equalsIgnoreCase(id)) { + potentialMatches.add(pluginID+'.'+contextIDList.get(c)); break; } } @@ -155,8 +152,7 @@ public class ContextManager { } list.add(provider); } - } - else { + } else { globalProviders.add(provider); } } @@ -185,31 +181,27 @@ public class ContextManager { loadContextProviders(); } - Iterator i = providersByPluginId.keySet().iterator(); + Iterator<String> i = providersByPluginId.keySet().iterator(); while (i.hasNext()) { - String pluginID = (String)i.next(); - ArrayList providers = (ArrayList)providersByPluginId.get(pluginID); + String pluginID = i.next(); + List<AbstractContextProvider> providers = providersByPluginId.get(pluginID); - for (int p=0;p<providers.size();p++) - { + for (int p = 0; p < providers.size(); p++) { ContextFileProvider provider = (ContextFileProvider)providers.get(p); - Map[] maps = provider.getPluginContexts(pluginID,Platform.getNL()); - - for (int m=0;m<maps.length;m++) - { - Iterator i2 = maps[m].keySet().iterator(); - while (i2.hasNext()) - { - String contextID = (String)i2.next(); + Map<String, Context>[] maps = provider.getPluginContexts(pluginID, Platform.getNL()); + + for (int m = 0; m < maps.length; m++) { + Iterator<String> i2 = maps[m].keySet().iterator(); + while (i2.hasNext()) { + String contextID = i2.next(); String fullID = pluginID+'.'+contextID; - Context currentContext = (Context)maps[m].get(contextID); + Context currentContext = maps[m].get(contextID); - if (!contextByContextID.containsKey(fullID)) + if (!contextByContextID.containsKey(fullID)) { contextByContextID.put(fullID,currentContext); - else if (HelpPlugin.DEBUG_CONTEXT) - { + } else if (HelpPlugin.DEBUG_CONTEXT) { Context initialContext = contextByContextID.get(fullID); String error = "Context Help ID '"+contextID+"' is found in multiple context files in plugin '"+pluginID+"'\n"+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ " Description 1: "+initialContext.getText()+'\n'+ //$NON-NLS-1$ diff --git a/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinition.java b/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinition.java index 89f4003e4..45587270b 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinition.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -35,7 +35,7 @@ public class CriteriaDefinition extends UAElement implements ICriteriaDefinition @Override public ICriterionDefinition[] getCriterionDefinitions() { - return (ICriterionDefinition[])getChildren(ICriterionDefinition.class); + return getChildren(ICriterionDefinition.class); } } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionDefinition.java b/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionDefinition.java index 9883f0fce..2948b3722 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionDefinition.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriterionDefinition.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 IBM Corporation and others. + * Copyright (c) 2010, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -52,7 +52,7 @@ public class CriterionDefinition extends UAElement implements ICriterionDefiniti @Override public ICriterionValueDefinition[] getCriterionValueDefinitions() { - return (ICriterionValueDefinition[])getChildren(ICriterionValueDefinition.class); + return getChildren(ICriterionValueDefinition.class); } } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java b/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java index 9a38dde8e..efb3b97a3 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 Intel Corporation and others. + * Copyright (c) 2005, 2016 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,7 +39,7 @@ public class Index extends UAElement implements IIndex { @Override public IIndexEntry[] getEntries() { - return (IIndexEntry[])getChildren(IIndexEntry.class); + return getChildren(IIndexEntry.class); } /** @@ -49,8 +49,8 @@ public class Index extends UAElement implements IIndex { public IndexEntry getSeeTarget(IndexSee see) { if (children == null) getChildren(); String keyword = see.getKeyword(); - for (Iterator iter = children.iterator(); iter.hasNext();) { - Object next = iter.next(); + for (Iterator<UAElement> iter = children.iterator(); iter.hasNext();) { + UAElement next = iter.next(); if (next instanceof IndexEntry && keyword.equals(((IndexEntry)next).getKeyword())) { return (IndexEntry)next; } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java index 6a1cbf6f5..0db0362bb 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java @@ -49,7 +49,7 @@ public class IndexAssembler { * Assembles the given index contributions into a complete, sorted index. * The originals are not modified. */ - public Index assemble(List contributions, String locale) { + public Index assemble(List<IndexContribution> contributions, String locale) { this.locale = locale; process(contributions); Index index = merge(contributions); @@ -60,11 +60,11 @@ public class IndexAssembler { /* * Merge all index contributions into one large index, not sorted. */ - private Index merge(List contributions) { + private Index merge(List<IndexContribution> contributions) { Index index = new Index(); - Iterator iter = contributions.iterator(); + Iterator<IndexContribution> iter = contributions.iterator(); while (iter.hasNext()) { - IndexContribution contribution = (IndexContribution)iter.next(); + IndexContribution contribution = iter.next(); mergeChildren(index, (Index)contribution.getIndex()); contribution.setIndex(null); } @@ -129,7 +129,7 @@ public class IndexAssembler { } } - private void process(List contributions) { + private void process(List<IndexContribution> contributions) { if (processor == null) { DocumentReader reader = new DocumentReader(); processor = new DocumentProcessor(new ProcessorHandler[] { @@ -138,9 +138,9 @@ public class IndexAssembler { new ExtensionHandler(reader, locale), }); } - Iterator iter = contributions.iterator(); + Iterator<IndexContribution> iter = contributions.iterator(); while (iter.hasNext()) { - IndexContribution contribution = (IndexContribution)iter.next(); + IndexContribution contribution = iter.next(); processor.process((Index)contribution.getIndex(), contribution.getId()); } } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java index 01dc87f37..a08cff1a3 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexEntry.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 Intel Corporation and others. + * Copyright (c) 2005, 2016 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,12 +41,12 @@ public class IndexEntry extends UAElement implements IIndexEntry2 { @Override public IIndexEntry[] getSubentries() { - return (IIndexEntry[])getChildren(IIndexEntry.class); + return getChildren(IIndexEntry.class); } @Override public ITopic[] getTopics() { - return (ITopic[])getChildren(ITopic.class); + return getChildren(ITopic.class); } public void setKeyword(String keyword) { @@ -55,6 +55,6 @@ public class IndexEntry extends UAElement implements IIndexEntry2 { @Override public IIndexSee[] getSees() { - return (IIndexSee[])getChildren(IIndexSee.class); + return getChildren(IIndexSee.class); } } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java index 69a2ee256..4674bb455 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexManager.java @@ -40,7 +40,7 @@ public class IndexManager { private static final String ELEMENT_NAME_INDEX_PROVIDER = "indexProvider"; //$NON-NLS-1$ private static final String ATTRIBUTE_NAME_CLASS = "class"; //$NON-NLS-1$ - private Map<String, IndexContribution[]> indexContributionsByLocale = new HashMap<>(); + private Map<String, IIndexContribution[]> indexContributionsByLocale = new HashMap<>(); private Map<String, Index> indexesByLocale = new HashMap<>(); private AbstractIndexProvider[] indexProviders; @@ -69,8 +69,8 @@ public class IndexManager { * Returns all index contributions for the given locale, from all * providers. */ - public synchronized IndexContribution[] getIndexContributions(String locale) { - IndexContribution[] contributions = indexContributionsByLocale.get(locale); + public synchronized IIndexContribution[] getIndexContributions(String locale) { + IIndexContribution[] contributions = indexContributionsByLocale.get(locale); if (contributions == null) { contributions = readIndexContributions(locale); indexContributionsByLocale.put(locale, contributions); @@ -171,23 +171,22 @@ public class IndexManager { * either the contribution's id or its category's id is listed in the * ignoredIndexes, filter the contribution. */ - private void filterIndexContributions(List unfiltered) { - Set indexesToFilter = getIgnoredIndexContributions(); - ListIterator iter = unfiltered.listIterator(); + private void filterIndexContributions(List<IndexContribution> unfiltered) { + Set<String> indexesToFilter = getIgnoredIndexContributions(); + ListIterator<IndexContribution> iter = unfiltered.listIterator(); while (iter.hasNext()) { - IIndexContribution contribution = (IIndexContribution)iter.next(); + IIndexContribution contribution = iter.next(); if (indexesToFilter.contains(contribution.getId())) { iter.remove(); } } } - private Set getIgnoredIndexContributions() { + private Set<String> getIgnoredIndexContributions() { HelpData helpData = HelpData.getProductHelpData(); if (helpData != null) { return helpData.getHiddenIndexes(); - } - else { + } else { HashSet<String> ignored = new HashSet<>(); String preferredIndexes = Platform.getPreferencesService().getString(HelpPlugin.PLUGIN_ID, HelpPlugin.IGNORED_INDEXES_KEY, "", null); //$NON-NLS-1$ if (preferredIndexes.length() > 0) { diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java index e1edd6011..b5d68375b 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 IBM Corporation and others. + * Copyright (c) 2009, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -112,6 +112,6 @@ public class IndexSee extends UAElement implements IIndexSee, Comparable { @Override public IIndexSubpath[] getSubpathElements() { - return (IIndexSubpath[])getChildren(IIndexSubpath.class); + return getChildren(IIndexSubpath.class); } } diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java index c5c333bce..8bfa726b9 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/toc/Toc.java @@ -36,7 +36,7 @@ public class Toc extends UAElement implements IToc2 { private ITocContribution contribution; private ITopic topic; - private Map href2TopicMap; + private Map<String, ITopic> href2TopicMap; public Toc(IToc src) { super(NAME, src); @@ -56,7 +56,7 @@ public class Toc extends UAElement implements IToc2 { /* * Creates a mapping of all topic hrefs to ITopics. */ - private Map createHref2TopicMap() { + private Map<String, ITopic> createHref2TopicMap() { Map<String, ITopic> map = new HashMap<>(); if (topic != null) { map.put(topic.getHref(), topic); @@ -112,7 +112,7 @@ public class Toc extends UAElement implements IToc2 { /* * Returns a mapping of all topic hrefs to ITopics. */ - private Map getHref2TopicMap() { + private Map<String, ITopic> getHref2TopicMap() { if (href2TopicMap == null) { href2TopicMap = createHref2TopicMap(); } @@ -181,18 +181,18 @@ public class Toc extends UAElement implements IToc2 { } return topic; } else { - return (ITopic) getHref2TopicMap().get(href); + return getHref2TopicMap().get(href); } } @Override public ITopic[] getTopics() { - return (ITopic[]) getChildren(ITopic.class); + return getChildren(ITopic.class); } @Override public ICriteria[] getCriteria() { - return (ICriteria[]) getChildren(ICriteria.class); + return getChildren(ICriteria.class); } public void setLabel(String label) { diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java b/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java index 9a4723300..193ff22cb 100644 --- a/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java +++ b/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java @@ -120,7 +120,7 @@ public class ProductPreferences { * plug-in that has the given helpDataFile and baseTOCS specified (these last * two may be null if not specified). */ - public static List getTocOrdering(String pluginId, String helpDataFile, String baseTOCS) { + public static List<String> getTocOrdering(String pluginId, String helpDataFile, String baseTOCS) { if (helpDataFile != null && helpDataFile.length() > 0) { String helpDataPluginId = pluginId; String helpDataPath = helpDataFile; |