diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java index a431eb5b906..7385ac10ee9 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/HelpPlugin.java @@ -83,8 +83,9 @@ public static TocManager getTocManager() { * Used to obtain Context Manager returns an instance of ContextManager */ public static ContextManager getContextManager() { - if (getDefault().contextManager == null) + if (getDefault().contextManager == null) { getDefault().contextManager = new ContextManager(); + } return getDefault().contextManager; } @@ -92,20 +93,23 @@ public static ContextManager getContextManager() { * Used to obtain the ContentExtensionManager */ public static ContentExtensionManager getContentExtensionManager() { - if (getDefault().contentExtensionManager == null) + if (getDefault().contentExtensionManager == null) { getDefault().contentExtensionManager = new ContentExtensionManager(); + } return getDefault().contentExtensionManager; } public static IndexManager getIndexManager() { - if (getDefault().indexManager == null) + if (getDefault().indexManager == null) { getDefault().indexManager = new IndexManager(); + } return getDefault().indexManager; } public static CriteriaManager getCriteriaManager() { - if (getDefault().criteriaManager == null) + if (getDefault().criteriaManager == null) { getDefault().criteriaManager = new CriteriaManager(); + } return getDefault().criteriaManager; } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java index 8f6bc7b91ac..b674de13281 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java @@ -234,14 +234,13 @@ private Map loadContextsFromInputStream(ContextFile descriptor, IUAElement[] children = root.getChildren(); Map contexts = new HashMap<>(); for (int i=0;i getRequiredAttributes() { private class NormalizeHandler extends ProcessorHandler { @Override public short handle(UAElement element, String id) { - if (element instanceof Context) { - Context context = (Context)element; + if (element instanceof Context context) { IUAElement[] children = context.getChildren(); if (children.length > 0 && Context.ELEMENT_DESCRIPTION.equals(((UAElement)children[0]).getElementName())) { StringBuilder buf = new StringBuilder(); @@ -321,8 +319,7 @@ else if (node.getNodeType() == Node.ELEMENT_NODE) { description.appendChild(document.createTextNode(buf.toString())); } } - else if (element instanceof Topic) { - Topic topic = (Topic)element; + else if (element instanceof Topic topic) { String href = topic.getHref(); if (href != null) { int index = id.indexOf('/', 1); diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java index a39dc5fb18b..3f57b55d34e 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java @@ -45,8 +45,9 @@ public class ContextManager { public ContextManager() { - if (HelpPlugin.DEBUG_CONTEXT) + if (HelpPlugin.DEBUG_CONTEXT) { checkContextProviders(); + } } /* @@ -88,8 +89,9 @@ public IContext getContext(String contextId, String locale) { String id = contextId; ArrayList potentialMatches = new ArrayList<>(); - if ((index = contextId.lastIndexOf('.'))>-1) + if ((index = contextId.lastIndexOf('.'))>-1) { id = contextId.substring(index+1); + } String warning = "Registered Context Provider IDs:\n"; //$NON-NLS-1$ Iterator iter = contextIDsByPluginId.keySet().iterator(); @@ -109,8 +111,9 @@ public IContext getContext(String contextId, String locale) { warning+="--------------------------------"; //$NON-NLS-1$ System.out.println(warning); - if (!potentialMatches.isEmpty()) + if (!potentialMatches.isEmpty()) { System.out.println("The ID searched is "+contextId+". Did you mean to call setHelp with:\n"+potentialMatches); //$NON-NLS-1$ //$NON-NLS-2$ + } } return null; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java index 4b4038dec8b..3fe629f40a0 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFile.java @@ -44,9 +44,10 @@ public String getPluginId() { } public InputStream getInputStream() throws IOException { - if (pluginId != null) + if (pluginId != null) { return ResourceLocator.openFromPlugin(pluginId, file, locale); - else + } else { return new FileInputStream(file); + } } } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFileProvider.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFileProvider.java index 8b5395d393b..590e2f06a87 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFileProvider.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaDefinitionFileProvider.java @@ -57,8 +57,9 @@ public ICriteriaDefinitionContribution[] getCriteriaDefinitionContributions(Stri // Use the contained exception. Exception x = spe; - if (spe.getException() != null) + if (spe.getException() != null) { x = spe.getException(); + } ILog.of(getClass()).error(buffer.toString(), x); } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java index 4cc470704e7..4532cbf9d4e 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/criteria/CriteriaManager.java @@ -81,8 +81,9 @@ public void addCriteriaValues(ICriteria[] criteria, String locale){ List criterionValues = criterion.getCriterionValues(); Set existedValues = criteriaInLocale.get(criterionName); - if (null == existedValues) + if (null == existedValues) { existedValues = new HashSet<>(); + } existedValues.addAll(criterionValues); criteriaInLocale.put(criterionName, existedValues); } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java index 7b6e387c4cf..c0fa2ddd459 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/Index.java @@ -50,7 +50,9 @@ public IIndexEntry[] getEntries() { * @return the entry with matching keyword or null */ public IndexEntry getSeeTarget(IndexSee see) { - if (children == null) getChildren(); + if (children == null) { + getChildren(); + } String keyword = see.getKeyword(); for (Iterator iter = children.iterator(); iter.hasNext();) { UAElement next = iter.next(); diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java index 2edbb8d1317..55a8554bd4c 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java @@ -211,8 +211,7 @@ boolean isValidSeeReference(IndexSee see) { private static class NormalizeHandler extends ProcessorHandler { @Override public short handle(UAElement element, String id) { - if (element instanceof Topic) { - Topic topic = (Topic)element; + if (element instanceof Topic topic) { String href = topic.getHref(); if (href != null) { int index = id.indexOf('/', 1); @@ -295,8 +294,7 @@ else if (Character.isLetter(c)) { * used for sorting. */ private String getLabel(IUAElement element) { - if (element instanceof Topic) { - Topic topic = (Topic)element; + if (element instanceof Topic topic) { if (topic.getLabel() == null) { ITopic topic2 = HelpPlugin.getTocManager().getTopic(topic.getHref(), locale); if (topic2 != null) { diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java index 01014851ab3..35e71e75a66 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFile.java @@ -45,9 +45,10 @@ public String getPluginId() { } public InputStream getInputStream() throws IOException { - if (pluginId != null) + if (pluginId != null) { return ResourceLocator.openFromPlugin(pluginId, file, locale); - else + } else { return new FileInputStream(file); + } } } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileProvider.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileProvider.java index 9d25e39c7da..79ab48cac86 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileProvider.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileProvider.java @@ -57,8 +57,9 @@ public IIndexContribution[] getIndexContributions(String locale) { // Use the contained exception. Exception x = spe; - if (spe.getException() != null) + if (spe.getException() != null) { x = spe.getException(); + } ILog.of(getClass()).error(buffer.toString(), x); } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java index 458feca777a..a9e46029382 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java @@ -46,8 +46,9 @@ public static String[] collectExtraDocuments(TocFile tocFile) { } Bundle pluginDesc = Platform.getBundle(pluginID); if (pluginDesc == null || pluginDesc.getState() == Bundle.INSTALLED - || pluginDesc.getState() == Bundle.UNINSTALLED) + || pluginDesc.getState() == Bundle.UNINSTALLED) { return new String[0]; + } String directory = HrefUtil.getResourcePathFromHref(dir); if (directory == null) { // the root - all files in a zip should be indexed diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java index 9042e6afd8c..75e59dc5e4b 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/HrefUtil.java @@ -23,11 +23,13 @@ public class HrefUtil { */ public static String normalizeDirectoryHref(String pluginID, String dir) { // "" is treated as if extra directory was not provided - if (dir == null || dir.length() <= 0) + if (dir == null || dir.length() <= 0) { return null; + } // "." means all the files in the plugin - if (".".equals(dir)) //$NON-NLS-1$ + if (".".equals(dir)) { //$NON-NLS-1$ dir = ""; //$NON-NLS-1$ + } // remove not needed trailing separator if (dir.length() > 0 && dir.lastIndexOf('/') == dir.length() - 1) { dir = dir.substring(0, dir.length() - 1); @@ -47,18 +49,21 @@ public static String normalizeDirectoryHref(String pluginID, String dir) { * /pluginID/path[#anchorID] */ public final static String normalizeHref(String pluginID, String href) { - if (href == null) + if (href == null) { return null; + } if (href.startsWith("http:") //$NON-NLS-1$ || href.startsWith("https:") //$NON-NLS-1$ || href.startsWith("file:") //$NON-NLS-1$ - || href.startsWith("jar:")) //$NON-NLS-1$ + || href.startsWith("jar:")) { //$NON-NLS-1$ // external doc return href; + } href = normalizeDirectoryPath(href); - if (href.startsWith("/")) //$NON-NLS-1$ + if (href.startsWith("/")) { //$NON-NLS-1$ // already normalized return href; + } if (href.startsWith("../")) { //$NON-NLS-1$ return href.substring(2); } @@ -82,11 +87,13 @@ public final static String normalizeHref(String pluginID, String href) { * @return plugin ID, or null */ public static String getPluginIDFromHref(String href) { - if (href == null || href.length() < 2 || href.charAt(0) != '/') + if (href == null || href.length() < 2 || href.charAt(0) != '/') { return null; + } int secondSlashIx = href.indexOf("/", 1); //$NON-NLS-1$ - if (secondSlashIx < 0) // href is /pluginID + if (secondSlashIx < 0) { // href is /pluginID return href.substring(1); + } // href is /pluginID/path[#anchorID] return href.substring(1, secondSlashIx); } @@ -99,19 +106,24 @@ public static String getPluginIDFromHref(String href) { * @return relative resource path, or null */ public static String getResourcePathFromHref(String href) { - if (href == null) + if (href == null) { return null; + } // drop anchor id int anchorIx = href.lastIndexOf("#"); //$NON-NLS-1$ - if (anchorIx >= 0) //anchor exists, drop it + if (anchorIx >= 0) { //anchor exists, drop it href = href.substring(0, anchorIx); - if (href.length() < 2 || href.charAt(0) != '/') + } + if (href.length() < 2 || href.charAt(0) != '/') { return null; + } int secondSlashIx = href.indexOf("/", 1); //$NON-NLS-1$ - if (secondSlashIx < 0) // href is /pluginID + if (secondSlashIx < 0) { // href is /pluginID return null; - if (secondSlashIx + 1 < href.length()) // href is /pluginID/path + } + if (secondSlashIx + 1 < href.length()) { // href is /pluginID/path return href.substring(secondSlashIx + 1); + } // href is /pluginID/ return ""; //$NON-NLS-1$ } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java index 57a299c035b..6a4b92903e0 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java @@ -154,8 +154,7 @@ private Map getLinkedContributionIds(List contr new ProcessorHandler() { @Override public short handle(UAElement element, String id) { - if (element instanceof Link) { - Link link = (Link)element; + if (element instanceof Link link) { String toc = link.getToc(); if (toc != null) { TocContribution srcContribution = getContribution(id); @@ -356,8 +355,7 @@ private void addExtraDocuments(TocContribution contribution, String[] extraDocum private class LinkHandler extends ProcessorHandler { @Override public short handle(UAElement element, String id) { - if (element instanceof Link) { - Link link = (Link)element; + if (element instanceof Link link) { UAElement parent = link.getParentElement(); if (parent != null) { String toc = link.getToc(); @@ -388,11 +386,10 @@ public short handle(UAElement element, String id) { private class AnchorHandler extends ProcessorHandler { @Override public short handle(UAElement element, String id) { - if (element instanceof Anchor) { + if (element instanceof Anchor anchor) { if (tocsToFilter.contains(id)) { return UNHANDLED; } - Anchor anchor = (Anchor)element; UAElement parent = anchor.getParentElement(); if (parent != null) { String anchorId = anchor.getId(); @@ -437,8 +434,7 @@ public short handle(UAElement element, String id) { private class NormalizeHandler extends ProcessorHandler { @Override public short handle(UAElement element, String id) { - if (element instanceof Topic) { - Topic topic = (Topic)element; + if (element instanceof Topic topic) { String href = topic.getHref(); if (href != null) { topic.setHref(normalize(href, id)); @@ -448,8 +444,7 @@ public short handle(UAElement element, String id) { return HANDLED_CONTINUE; } - else if (element instanceof Toc) { - Toc toc = (Toc)element; + else if (element instanceof Toc toc) { toc.setHref(id); String topic = toc.getTopic(); if (topic != null) { @@ -484,12 +479,10 @@ private void processCriteria(UAElement element, String id) { ITocContribution contribution = getContribution(id); String locale = contribution.getLocale(); ICriteria[] criteria = new ICriteria[0]; - if (element instanceof Topic) { - Topic topic = (Topic) element; + if (element instanceof Topic topic) { criteria = CriteriaProviderRegistry.getInstance().getAllCriteria(topic); } - else if (element instanceof Toc) { - Toc toc = (Toc) element; + else if (element instanceof Toc toc) { criteria = CriteriaProviderRegistry.getInstance().getAllCriteria(toc); } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileProvider.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileProvider.java index a76adde155c..191ad3e595e 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileProvider.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileProvider.java @@ -52,8 +52,7 @@ public ITocContribution[] getTocContributions(String locale) { } catch (Throwable t) { String locationInfo = ""; //$NON-NLS-1$ - if (t instanceof SAXParseException) { - SAXParseException spe = (SAXParseException) t; + if (t instanceof SAXParseException spe) { locationInfo = " at line " + spe.getLineNumber() //$NON-NLS-1$ + ", column " + spe.getColumnNumber(); //$NON-NLS-1$ } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java index 9fabb07cb39..f0ad2fb8f04 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java @@ -141,9 +141,8 @@ public synchronized ITopic getTopic(String href, String locale) { public synchronized int[] getTopicPath(String href, String locale) { ITopic topic = getTopic(href, locale); try { - if (topic != null && topic instanceof UAElement) { + if (topic != null && topic instanceof UAElement element) { List path = new ArrayList<>(); - UAElement element = (UAElement) topic; while (!(element instanceof Toc)) { UAElement parent = element.getParentElement(); path.add(Integer.valueOf(indexOf(parent, (Topic)element))); @@ -222,11 +221,12 @@ private synchronized TocContribution[] getAndCacheTocContributions(String locale contribution.setLocale(contrib[j].getLocale()); contribution.setPrimary(contrib[j].isPrimary()); IToc toc = contrib[j].getToc(); - Toc t = toc instanceof Toc ? (Toc)toc : (Toc)UAElementFactory.newElement(toc); + Toc t = toc instanceof Toc t2 ? t2 : (Toc)UAElementFactory.newElement(toc); t.setLinkTo(contrib[j].getLinkTo()); contribution.setToc(t); - if(!contributions.containsKey(contrib[j].getId())) + if(!contributions.containsKey(contrib[j].getId())) { contributions.put(contrib[j].getId(), contribution); + } } } catch (Throwable t) { diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocProviderComparator.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocProviderComparator.java index 31ab5467d62..32b6c770d86 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocProviderComparator.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocProviderComparator.java @@ -23,11 +23,12 @@ public class TocProviderComparator implements Comparator { @Override public int compare(AbstractTocProvider provider1, AbstractTocProvider provider2) { - if(provider1.getPriority()provider2.getPriority()) + } else if(provider1.getPriority()>provider2.getPriority()) { return 1; - else + } else { return 0; + } } } diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocSorter.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocSorter.java index 120ae59a1b3..fec44302a49 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocSorter.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/toc/TocSorter.java @@ -73,8 +73,7 @@ private Map createNameIdMap(Map categorized) { String key = iter.next(); Object value = categorized.get(key); ITocContribution toc; - if (value instanceof TocCategory) { - TocCategory category = (TocCategory)value; + if (value instanceof TocCategory category) { toc = category.get(0); } else { toc = (ITocContribution)value; diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java index e249ae2f7d8..5e4ebe5f192 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java @@ -404,8 +404,9 @@ private static boolean initializeRTL() { // Check if the user property is set. If not do not // rely on the vm. - if (System.getProperty("osgi.nl.user") == null) //$NON-NLS-1$ + if (System.getProperty("osgi.nl.user") == null) { //$NON-NLS-1$ return false; + } // guess from default locale String locale = Platform.getNL(); diff --git a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java index 52254e896ea..200e07aee2e 100644 --- a/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java +++ b/ua/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java @@ -81,8 +81,9 @@ public IHelpContentProducer getProducer() { if (producer == null) { try { Object o = config.createExecutableExtension("producer"); //$NON-NLS-1$ - if (o instanceof IHelpContentProducer) + if (o instanceof IHelpContentProducer) { producer = (IHelpContentProducer) o; + } } catch (CoreException ce) { ILog.of(getClass()) .error("Exception occurred creating help content producer for plug-in " //$NON-NLS-1$ @@ -102,8 +103,7 @@ public IHelpContentProducer getProducer() { // it will be recreated on demand synchronized (contentProducers) { Object obj = contentProducers.get(affectedPlugin); - if (obj instanceof ProducerDescriptor) { - ProducerDescriptor desc = (ProducerDescriptor) obj; + if (obj instanceof ProducerDescriptor desc) { desc.reset(); } } @@ -119,8 +119,9 @@ public IHelpContentProducer getProducer() { private static IHelpContentProducer getContentProducer(String pluginId) { synchronized (contentProducers) { Object obj = getProducerDescriptor(pluginId); - if (obj == null || obj == STATIC_DOCS_ONLY) + if (obj == null || obj == STATIC_DOCS_ONLY) { return null; + } return ((ProducerDescriptor) obj).getProducer(); } } @@ -205,10 +206,10 @@ private static ProducerDescriptor findContentProducer(IConfigurationElement [] e // try existing ones for (Iterator iter = contentProducers.values().iterator(); iter.hasNext();) { Object obj = iter.next(); - if (obj instanceof ProducerDescriptor) { - ProducerDescriptor desc = (ProducerDescriptor) obj; - if (desc.matches(refId)) + if (obj instanceof ProducerDescriptor desc) { + if (desc.matches(refId)) { return desc; + } } } // not created yet. Find the matching configuration element, @@ -219,8 +220,9 @@ private static ProducerDescriptor findContentProducer(IConfigurationElement [] e String id = elements[i].getDeclaringExtension().getUniqueIdentifier(); if (refId.equals(id)) { Object obj = getProducerDescriptor(elements[i].getContributor().getName()); - if (obj instanceof ProducerDescriptor) + if (obj instanceof ProducerDescriptor) { return (ProducerDescriptor)obj; + } } } } @@ -264,8 +266,9 @@ public static InputStream openFromProducer(Bundle pluginDesc, String file, Strin */ public static InputStream openFromPlugin(String pluginId, String file, String locale) { Bundle bundle = Platform.getBundle(pluginId); - if (bundle != null) + if (bundle != null) { return openFromPlugin(bundle, file, locale); + } return null; } @@ -309,8 +312,9 @@ public static InputStream openFromZip(Bundle pluginDesc, String zip, String file cache.put(pluginID + '/' + pathPrefix.get(i) + zip, cached); } - if (cached == ZIP_NOT_FOUND || cached.toString().startsWith("jar:")) //$NON-NLS-1$ + if (cached == ZIP_NOT_FOUND || cached.toString().startsWith("jar:")) { //$NON-NLS-1$ continue; + } // cached should be a zip file that is actually on the filesystem // now check if the file is in this zip @@ -348,12 +352,13 @@ public static InputStream openFromPlugin(Bundle pluginDesc, String file, String ArrayList pathPrefix = getPathPrefix(locale); URL flatFileURL = find(pluginDesc, IPath.fromOSString(file), pathPrefix); - if (flatFileURL != null) + if (flatFileURL != null) { try { return flatFileURL.openStream(); } catch (IOException e) { return null; } + } return null; } @@ -368,8 +373,9 @@ public static URL find(Bundle pluginDesc, IPath flatFilePath, ArrayList // try to find the actual file. for (int i = 0; i < pathPrefix.size(); i++) { URL url = FileLocator.find(pluginDesc, IPath.fromOSString(pathPrefix.get(i) + flatFilePath), null); - if (url != null) + if (url != null) { return url; + } } return null; } @@ -391,20 +397,25 @@ public static ArrayList getPathPrefix(String locale) { // now String ws = Platform.getWS(); String os = Platform.getOS(); - if (locale == null) + if (locale == null) { locale = Platform.getNL(); + } - if (ws != null) + if (ws != null) { pathPrefix.add("ws/" + ws + '/'); //$NON-NLS-1$ + } - if (os != null && !os.equals("OS_UNKNOWN")) //$NON-NLS-1$ + if (os != null && !os.equals("OS_UNKNOWN")) { //$NON-NLS-1$ pathPrefix.add("os/" + os + '/'); //$NON-NLS-1$ + } - if (locale != null && locale.length() >= 5) + if (locale != null && locale.length() >= 5) { pathPrefix.add("nl/" + locale.substring(0, 2) + '/' + locale.substring(3, 5) + '/'); //$NON-NLS-1$ + } - if (locale != null && locale.length() >= 2) + if (locale != null && locale.length() >= 2) { pathPrefix.add("nl/" + locale.substring(0, 2) + '/'); //$NON-NLS-1$ + } // the plugin root pathPrefix.add(""); //$NON-NLS-1$ @@ -432,13 +443,15 @@ public static Set findTopicPaths(Bundle pluginDesc, String directory, St } private static void findTopicPaths(Bundle pluginDesc, String directory, String locale, Set paths) { - if (directory.endsWith("/")) //$NON-NLS-1$ + if (directory.endsWith("/")) { //$NON-NLS-1$ directory = directory.substring(0, directory.length() - 1); + } ArrayList pathPrefix = getPathPrefix(locale); for (int i = 0; i < pathPrefix.size(); i++) { String path = pathPrefix.get(i) + directory; - if (path.length() == 0) + if (path.length() == 0) { path = "/"; //$NON-NLS-1$ + } Enumeration entries = pluginDesc.getEntryPaths(path); if (entries != null) { while (entries.hasMoreElements()) {