[nobug] adopt some generics
diff --git a/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF b/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF index d0ac23e..17f195f 100644 --- a/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF +++ b/core/bundles/org.eclipse.wst.sse.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.wst.sse.core; singleton:=true -Bundle-Version: 1.2.500.qualifier +Bundle-Version: 1.2.600.qualifier Bundle-Activator: org.eclipse.wst.sse.core.internal.SSECorePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin
diff --git a/core/bundles/org.eclipse.wst.sse.core/pom.xml b/core/bundles/org.eclipse.wst.sse.core/pom.xml index 5360ced..1f4af17 100644 --- a/core/bundles/org.eclipse.wst.sse.core/pom.xml +++ b/core/bundles/org.eclipse.wst.sse.core/pom.xml
@@ -21,7 +21,7 @@ <groupId>org.eclipse.webtools.sourceediting</groupId> <artifactId>org.eclipse.wst.sse.core</artifactId> - <version>1.2.500-SNAPSHOT</version> + <version>1.2.600-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <build>
diff --git a/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTagParser.java b/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTagParser.java index c4ac4d0..c402a8a 100644 --- a/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTagParser.java +++ b/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTagParser.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. + * Copyright (c) 2001, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -26,7 +26,7 @@ BlockMarker getBlockMarker(String tagName); - List getBlockMarkers(); + List<BlockMarker> getBlockMarkers(); void removeBlockMarker(BlockMarker marker);
diff --git a/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTokenizer.java b/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTokenizer.java index b2ab942..b8d76c9 100644 --- a/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTokenizer.java +++ b/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/BlockTokenizer.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. + * Copyright (c) 2001, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -32,7 +32,7 @@ void beginBlockTagScan(String newTagName); - List getBlockMarkers(); + List<BlockMarker> getBlockMarkers(); ITextRegion getNextToken() throws IOException;
diff --git a/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/JSPCapableParser.java b/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/JSPCapableParser.java index 55ab2cf..cd44f92 100644 --- a/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/JSPCapableParser.java +++ b/core/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ltk/parser/JSPCapableParser.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2005 IBM Corporation and others. + * Copyright (c) 2001, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -24,7 +24,7 @@ * * @return */ - List getNestablePrefixes(); + List<TagMarker> getNestablePrefixes(); void removeNestablePrefix(String tagName); }
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java index 7ac70fe..2035001 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/TaglibController.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -18,6 +18,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.IDocumentSetupParticipant; @@ -124,7 +125,7 @@ DocumentInfo info = null; synchronized (_instance.fDocumentMap) { - info = (DocumentInfo) _instance.fDocumentMap.get(document); + info = _instance.fDocumentMap.get(document); } if (info != null) { // remember the buffer now @@ -162,27 +163,26 @@ return; } } - DocumentInfo info = null; + synchronized (fDocumentMap) { - Map.Entry[] entries = (Map.Entry[]) fDocumentMap.entrySet().toArray(new Map.Entry[fDocumentMap.size()]); - for (int i = 0; i < entries.length; i++) { - info = (DocumentInfo) entries[i].getValue(); + Iterator<Entry<IDocument, DocumentInfo>> infos = fDocumentMap.entrySet().iterator(); + while(infos.hasNext()) { + Entry<IDocument, DocumentInfo> entry = infos.next(); /** * https://bugs.eclipse.org/bugs/show_bug.cgi?id=222137 * * Might be null if setup() has been called but * bufferCreated() has not, yet. */ - if (info != null && info.textFileBuffer != null && info.textFileBuffer.equals(buffer)) { - fDocumentMap.remove(entries[i].getKey()); + DocumentInfo info = entry.getValue(); + if (info.textFileBuffer != null && info.textFileBuffer.equals(buffer)) { + info.tldDocumentManager.clearCache(); + TaglibIndex.removeTaglibIndexListener(info); + infos.remove(); break; } } } - if (info != null) { - info.tldDocumentManager.clearCache(); - TaglibIndex.removeTaglibIndexListener(info); - } } /* @@ -244,7 +244,7 @@ public static IPath getLocation(IDocument document) { synchronized (_instance.fDocumentMap) { - DocumentInfo info = (DocumentInfo) _instance.fDocumentMap.get(document); + DocumentInfo info = _instance.fDocumentMap.get(document); if (info != null) return info.location; return null; @@ -262,9 +262,9 @@ IPath location = null; synchronized (_instance.fDocumentMap) { - Iterator docInfos = _instance.fDocumentMap.values().iterator(); + Iterator<DocumentInfo> docInfos = _instance.fDocumentMap.values().iterator(); while (docInfos.hasNext() && location == null) { - DocumentInfo info = (DocumentInfo) docInfos.next(); + DocumentInfo info = docInfos.next(); if (info.tldDocumentManager.equals(manager)) location = info.location; } @@ -277,7 +277,7 @@ if (_instance == null) return null; synchronized (_instance.fDocumentMap) { - DocumentInfo info = (DocumentInfo) _instance.fDocumentMap.get(document); + DocumentInfo info = _instance.fDocumentMap.get(document); if (info != null) return info.tldDocumentManager; return null; @@ -309,9 +309,9 @@ IFileBufferListener fBufferListener; - Map fDocumentMap; + Map<IDocument, DocumentInfo> fDocumentMap; - List fJSPdocuments; + List<IDocument> fJSPdocuments; /* * This constructor is only to be called as part of the FileBuffer @@ -320,8 +320,8 @@ public TaglibController() { super(); fBufferListener = new FileBufferListener(); - fJSPdocuments = new ArrayList(1); - fDocumentMap = new HashMap(1); + fJSPdocuments = new ArrayList<>(1); + fDocumentMap = new HashMap<>(1); }
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMDocumentFactoryTLD.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMDocumentFactoryTLD.java index 790bbfc..3c67cca 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMDocumentFactoryTLD.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMDocumentFactoryTLD.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -385,7 +385,7 @@ ed.setPath(getContainedText(child)); } else if (nodeName.equals(JSP20TLDNames.TAG_EXTENSION)) { - ed.getExtensions().add(child); + ed.getExtensions().add(getContainedText(child)); } } child = child.getNextSibling(); @@ -483,7 +483,7 @@ ed.setSmallIcon(getContainedText(child)); } else if (nodeName.equals(JSP20TLDNames.TAG_EXTENSION) && child.getNodeType() == Node.ELEMENT_NODE) { - ed.getExtensions().add(child); + ed.getExtensions().add(getContainedText(child)); } else if (nodeName.equals(JSP20TLDNames.DYNAMIC_ATTRIBUTES) && child.hasChildNodes()) { ed.setDynamicAttributes(getContainedText(child));
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMElementDeclarationImpl.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMElementDeclarationImpl.java index 75b98dc..cfbe365 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMElementDeclarationImpl.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/CMElementDeclarationImpl.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.JSP12TLDNames; import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument; import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration; +import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDVariable; import org.eclipse.wst.sse.core.utils.StringUtils; import org.eclipse.wst.xml.core.internal.contentmodel.CMContent; import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType; @@ -52,7 +53,7 @@ private String fPath = null; - private List fTagExtensions = new ArrayList(0); + private List<String> fTagExtensions = new ArrayList<>(0); /** * since JSP 1.2 */ @@ -80,7 +81,7 @@ /** * since JSP 1.2 */ - private List variables; + private List<TLDVariable> variables; /** * since JSP 2.0 @@ -198,7 +199,7 @@ /** * @return Returns the extensions. */ - public List getExtensions() { + public List<String> getExtensions() { return fTagExtensions; } @@ -391,9 +392,9 @@ * * @return Returns a List */ - public List getVariables() { + public List<TLDVariable> getVariables() { if (variables == null) { - variables = new ArrayList(); + variables = new ArrayList<>(); } return variables; } @@ -504,7 +505,7 @@ * @param variables * The variables to set */ - public void setVariables(List variables) { + public void setVariables(List<TLDVariable> variables) { this.variables = variables; }
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java index 7328a8d..db2cd12 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/TLDCMDocumentManager.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2012 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -240,7 +240,7 @@ if (getIncludes().isEmpty()) filePath = FacetModuleCoreSupport.resolve(modelBaseLocation, includedFile); else - filePath = FacetModuleCoreSupport.resolve((IPath) getIncludes().peek(), includedFile); + filePath = FacetModuleCoreSupport.resolve(getIncludes().peek(), includedFile); } // check for "loops" @@ -298,9 +298,9 @@ } else { // Add from that saved list of uris/prefixes/documents - List references = (List) fTLDCMReferencesMap.get(filePath); + List<TLDCMDocumentReference> references = fTLDCMReferencesMap.get(filePath); for (int i = 0; references != null && i < references.size(); i++) { - TLDCMDocumentReference reference = (TLDCMDocumentReference) references.get(i); + TLDCMDocumentReference reference = references.get(i); /* * The uri might not be resolved properly if * relative to the JSP fragment. @@ -537,7 +537,7 @@ fLocalParser.addBlockMarker(new BlockMarker(marker.getTagName(), null, marker.getContext(), marker.isCaseSensitive())); } if (fParentParser instanceof JSPCapableParser && fLocalParser instanceof JSPCapableParser) { - TagMarker[] knownPrefixes = (TagMarker[]) ((JSPCapableParser) fParentParser).getNestablePrefixes().toArray(new TagMarker[0]); + TagMarker[] knownPrefixes = ((JSPCapableParser) fParentParser).getNestablePrefixes().toArray(new TagMarker[0]); for (int i = 0; i < knownPrefixes.length; i++) { ((JSPCapableParser) fLocalParser).addNestablePrefix(new TagMarker(knownPrefixes[i].getTagName(), null)); } @@ -584,9 +584,13 @@ static final boolean _debugCache = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/tldcmdocument/cache")); //$NON-NLS-1$ //$NON-NLS-2$ // will hold the prefixes banned by the specification; taglibs may not use // them - protected static List bannedPrefixes = null; + protected static List<String> bannedPrefixes = null; - private static Hashtable fCache = null; + /** + * Map of either TLDCacheEntrys or WeakReferences to TLD + * CMDocuments, depending on the known open files referring to them + */ + private static Map<Object, ?> fSharedCache = null; final String XMLNS = "xmlns:"; //$NON-NLS-1$ final String URN_TAGDIR = "urn:jsptagdir:"; final String URN_TLD = "urn:jsptld:"; @@ -596,7 +600,7 @@ final int URN_TLD_LENGTH = URN_TLD.length(); static { - bannedPrefixes = new ArrayList(7); + bannedPrefixes = new ArrayList<>(7); bannedPrefixes.add("jsp"); //$NON-NLS-1$ bannedPrefixes.add("jspx"); //$NON-NLS-1$ bannedPrefixes.add("java"); //$NON-NLS-1$ @@ -609,14 +613,14 @@ /** * Gets all of the known documents. * - * @return Returns a Hashtable of either TLDCacheEntrys or WeakReferences + * @return Returns a map of either TLDCacheEntrys or WeakReferences * to TLD CMDocuments */ - public static Hashtable getSharedDocumentCache() { - if (fCache == null) { - fCache = new Hashtable(); + public static Map getSharedDocumentCache() { + if (fSharedCache == null) { + fSharedCache = new HashMap<>(); } - return fCache; + return fSharedCache; } @@ -659,20 +663,20 @@ /** * The locally-know list of CMDocuments */ - private Hashtable fDocuments = null; + private Hashtable<Object, CMDocument> fDocuments = null; // timestamp cache to prevent excessive reparsing // of included files // IPath (filepath) > Long (modification stamp) HashMap fInclude2TimestampMap = new HashMap(); - private Stack fIncludes = null; + private Stack<IPath> fIncludes = null; private XMLSourceParser fParser = null; private List fTaglibTrackers = null; - Map fTLDCMReferencesMap = new HashMap(); + Map<IPath, List<TLDCMDocumentReference>> fTLDCMReferencesMap = new HashMap<>(); boolean fProcessIncludes = true; boolean preludesHandled = false; @@ -872,8 +876,8 @@ return fCMDocumentBuilder; } - public List getCMDocumentTrackers(int offset) { - List validDocs = new ArrayList(); + public List<TaglibTracker> getCMDocumentTrackers(int offset) { + List<TaglibTracker> validDocs = new ArrayList<>(); Object[] alldocs = getTaglibTrackers().toArray(); for (int i = 0; i < alldocs.length; i++) { TaglibTracker aTracker = (TaglibTracker) alldocs[i]; @@ -884,8 +888,8 @@ return validDocs; } - public List getCMDocumentTrackers(String prefix, int offset) { - List validDocs = new ArrayList(); + public List<TaglibTracker> getCMDocumentTrackers(String prefix, int offset) { + List<TaglibTracker> validDocs = new ArrayList<>(); Object[] alldocs = getTaglibTrackers().toArray(); for (int i = 0; i < alldocs.length; i++) { TaglibTracker aTracker = (TaglibTracker) alldocs[i]; @@ -929,7 +933,7 @@ IPath getCurrentParserPath() { IPath path = null; if (!getIncludes().isEmpty()) { - path = (IPath) getIncludes().peek(); + path = getIncludes().peek(); } else { path = TaglibController.getLocation(this); @@ -951,7 +955,7 @@ */ public Hashtable getDocuments() { if (fDocuments == null) - fDocuments = new Hashtable(); + fDocuments = new Hashtable<>(); return fDocuments; } @@ -960,9 +964,9 @@ * * @return Returns a Stack */ - protected Stack getIncludes() { + protected Stack<IPath> getIncludes() { if (fIncludes == null) - fIncludes = new Stack(); + fIncludes = new Stack<>(); return fIncludes; } @@ -1003,17 +1007,18 @@ if (getParser() != null) { IncludeHelper includeHelper = new IncludeHelper(anchor, getParser()); includeHelper.parse(preludes[i]); - List references = includeHelper.taglibReferences; + List<TLDCMDocumentReference> references = includeHelper.taglibReferences; fTLDCMReferencesMap.put(preludes[i], references); if (getParser() instanceof JSPCapableParser) { for (int j = 0; j < references.size(); j++) { - TLDCMDocumentReference reference = (TLDCMDocumentReference) references.get(j); + TLDCMDocumentReference reference = references.get(j); ((JSPCapableParser) getParser()).addNestablePrefix(new TagMarker(reference.prefix + ":")); //$NON-NLS-1$ } } } - else + else { Logger.log(Logger.WARNING, "Warning: parser text was requested by " + getClass().getName() + " but none was available; taglib support disabled"); //$NON-NLS-1$ //$NON-NLS-2$ + } getIncludes().pop(); } } @@ -1129,10 +1134,12 @@ } public void setSourceParser(XMLSourceParser parser) { - if (fParser != null) + if (fParser != null) { fParser.removeStructuredDocumentRegionHandler(getStructuredDocumentRegionHandler()); + } fParser = parser; - if (fParser != null) + if (fParser != null) { fParser.addStructuredDocumentRegionHandler(getStructuredDocumentRegionHandler()); + } } }
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/provisional/TLDElementDeclaration.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/provisional/TLDElementDeclaration.java index 55d5519..1aeecf0 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/provisional/TLDElementDeclaration.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/contentmodel/tld/provisional/TLDElementDeclaration.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -68,11 +68,11 @@ /** * Zero or more extensions that provide extra information about this tag, - * for tool consumption + * for tool consumption (must be some other tool) * * @see JSP 2.0 */ - List getExtensions(); + List<String> getExtensions(); /** * Optional tag-specific information @@ -131,5 +131,5 @@ * @see JSP 1.2 * @return List of TLDVariables */ - List getVariables(); + List<TLDVariable> getVariables(); }
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java index f4bfbbb..79a6baf 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/ProjectDescription.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2018 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -667,7 +667,7 @@ * Lookups/enumerations will be redirected to the corresponding * ProjectDescription instances */ - Set fClasspathProjects = null; + Set<IProject> fClasspathProjects = null; /** Holds references by URI to JARs */ Hashtable fClasspathReferences; @@ -770,7 +770,7 @@ references.put(key, urlRecord); } } - IProject[] buildpathProjects = (IProject[]) fClasspathProjects.toArray(new IProject[fClasspathProjects.size()]); + IProject[] buildpathProjects = fClasspathProjects.toArray(new IProject[fClasspathProjects.size()]); for (int i = 0; i < buildpathProjects.length; i++) { if (!projectsProcessed.contains(buildpathProjects[i]) && buildpathProjects[i].isAccessible()) { projectsProcessed.add(buildpathProjects[i]); @@ -1178,9 +1178,9 @@ return info; } - List getAvailableTaglibRecords(IPath path) { + List<ITaglibRecord> getAvailableTaglibRecords(IPath path) { ensureUpTodate(); - Collection records = null; + Collection<ITaglibRecord> records = null; try { float jspVersion = DeploymentDescriptorPropertyCache.getInstance().getJSPVersion(path); LOCK.acquire(); @@ -2194,7 +2194,7 @@ writer.write(BUILDPATH_ENTRIES + "|" + fBuildPathEntryCount); //$NON-NLS-1$ writer.write('\n'); //$NON-NLS-1$ - IProject[] projects = (IProject[]) fClasspathProjects.toArray(new IProject[0]); + IProject[] projects = fClasspathProjects.toArray(new IProject[0]); for (int i = 0; i < projects.length; i++) { writer.write(BUILDPATH_PROJECT); writer.write("|"); //$NON-NLS-1$
diff --git a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java index 9a4585e..330902a 100644 --- a/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java +++ b/web/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/taglib/TaglibIndex.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2014 IBM Corporation and others. + * Copyright (c) 2005, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -69,7 +69,7 @@ */ public final class TaglibIndex { class ClasspathChangeListener implements IElementChangedListener { - List projectsIndexed = new ArrayList(1); + List<IProject> projectsIndexed = new ArrayList<>(1); public void elementChanged(ElementChangedEvent event) { if (!isIndexAvailable()) @@ -113,7 +113,7 @@ runner.run(new Runnable() { public void run() { IJavaProject proj = (IJavaProject) element; - ProjectDescription description = (ProjectDescription) fProjectDescriptions.remove(proj.getProject()); + ProjectDescription description = fProjectDescriptions.remove(proj.getProject()); if (description != null) { if (_debugIndexCreation) { Logger.log(Logger.INFO, "removing index of " + description.fProject.getName()); //$NON-NLS-1$ @@ -189,7 +189,7 @@ description = getDescription((IProject) resource); } if (description != null && !frameworkIsShuttingDown()) { - projectsIndexed.add(resource); + projectsIndexed.add((IProject) resource); description.queueElementChanged(delta); } } @@ -271,7 +271,7 @@ if (_debugIndexCreation) { Logger.log(Logger.INFO, "TaglibIndex noticed " + projects[i].getName() + " is about to be deleted/closed"); //$NON-NLS-1$ //$NON-NLS-2$ } - ProjectDescription description = (ProjectDescription) fProjectDescriptions.remove(projects[i]); + ProjectDescription description = fProjectDescriptions.remove(projects[i]); if (description != null) { if (_debugIndexCreation) { Logger.log(Logger.INFO, "removing index of " + description.fProject.getName()); //$NON-NLS-1$ @@ -334,7 +334,7 @@ if (_debugIndexCreation) { Logger.log(Logger.INFO, "TaglibIndex noticed " + projects[i].getName() + " was removed or is no longer accessible"); //$NON-NLS-1$ //$NON-NLS-2$ } - ProjectDescription description = (ProjectDescription) fProjectDescriptions.remove(projects[i]); + ProjectDescription description = fProjectDescriptions.remove(projects[i]); if (description != null) { if (_debugIndexCreation) { Logger.log(Logger.INFO, "removing index of " + description.fProject.getName()); //$NON-NLS-1$ @@ -452,8 +452,9 @@ } } } + synchronized (TLDCMDocumentManager.getSharedDocumentCache()) { - Iterator values = TLDCMDocumentManager.getSharedDocumentCache().values().iterator(); + Iterator<?> values = TLDCMDocumentManager.getSharedDocumentCache().values().iterator(); while (values.hasNext()) { Object o = values.next(); if (o instanceof Reference) { @@ -639,7 +640,7 @@ private TaglibIndexDelta fCurrentTopLevelDelta = null; - Map fProjectDescriptions = null; + Map<IProject, ProjectDescription> fProjectDescriptions = null; private ResourceChangeListener fResourceChangeListener; @@ -684,7 +685,7 @@ removeIndexes(false); } - fProjectDescriptions = new Hashtable(); + fProjectDescriptions = new Hashtable<>(); fResourceChangeListener = new ResourceChangeListener(); fClasspathChangeListener = new ClasspathChangeListener(); fMemoryListener = new MemoryListener(); @@ -745,7 +746,7 @@ ProjectDescription description = null; try { LOCK.acquire(); - description = (ProjectDescription) fProjectDescriptions.get(project); + description = fProjectDescriptions.get(project); if (description == null) { // Once we've started indexing, we're dirty again if (fProjectDescriptions.isEmpty()) { @@ -810,7 +811,7 @@ ProjectDescription getDescription(IProject project) { ProjectDescription description = null; if (isInitialized()) { - description = (ProjectDescription) fProjectDescriptions.get(project); + description = fProjectDescriptions.get(project); } return description; } @@ -837,11 +838,11 @@ fTaglibIndexListeners = new ITaglibIndexListener[]{listener}; } else { - List listeners = new ArrayList(Arrays.asList(fTaglibIndexListeners)); + List<ITaglibIndexListener> listeners = new ArrayList<>(Arrays.asList(fTaglibIndexListeners)); if (!listeners.contains(listener)) { listeners.add(listener); } - fTaglibIndexListeners = (ITaglibIndexListener[]) listeners.toArray(new ITaglibIndexListener[0]); + fTaglibIndexListeners = listeners.toArray(new ITaglibIndexListener[0]); } } finally { @@ -855,7 +856,7 @@ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); if (project.isAccessible()) { ProjectDescription description = createDescription(project); - List availableRecords = description.getAvailableTaglibRecords(path); + List<ITaglibRecord> availableRecords = description.getAvailableTaglibRecords(path); // check web fragments, if there are any IProject[] projects = FacetModuleCoreSupport.getReferenced(project); @@ -868,7 +869,7 @@ } } - records = (ITaglibRecord[]) availableRecords.toArray(records); + records = availableRecords.toArray(records); } } return records; @@ -893,9 +894,9 @@ try { LOCK.acquire(); if (fTaglibIndexListeners != null) { - List listeners = new ArrayList(Arrays.asList(fTaglibIndexListeners)); + List<ITaglibIndexListener> listeners = new ArrayList<>(Arrays.asList(fTaglibIndexListeners)); listeners.remove(listener); - fTaglibIndexListeners = (ITaglibIndexListener[]) listeners.toArray(new ITaglibIndexListener[0]); + fTaglibIndexListeners = listeners.toArray(new ITaglibIndexListener[0]); } } finally { @@ -988,7 +989,7 @@ // remove any extraneous index files IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - List indexNames = new ArrayList(projects.length); + List<String> indexNames = new ArrayList<>(projects.length); if (staleOnly) { for (int i = 0; i < projects.length; i++) { if (projects[i].isAccessible()) { @@ -1065,9 +1066,9 @@ void clearProjectDescriptions() { try { LOCK.acquire(); - Iterator i = fProjectDescriptions.values().iterator(); + Iterator<ProjectDescription> i = fProjectDescriptions.values().iterator(); while (i.hasNext()) { - ProjectDescription description = (ProjectDescription) i.next(); + ProjectDescription description = i.next(); description.saveReferences(); }
diff --git a/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java b/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java index 290b5c9..af5aecb 100644 --- a/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java +++ b/xml/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -14,8 +14,6 @@ *******************************************************************************/ package org.eclipse.wst.xml.core.internal.parser; - - import java.io.StringReader; import java.util.ArrayList; import java.util.List; @@ -40,7 +38,6 @@ import org.eclipse.wst.xml.core.internal.Logger; import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; - /** * Takes input from the HTMLTokenizer and creates a tag list */ @@ -59,7 +56,7 @@ // protected List fRegions = null; // protected Object fInput = null; protected String fStringInput = null; - protected List fStructuredDocumentRegionHandlers; + protected List<StructuredDocumentRegionHandler> fStructuredDocumentRegionHandlers; protected BlockTokenizer fTokenizer = null; protected long startTime; @@ -70,7 +67,7 @@ */ public XMLSourceParser() { super(); - fStructuredDocumentRegionHandlers = new ArrayList(); + fStructuredDocumentRegionHandlers = new ArrayList<>(); } /** @@ -92,8 +89,9 @@ } public synchronized void addStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler) { - if (fStructuredDocumentRegionHandlers == null) - fStructuredDocumentRegionHandlers = new ArrayList(); + if (fStructuredDocumentRegionHandlers == null) { + fStructuredDocumentRegionHandlers = new ArrayList<>(); + } synchronized (fStructuredDocumentRegionHandlers) { fStructuredDocumentRegionHandlers.add(handler); } @@ -159,7 +157,7 @@ return null; } - public List getBlockMarkers() { + public List<BlockMarker> getBlockMarkers() { return getTokenizer().getBlockMarkers(); } @@ -209,7 +207,7 @@ * Return the full list of known regions. Typically getNodes should be * used instead of this method. */ - public List getRegions() { + public List<ITextRegion> getRegions() { IStructuredDocumentRegion headNode = null; if (!getTokenizer().isEOF()) { headNode = getDocumentRegions(); @@ -220,7 +218,7 @@ // memory consuming objects // but the new "getRegions" method is then more expensive. // I don't think its used much, though. - List localRegionsList = getRegions(headNode); + List<ITextRegion> localRegionsList = getRegions(headNode); primReset(); return localRegionsList; } @@ -231,8 +229,8 @@ * @param headNode * @return List */ - protected List getRegions(IStructuredDocumentRegion headNode) { - List allRegions = new ArrayList(); + protected List<ITextRegion> getRegions(IStructuredDocumentRegion headNode) { + List<ITextRegion> allRegions = new ArrayList<>(); IStructuredDocumentRegion currentNode = headNode; while (currentNode != null) { ITextRegionList nodeRegions = currentNode.getRegions(); @@ -248,9 +246,9 @@ * @deprecated - use the add/remove methods instead * @return java.util.List */ - public List getStructuredDocumentRegionHandlers() { + public List<StructuredDocumentRegionHandler> getStructuredDocumentRegionHandlers() { if (fStructuredDocumentRegionHandlers == null) { - fStructuredDocumentRegionHandlers = new ArrayList(0); + fStructuredDocumentRegionHandlers = new ArrayList<>(0); } return fStructuredDocumentRegionHandlers; }