1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

autotools: Additional generification.

Properly generify now that o.e.text is generified. This alows removing a
number of suppressed warnings. In a few places it is better to use
wildcard than suppressing warnings.
Also remove DefaultNoDependencyCalculator as it was suppressing warnings
but better to remove directly as it's not use anywhere.

Change-Id: I70c4ac073ce5b6c2a45443372037fa61b7c36c76
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
Alexander Kurtakov 2015-12-14 08:49:09 +02:00
parent af49d7701a
commit 34281a96e0
18 changed files with 46 additions and 108 deletions

View file

@ -47,7 +47,7 @@ public class AutotoolsConfigurationBuilder extends ACBuilder {
} }
@Override @Override
protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor) protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor)
throws CoreException { throws CoreException {
IProject project = getProject(); IProject project = getProject();
if(!isCdtProjectCreated(project)) if(!isCdtProjectCreated(project))

View file

@ -1,45 +0,0 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.autotools.core;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
/**
* This is the dependency calculator used by the makefile generation system when
* nothing is defined for a tool.
*
* @since 2.0
*/
@SuppressWarnings("deprecation")
public class DefaultNoDependencyCalculator implements IManagedDependencyGenerator {
@Override
public IResource[] findDependencies(IResource resource, IProject project) {
// Never answers any dependencies
return null;
}
@Override
public int getCalculatorType() {
return TYPE_NODEPS;
}
@Override
public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
// Never answers this call with an actual value
return null;
}
}

View file

@ -29,11 +29,10 @@ public class FlagConfigureOption extends AbstractConfigurationOption {
this.value = name; this.value = name;
} }
@SuppressWarnings("unchecked")
private FlagConfigureOption(String name, AutotoolsConfiguration cfg, String value, ArrayList<String> children) { private FlagConfigureOption(String name, AutotoolsConfiguration cfg, String value, ArrayList<String> children) {
super(name, cfg); super(name, cfg);
this.value = value; this.value = value;
this.children = (ArrayList<String>) children.clone(); this.children = new ArrayList<>(children);
} }
@Override @Override

View file

@ -75,8 +75,7 @@ public class AutoconfAnnotationHover implements IAnnotationHover, IAnnotationHov
List<Annotation> exact= new ArrayList<>(); List<Annotation> exact= new ArrayList<>();
List<Annotation> including= new ArrayList<>(); List<Annotation> including= new ArrayList<>();
@SuppressWarnings("rawtypes") Iterator<?> e = model.getAnnotationIterator();
Iterator e= model.getAnnotationIterator();
while (e.hasNext()) { while (e.hasNext()) {
Object o= e.next(); Object o= e.next();
if (o instanceof Annotation) { if (o instanceof Annotation) {

View file

@ -18,8 +18,7 @@ import org.eclipse.ui.editors.text.TextFileDocumentProvider;
public class AutoconfDocumentProvider extends TextFileDocumentProvider { public class AutoconfDocumentProvider extends TextFileDocumentProvider {
public void shutdown() { public void shutdown() {
@SuppressWarnings("rawtypes") Iterator<?> e = getConnectedElementsIterator();
Iterator e= getConnectedElementsIterator();
while (e.hasNext()) while (e.hasNext())
disconnect(e.next()); disconnect(e.next());
} }

View file

@ -185,18 +185,18 @@ public class AutoconfEditor extends TextEditor implements IAutotoolsEditor, IPro
} }
} }
@Override @SuppressWarnings("unchecked")
@SuppressWarnings({ "rawtypes" }) @Override
public Object getAdapter(Class required) { public <T> T getAdapter(Class<T> required) {
if (ProjectionAnnotationModel.class.equals(required)) { if (ProjectionAnnotationModel.class.equals(required)) {
if (fProjectionSupport != null) { if (fProjectionSupport != null) {
Object result = fProjectionSupport.getAdapter(getSourceViewer(), required); Object result = fProjectionSupport.getAdapter(getSourceViewer(), required);
if (result != null) { if (result != null) {
return result; return (T) result;
} }
} }
} else if (IContentOutlinePage.class.equals(required)) { } else if (IContentOutlinePage.class.equals(required)) {
return getOutlinePage(); return (T) getOutlinePage();
} }
return super.getAdapter(required); return super.getAdapter(required);
} }

View file

@ -87,10 +87,9 @@ public class AutoconfErrorHandler implements IAutoconfErrorHandler {
public void removeExistingMarkers(int offset, int length) public void removeExistingMarkers(int offset, int length)
{ {
@SuppressWarnings("rawtypes") Iterator<Annotation> i = fAnnotationModel.getAnnotationIterator();
Iterator i = fAnnotationModel.getAnnotationIterator();
while (i.hasNext()) { while (i.hasNext()) {
Annotation annotation = (Annotation)i.next(); Annotation annotation = i.next();
Position p = fAnnotationModel.getPosition(annotation); Position p = fAnnotationModel.getPosition(annotation);
int pStart = p.getOffset(); int pStart = p.getOffset();
if (pStart >= offset && pStart < (offset + length)) { if (pStart >= offset && pStart < (offset + length)) {

View file

@ -49,8 +49,7 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
protected ISelection updateSelection(ISelection sel) { protected ISelection updateSelection(ISelection sel) {
ArrayList<AutoconfElement> newSelection= new ArrayList<>(); ArrayList<AutoconfElement> newSelection= new ArrayList<>();
if (sel instanceof IStructuredSelection) { if (sel instanceof IStructuredSelection) {
@SuppressWarnings("rawtypes") Iterator<?> iter = ((IStructuredSelection) sel).iterator();
Iterator iter= ((IStructuredSelection)sel).iterator();
for (;iter.hasNext();) { for (;iter.hasNext();) {
//ICElement elem= fInput.findEqualMember((ICElement)iter.next()); //ICElement elem= fInput.findEqualMember((ICElement)iter.next());
Object o = iter.next(); Object o = iter.next();

View file

@ -49,11 +49,10 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation
int yoursStart= offset; int yoursStart= offset;
@SuppressWarnings("rawtypes") Iterator<StyleRange> e = presentation.getAllStyleRangeIterator();
Iterator e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) { while (e.hasNext()) {
StyleRange range= (StyleRange) e.next(); StyleRange range= e.next();
int myStart= range.start; int myStart= range.start;
int myEnd= range.start + range.length -1; int myEnd= range.start + range.length -1;

View file

@ -157,7 +157,7 @@ public class ProjectionFileUpdater implements IProjectionListener {
AutoconfElement fInput= fEditor.getRootElement(); AutoconfElement fInput= fEditor.getRootElement();
if (fInput != null) { if (fInput != null) {
ProjectionAnnotationModel model= (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class); ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class);
if (model != null) { if (model != null) {
Map<AutoconfProjectionAnnotation, Position> additions= computeAdditions(fInput); Map<AutoconfProjectionAnnotation, Position> additions= computeAdditions(fInput);
model.removeAllAnnotations(); model.removeAllAnnotations();
@ -262,7 +262,7 @@ public class ProjectionFileUpdater implements IProjectionListener {
if (!isInstalled()) if (!isInstalled())
return; return;
ProjectionAnnotationModel model= (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class); ProjectionAnnotationModel model= fEditor.getAdapter(ProjectionAnnotationModel.class);
if (model == null) if (model == null)
return; return;
@ -398,10 +398,9 @@ public class ProjectionFileUpdater implements IProjectionListener {
private Map<AutoconfElement, List<AutoconfProjectionAnnotation>> createAnnotationMap(IAnnotationModel model) { private Map<AutoconfElement, List<AutoconfProjectionAnnotation>> createAnnotationMap(IAnnotationModel model) {
Map<AutoconfElement, List<AutoconfProjectionAnnotation>> map= new HashMap<>(); Map<AutoconfElement, List<AutoconfProjectionAnnotation>> map= new HashMap<>();
@SuppressWarnings("rawtypes") Iterator<Annotation> e = model.getAnnotationIterator();
Iterator e= model.getAnnotationIterator();
while (e.hasNext()) { while (e.hasNext()) {
Object annotation= e.next(); Annotation annotation = e.next();
if (annotation instanceof AutoconfProjectionAnnotation) { if (annotation instanceof AutoconfProjectionAnnotation) {
AutoconfProjectionAnnotation directive= (AutoconfProjectionAnnotation) annotation; AutoconfProjectionAnnotation directive= (AutoconfProjectionAnnotation) annotation;
List<AutoconfProjectionAnnotation> list= map.get(directive.getElement()); List<AutoconfProjectionAnnotation> list= map.get(directive.getElement());

View file

@ -89,8 +89,7 @@ public class AutomakeDocumentProvider extends TextFileDocumentProvider implement
@Override @Override
public void shutdown() { public void shutdown() {
@SuppressWarnings("rawtypes") Iterator<?> e = getConnectedElementsIterator();
Iterator e= getConnectedElementsIterator();
while (e.hasNext()) while (e.hasNext())
disconnect(e.next()); disconnect(e.next());
} }

View file

@ -90,10 +90,11 @@ public class AutomakeEditor extends MakefileEditor {
return ampage; return ampage;
} }
@SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class key) { public <T> T getAdapter(Class<T> key) {
if (key.equals(IContentOutlinePage.class)) { if (key.equals(IContentOutlinePage.class)) {
return getAutomakeOutlinePage(); return (T) getAutomakeOutlinePage();
} }
return super.getAdapter(key); return super.getAdapter(key);
} }

View file

@ -92,29 +92,22 @@ public class MakefileAnnotationHover implements IAnnotationHover, IAnnotationHov
List<Annotation> exact= new ArrayList<>(); List<Annotation> exact= new ArrayList<>();
List<Annotation> including= new ArrayList<>(); List<Annotation> including= new ArrayList<>();
@SuppressWarnings("rawtypes") Iterator<Annotation> e = model.getAnnotationIterator();
Iterator e= model.getAnnotationIterator();
while (e.hasNext()) { while (e.hasNext()) {
Object o= e.next(); Annotation a = e.next();
if (o instanceof Annotation) { switch (compareRulerLine(model.getPosition(a), document, line)) {
Annotation a= (Annotation) o; case 1:
switch (compareRulerLine(model.getPosition(a), document, line)) { exact.add(a);
case 1: break;
exact.add(a); case 2:
break; including.add(a);
case 2: break;
including.add(a);
break;
}
} }
} }
return select(exact, including); return select(exact, including);
} }
/*
* @see IVerticalRulerHover#getHoverInfo(ISourceViewer, int)
*/
@Override @Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) { public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
List<Annotation> annotations = getAnnotationsForLine(sourceViewer, lineNumber); List<Annotation> annotations = getAnnotationsForLine(sourceViewer, lineNumber);

View file

@ -125,8 +125,7 @@ public class MakefileDocumentProvider extends TextFileDocumentProvider implement
@Override @Override
public void shutdown() { public void shutdown() {
@SuppressWarnings("rawtypes") Iterator<?> e = getConnectedElementsIterator();
Iterator e= getConnectedElementsIterator();
while (e.hasNext()) while (e.hasNext())
disconnect(e.next()); disconnect(e.next());
} }

View file

@ -158,17 +158,18 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
return viewer; return viewer;
} }
@SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(@SuppressWarnings("rawtypes") Class key) { public <T> T getAdapter(Class<T> key) {
if (ProjectionAnnotationModel.class.equals(key)) { if (ProjectionAnnotationModel.class.equals(key)) {
if (projectionSupport != null) { if (projectionSupport != null) {
Object result = projectionSupport.getAdapter(getSourceViewer(), key); Object result = projectionSupport.getAdapter(getSourceViewer(), key);
if (result != null) { if (result != null) {
return result; return (T) result;
} }
} }
} else if (key.equals(IContentOutlinePage.class)) { } else if (key.equals(IContentOutlinePage.class)) {
return getOutlinePage(); return (T) getOutlinePage();
} }
return super.getAdapter(key); return super.getAdapter(key);
} }

View file

@ -269,8 +269,7 @@ public class OpenIncludeAction extends Action {
private static IInclude getIncludeStatement(ISelection sel) { private static IInclude getIncludeStatement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
@SuppressWarnings("rawtypes") List<?> list = ((IStructuredSelection) sel).toList();
List list= ((IStructuredSelection)sel).toList();
if (list.size() == 1) { if (list.size() == 1) {
Object element= list.get(0); Object element= list.get(0);
if (element instanceof IInclude) { if (element instanceof IInclude) {

View file

@ -149,10 +149,9 @@ public class ProjectionMakefileUpdater implements IProjectionListener {
fInput= manager.getWorkingCopy(fEditor.getEditorInput()); fInput= manager.getWorkingCopy(fEditor.getEditorInput());
if (fInput != null) { if (fInput != null) {
ProjectionAnnotationModel model= (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class); ProjectionAnnotationModel model = fEditor.getAdapter(ProjectionAnnotationModel.class);
if (model != null) { if (model != null) {
@SuppressWarnings("rawtypes") Map<MakefileProjectionAnnotation, Position> additions = computeAdditions((IParent) fInput);
Map additions= computeAdditions((IParent) fInput);
model.removeAllAnnotations(); model.removeAllAnnotations();
model.replaceAnnotations(null, additions); model.replaceAnnotations(null, additions);
} }
@ -235,7 +234,7 @@ public class ProjectionMakefileUpdater implements IProjectionListener {
if (!isInstalled()) if (!isInstalled())
return; return;
ProjectionAnnotationModel model= (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class); ProjectionAnnotationModel model= fEditor.getAdapter(ProjectionAnnotationModel.class);
if (model == null) if (model == null)
return; return;
@ -371,10 +370,9 @@ public class ProjectionMakefileUpdater implements IProjectionListener {
private Map<IDirective, List<MakefileProjectionAnnotation>> createAnnotationMap(IAnnotationModel model) { private Map<IDirective, List<MakefileProjectionAnnotation>> createAnnotationMap(IAnnotationModel model) {
Map<IDirective, List<MakefileProjectionAnnotation>> map= new HashMap<>(); Map<IDirective, List<MakefileProjectionAnnotation>> map= new HashMap<>();
@SuppressWarnings("rawtypes") Iterator<Annotation> e = model.getAnnotationIterator();
Iterator e= model.getAnnotationIterator();
while (e.hasNext()) { while (e.hasNext()) {
Object annotation= e.next(); Annotation annotation = e.next();
if (annotation instanceof MakefileProjectionAnnotation) { if (annotation instanceof MakefileProjectionAnnotation) {
MakefileProjectionAnnotation directive= (MakefileProjectionAnnotation) annotation; MakefileProjectionAnnotation directive= (MakefileProjectionAnnotation) annotation;
List<MakefileProjectionAnnotation> list= map.get(directive.getElement()); List<MakefileProjectionAnnotation> list= map.get(directive.getElement());

View file

@ -83,9 +83,8 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
* if there isn't any initial selection. * if there isn't any initial selection.
* @return the first element of the initial selection. * @return the first element of the initial selection.
*/ */
@SuppressWarnings({ "rawtypes" })
protected Object getPrimaryInitialSelection() { protected Object getPrimaryInitialSelection() {
List result= getInitialElementSelections(); List<?> result = getInitialElementSelections();
if (result == null || result.size() == 0) if (result == null || result.size() == 0)
return null; return null;
return result.get(0); return result.get(0);
@ -120,9 +119,10 @@ public abstract class SelectionStatusDialog extends SelectionDialog {
public void setImage(Image image) { public void setImage(Image image) {
fImage= image; fImage= image;
} }
@SuppressWarnings({ "unchecked" })
@SuppressWarnings("unchecked")
protected void setInitialSelection(int position, Object element) { protected void setInitialSelection(int position, Object element) {
List l= getInitialElementSelections(); List<Object> l = getInitialElementSelections();
l.set(position, element); l.set(position, element);
fInitialSelectionSet= true; fInitialSelectionSet= true;
} }