1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Bug 567966 - CDT code clean up: type safety warnings

Generalize the type of elements and resolve type safety warnings

Change-Id: Ibbbdc26663a7fede9debef3ca5d1c79ca346608c
Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
This commit is contained in:
Alexander Fedorov 2020-10-24 16:37:11 +03:00
parent 87dff3db99
commit b8ba9605c6

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 Texas Instruments Incorporated and others. * Copyright (c) 2005, 2020 Texas Instruments Incorporated and others.
* *
* This program and the accompanying materials * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0 * are made available under the terms of the Eclipse Public License 2.0
@ -12,6 +12,7 @@
* Texas Instruments - initial API and implementation * Texas Instruments - initial API and implementation
* Intel Corporation - adaptation to new project model * Intel Corporation - adaptation to new project model
* IBM Corporation * IBM Corporation
* ArSysOp - rework to typed collections to fix type safety warnings
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.wizards; package org.eclipse.cdt.managedbuilder.ui.wizards;
@ -105,21 +106,21 @@ public final class MBSCustomPageManager {
/** /**
* Maps String IDs to IWizardPages * Maps String IDs to IWizardPages
*/ */
private static Map idToPageDataMap = null; private static Map<String, MBSCustomPageData> idToPageDataMap = null;
/** /**
* The set of pages that this manager knows about. * The set of pages that this manager knows about.
*/ */
private static Set pageSet = null; private static Set<MBSCustomPageData> pageSet = null;
/** /**
* Maps page IDs to the properties that page has set. * Maps page IDs to the properties that page has set.
*/ */
private static java.util.Map pageIDtoPagePropertiesMap = null; private static Map<String, Map<String, Object>> pageIDtoPagePropertiesMap = null;
private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.managedbuilder.ui.newWizardPages"; //$NON-NLS-1$ private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.managedbuilder.ui.newWizardPages"; //$NON-NLS-1$
private static List hiddenList; private static List<String> hiddenList;
/** /**
* *
@ -293,7 +294,7 @@ public final class MBSCustomPageManager {
* @since 3.0 * @since 3.0
*/ */
public static MBSCustomPageData getPageData(String pageID) { public static MBSCustomPageData getPageData(String pageID) {
return (MBSCustomPageData) idToPageDataMap.get(pageID); return idToPageDataMap.get(pageID);
} }
/** /**
@ -311,10 +312,10 @@ public final class MBSCustomPageManager {
return false; return false;
// first, find out what project type, toolchain, and nature have been set // first, find out what project type, toolchain, and nature have been set
Map pagePropertiesMap = (Map) pageIDtoPagePropertiesMap.get(PAGE_ID); Map<String, Object> pagePropertiesMap = pageIDtoPagePropertiesMap.get(PAGE_ID);
Object projectType = pagePropertiesMap.get(PROJECT_TYPE); Object projectType = pagePropertiesMap.get(PROJECT_TYPE);
List toolchainList = (List) pagePropertiesMap.get(TOOLCHAIN); List<IToolChain> toolchainList = (List<IToolChain>) pagePropertiesMap.get(TOOLCHAIN);
Object nature = pagePropertiesMap.get(NATURE); Object nature = pagePropertiesMap.get(NATURE);
// does the page follow nature and project type constraints? // does the page follow nature and project type constraints?
@ -327,9 +328,9 @@ public final class MBSCustomPageManager {
// otherwise, iterate through the toolchains to see if one matches // otherwise, iterate through the toolchains to see if one matches
for (int k = 0; k < toolchainData.length; k++) { for (int k = 0; k < toolchainData.length; k++) {
// check all toolchains, see if there is one for which we should be present // check all toolchains, see if there is one for which we should be present
Iterator toolchainIterator = toolchainList.iterator(); Iterator<IToolChain> toolchainIterator = toolchainList.iterator();
while (toolchainIterator.hasNext()) { while (toolchainIterator.hasNext()) {
IToolChain toolchain = (IToolChain) toolchainIterator.next(); IToolChain toolchain = toolchainIterator.next();
if (toolchain != null) { if (toolchain != null) {
String id = ManagedBuildManager.getIdFromIdAndVersion(toolchain.getId()); String id = ManagedBuildManager.getIdFromIdAndVersion(toolchain.getId());
String version = ManagedBuildManager.getVersionFromIdAndVersion(toolchain.getId()); String version = ManagedBuildManager.getVersionFromIdAndVersion(toolchain.getId());
@ -360,10 +361,10 @@ public final class MBSCustomPageManager {
* @see org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager#getPageProperty(String, String) * @see org.eclipse.cdt.managedbuilder.ui.wizards.MBSCustomPageManager#getPageProperty(String, String)
*/ */
public static void addPageProperty(String pageID, String key, Object data) { public static void addPageProperty(String pageID, String key, Object data) {
Map propertiesMap = (Map) pageIDtoPagePropertiesMap.get(pageID); Map<String, Object> propertiesMap = pageIDtoPagePropertiesMap.get(pageID);
if (propertiesMap == null) { if (propertiesMap == null) {
propertiesMap = new TreeMap(); propertiesMap = new TreeMap<>();
pageIDtoPagePropertiesMap.put(pageID, propertiesMap); pageIDtoPagePropertiesMap.put(pageID, propertiesMap);
} }
@ -391,7 +392,7 @@ public final class MBSCustomPageManager {
* @since 3.0 * @since 3.0
*/ */
public static Object getPageProperty(String pageID, String key) { public static Object getPageProperty(String pageID, String key) {
Map propertiesMap = (Map) pageIDtoPagePropertiesMap.get(pageID); Map<String, Object> propertiesMap = pageIDtoPagePropertiesMap.get(pageID);
if (propertiesMap != null) { if (propertiesMap != null) {
return propertiesMap.get(key); return propertiesMap.get(key);
@ -412,12 +413,12 @@ public final class MBSCustomPageManager {
public static IWizardPage getNextPage(String currentPageID) { public static IWizardPage getNextPage(String currentPageID) {
// find the current page in the set of pages // find the current page in the set of pages
MBSCustomPageData pageData = getPageData(currentPageID); MBSCustomPageData pageData = getPageData(currentPageID);
Iterator iterator = pageSet.iterator(); Iterator<MBSCustomPageData> iterator = pageSet.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
if (pageData.equals(iterator.next())) { if (pageData.equals(iterator.next())) {
IWizardPage nextPage = null; IWizardPage nextPage = null;
while (iterator.hasNext() && nextPage == null) { while (iterator.hasNext() && nextPage == null) {
MBSCustomPageData potentialPage = (MBSCustomPageData) iterator.next(); MBSCustomPageData potentialPage = iterator.next();
if (isPageVisible(potentialPage.getID())) if (isPageVisible(potentialPage.getID()))
nextPage = potentialPage.getWizardPage(); nextPage = potentialPage.getWizardPage();
} }
@ -455,14 +456,14 @@ public final class MBSCustomPageManager {
MBSCustomPageData pageData = getPageData(currentPageID); MBSCustomPageData pageData = getPageData(currentPageID);
MBSCustomPageData currentData = null; MBSCustomPageData currentData = null;
Iterator iterator = pageSet.iterator(); Iterator<MBSCustomPageData> iterator = pageSet.iterator();
// since Java has no concept of a reverse-iterator yet, we must keep a stack of the // since Java has no concept of a reverse-iterator yet, we must keep a stack of the
// pages we have visited, so that we can get them in reverse chronological order // pages we have visited, so that we can get them in reverse chronological order
Stack pageDataStack = new Stack(); Stack<MBSCustomPageData> pageDataStack = new Stack<>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
currentData = (MBSCustomPageData) iterator.next(); currentData = iterator.next();
if (currentData == pageData) { if (currentData == pageData) {
@ -494,7 +495,7 @@ public final class MBSCustomPageManager {
// use the stack to visit the previous pages // use the stack to visit the previous pages
while (pageDataStack.size() != 0 && !pageFound) { while (pageDataStack.size() != 0 && !pageFound) {
MBSCustomPageData potentialPage = (MBSCustomPageData) pageDataStack.pop(); MBSCustomPageData potentialPage = pageDataStack.pop();
if (isPageVisible(potentialPage.getID())) { if (isPageVisible(potentialPage.getID())) {
pageFound = true; pageFound = true;
@ -524,12 +525,12 @@ public final class MBSCustomPageManager {
public static IWizardPage[] getPages() { public static IWizardPage[] getPages() {
IWizardPage[] pages = new IWizardPage[pageSet.size()]; IWizardPage[] pages = new IWizardPage[pageSet.size()];
Iterator iterator = pageSet.iterator(); Iterator<MBSCustomPageData> iterator = pageSet.iterator();
int k = 0; int k = 0;
while (iterator.hasNext()) { while (iterator.hasNext()) {
MBSCustomPageData page = (MBSCustomPageData) iterator.next(); MBSCustomPageData page = iterator.next();
pages[k++] = page.getWizardPage(); pages[k++] = page.getWizardPage();
} }
@ -548,12 +549,12 @@ public final class MBSCustomPageManager {
* @see getPages() * @see getPages()
*/ */
public static IWizardPage[] getCustomPages() { public static IWizardPage[] getCustomPages() {
Set customPageSet = new LinkedHashSet(); Set<IWizardPage> customPageSet = new LinkedHashSet<>();
Iterator pageIterator = pageSet.iterator(); Iterator<MBSCustomPageData> pageIterator = pageSet.iterator();
while (pageIterator.hasNext()) { while (pageIterator.hasNext()) {
MBSCustomPageData page = (MBSCustomPageData) pageIterator.next(); MBSCustomPageData page = pageIterator.next();
if (!page.isStockPage()) { if (!page.isStockPage()) {
customPageSet.add(page.getWizardPage()); customPageSet.add(page.getWizardPage());
@ -561,13 +562,13 @@ public final class MBSCustomPageManager {
} }
Iterator iterator = customPageSet.iterator(); Iterator<IWizardPage> iterator = customPageSet.iterator();
IWizardPage[] pages = new IWizardPage[customPageSet.size()]; IWizardPage[] pages = new IWizardPage[customPageSet.size()];
int k = 0; int k = 0;
while (iterator.hasNext()) { while (iterator.hasNext()) {
pages[k++] = (IWizardPage) iterator.next(); pages[k++] = iterator.next();
} }
return pages; return pages;
@ -581,12 +582,12 @@ public final class MBSCustomPageManager {
* @since 3.0 * @since 3.0
*/ */
public static IRunnableWithProgress[] getOperations() { public static IRunnableWithProgress[] getOperations() {
Set operationSet = new LinkedHashSet(); Set<IRunnableWithProgress> operationSet = new LinkedHashSet<>();
Iterator pageIterator = pageSet.iterator(); Iterator<MBSCustomPageData> pageIterator = pageSet.iterator();
while (pageIterator.hasNext()) { while (pageIterator.hasNext()) {
MBSCustomPageData page = (MBSCustomPageData) pageIterator.next(); MBSCustomPageData page = pageIterator.next();
if (!page.isStockPage() && isPageVisible(page.getID())) { if (!page.isStockPage() && isPageVisible(page.getID())) {
if (page.getOperation() != null) { if (page.getOperation() != null) {
@ -599,13 +600,13 @@ public final class MBSCustomPageManager {
if (operationSet.size() == 0) if (operationSet.size() == 0)
return null; return null;
Iterator iterator = operationSet.iterator(); Iterator<IRunnableWithProgress> iterator = operationSet.iterator();
IRunnableWithProgress[] operations = new IRunnableWithProgress[operationSet.size()]; IRunnableWithProgress[] operations = new IRunnableWithProgress[operationSet.size()];
int k = 0; int k = 0;
while (iterator.hasNext()) { while (iterator.hasNext()) {
operations[k++] = (IRunnableWithProgress) iterator.next(); operations[k++] = iterator.next();
} }
return operations; return operations;
@ -621,10 +622,10 @@ public final class MBSCustomPageManager {
* @since 3.0 * @since 3.0
*/ */
public static void init() { public static void init() {
idToPageDataMap = new TreeMap(); idToPageDataMap = new TreeMap<>();
pageIDtoPagePropertiesMap = new TreeMap(); pageIDtoPagePropertiesMap = new TreeMap<>();
pageSet = new LinkedHashSet(); pageSet = new LinkedHashSet<>();
hiddenList = new ArrayList(); hiddenList = new ArrayList<>();
} }
// singleton class - do not use // singleton class - do not use