Commit f202dc3a authored by andrei's avatar andrei

Using generics where available

parent 14b44ca2
......@@ -156,7 +156,7 @@ public class CommentedASMifierClassVisitor extends ASMifier implements ICommente
}
assert meth != null;
currMethod = new DecompiledMethod(className, new HashMap(), meth, options, access);
currMethod = new DecompiledMethod(className, new HashMap<Label, Integer>(), meth, options, access);
ASMifier textifier = super.visitMethod(access, name1, desc, signature, exceptions);
TraceMethodVisitor tm = new TraceMethodVisitor(textifier);
meth.accept(tm);
......
......@@ -23,7 +23,6 @@ import de.loskutov.bco.preferences.BCOConstants;
/**
* @author Eric Bruneton
*/
public class CommentedClassVisitor extends Textifier implements ICommentedClassVisitor {
protected final boolean raw;
......@@ -149,7 +148,7 @@ public class CommentedClassVisitor extends Textifier implements ICommentedClassV
}
assert meth != null;
currMethod = new DecompiledMethod(className, new HashMap(), meth, options, access);
currMethod = new DecompiledMethod(className, new HashMap<Label, Integer>(), meth, options, access);
Textifier textifier = super.visitMethod(access, name, desc, signature, exceptions);
TraceMethodVisitor tm = new TraceMethodVisitor(textifier);
meth.accept(tm);
......
......@@ -16,30 +16,22 @@ import de.loskutov.bco.ui.JdtUtils;
/**
* @author Eric Bruneton
*/
public class DecompiledClass {
public static final String ATTR_CLAS_SIZE = "class.size";
public static final String ATTR_JAVA_VERSION = "java.version";
public static final String ATTR_ACCESS_FLAGS = "access";
/** key is DecompiledMethod, value is IJavaElement (Member) */
private final Map methodToJavaElt;
private final List text;
/**
* key is string, value is string
*/
private final Map classAttributesMap = new HashMap();
private final Map<DecompiledMethod, IJavaElement> methodToJavaElt;
private final List<Object> text;
private String value;
private ClassNode classNode;
private final ClassNode classNode;
private int classSize;
private final DecompiledClassInfo classInfo;
public DecompiledClass(final List text) {
public DecompiledClass(final List<Object> text, DecompiledClassInfo classInfo, ClassNode classNode) {
this.text = text;
methodToJavaElt = new HashMap();
}
public void setAttribute(String key, String value) {
classAttributesMap.put(key, value);
this.classInfo = classInfo;
this.classNode = classNode;
methodToJavaElt = new HashMap<DecompiledMethod, IJavaElement>();
}
/**
......@@ -47,33 +39,18 @@ public class DecompiledClass {
* indicates if the class is deprecated.
*/
public int getAccessFlags() {
int result = 0;
String flags = (String) classAttributesMap.get(ATTR_ACCESS_FLAGS);
if (flags == null) {
return result;
}
try {
Integer intFlags = Integer.valueOf(flags);
result = intFlags.intValue();
} catch (NumberFormatException e) {
// ignore, should not happen
}
return result;
return classInfo.accessFlags;
}
/**
* @return true if the class is either abstract or interface
*/
public boolean isAbstractOrInterface() {
int accessFlags = getAccessFlags();
return ((accessFlags & Opcodes.ACC_ABSTRACT) != 0)
int accessFlags = classInfo.accessFlags;
return (accessFlags & Opcodes.ACC_ABSTRACT) != 0
|| ((accessFlags & Opcodes.ACC_INTERFACE) != 0);
}
public String getAttribute(String key) {
return (String) classAttributesMap.get(key);
}
public String getText() {
if (value == null) {
StringBuffer buf = new StringBuffer();
......@@ -91,7 +68,7 @@ public class DecompiledClass {
}
public String[][] getTextTable() {
List lines = new ArrayList();
List<String[]> lines = new ArrayList<String[]>();
for (int i = 0; i < text.size(); ++i) {
Object o = text.get(i);
if (o instanceof DecompiledMethod) {
......@@ -103,7 +80,7 @@ public class DecompiledClass {
lines.add(new String[]{"", "", "", o.toString(), ""});
}
}
return (String[][]) lines.toArray(new String[lines.size()][]);
return lines.toArray(new String[lines.size()][]);
}
public int getBytecodeOffset(final int decompiledLine) {
......@@ -196,7 +173,7 @@ public class DecompiledClass {
public IJavaElement getJavaElement(int decompiledLine, IClassFile clazz) {
DecompiledMethod method = getMethod(decompiledLine);
if (method != null) {
IJavaElement javaElement = (IJavaElement) methodToJavaElt
IJavaElement javaElement = methodToJavaElt
.get(method);
if (javaElement == null) {
javaElement = JdtUtils.getMethod(clazz, method.getSignature());
......@@ -328,8 +305,8 @@ public class DecompiledClass {
return -1;
}
public List getErrorLines() {
List errors = new ArrayList();
public List<Integer> getErrorLines() {
List<Integer> errors = new ArrayList<Integer>();
int currentDecompiledLine = 0;
for (int i = 0; i < text.size(); ++i) {
Object o = text.get(i);
......@@ -432,11 +409,19 @@ public class DecompiledClass {
return new LineRange(startSourceLine, endSourceLine);
}
public void setClassNode(ClassNode classNode) {
this.classNode = classNode;
}
public ClassNode getClassNode() {
return classNode;
}
public void setClassSize(int classSize) {
this.classSize = classSize;
}
public int getClassSize() {
return classSize;
}
public String getJavaVersion() {
return classInfo.javaVersion;
}
}
......@@ -25,7 +25,7 @@ import de.loskutov.bco.preferences.BCOConstants;
/**
* @author Eric Bruneton
*/
public class DecompilerClassVisitor {
public class DecompilerHelper {
public static DecompiledClass getDecompiledClass(final InputStream is,
DecompilerOptions options)
......@@ -49,21 +49,17 @@ public class DecompilerClassVisitor {
}
private static DecompiledClass getResult(ICommentedClassVisitor printer, DecompilerOptions options, ClassNode classNode) {
List classText = new ArrayList();
List<Object> classText = new ArrayList<Object>();
formatText(printer.getText(), new StringBuffer(), classText, options.cl);
while (classText.size() > 0 && classText.get(0).equals("\n")) {
classText.remove(0);
}
DecompiledClassInfo classInfo = printer.getClassInfo();
DecompiledClass dc = new DecompiledClass(classText);
dc.setAttribute(DecompiledClass.ATTR_JAVA_VERSION, classInfo.javaVersion);
dc.setAttribute(DecompiledClass.ATTR_ACCESS_FLAGS, String.valueOf(classInfo.accessFlags));
dc.setClassNode(classNode);
return dc;
return new DecompiledClass(classText, classInfo, classNode);
}
private static void formatText(final List input, final StringBuffer line, final List result,
private static void formatText(final List input, final StringBuffer line, final List<Object> result,
final ClassLoader cl) {
for (int i = 0; i < input.size(); ++i) {
Object o = input.get(i);
......
......@@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.Display;
import de.loskutov.bco.BytecodeOutlinePlugin;
import de.loskutov.bco.asm.DecompiledClass;
import de.loskutov.bco.asm.DecompilerClassVisitor;
import de.loskutov.bco.asm.DecompilerHelper;
import de.loskutov.bco.asm.DecompilerOptions;
import de.loskutov.bco.ui.JdtUtils;
......@@ -123,7 +123,7 @@ public class TypedElement extends BufferedContent
}
DecompiledClass decompiledClass = null;
try {
decompiledClass = DecompilerClassVisitor.getDecompiledClass(
decompiledClass = DecompilerHelper.getDecompiledClass(
stream, new DecompilerOptions(null, methodName, modes, null));
} catch (IOException e) {
throw new CoreException(new Status(
......
......@@ -128,9 +128,6 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
return decompilerFlags.get(flag);
}
/*
* @see IEditorPart#init(IEditorSite, IEditorInput)
*/
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
......@@ -325,9 +322,6 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
}
}
/*
* @see JavaEditor#getElementAt(int)
*/
@Override
protected IJavaElement getElementAt(int offset) {
......@@ -531,9 +525,6 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
//
}
/*
* @see Runnable#run()
*/
@Override
public void run() {
......@@ -584,9 +575,6 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
}
}
/*
* @see JavaEditor#getCorrespondingElement(IJavaElement)
*/
@Override
protected IJavaElement getCorrespondingElement(IJavaElement element) {
IClassFile classFile = getClassFile();
......@@ -599,31 +587,16 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
return super.getCorrespondingElement(element);
}
/*
* 1GEPKT5: ITPJUI:Linux - Source in editor for external classes is editable Removed
* methods isSaveOnClosedNeeded and isDirty. Added method isEditable.
*/
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#isEditable()
*/
@Override
public boolean isEditable() {
return isDecompiled();
}
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#isEditorInputReadOnly()
* @since 3.2
*/
@Override
public boolean isEditorInputReadOnly() {
return !isDecompiled();
}
/*
* @see ITextEditorExtension2#isEditorInputModifiable()
* @since 2.1
*/
@Override
public boolean isEditorInputModifiable() {
return isDecompiled();
......@@ -643,12 +616,12 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
if (input instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) input).getFile();
Constructor cons;
Constructor<ExternalClassFileEditorInput> cons;
try {
cons = ExternalClassFileEditorInput.class
.getDeclaredConstructor(new Class[]{IFile.class});
cons.setAccessible(true);
IClassFileEditorInput classFileInput = (IClassFileEditorInput) cons
IClassFileEditorInput classFileInput = cons
.newInstance(new Object[]{file});
return classFileInput;
} catch (Exception e) {
......@@ -663,18 +636,12 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
return null;
}
/*
* @see IWorkbenchPart#createPartControl(Composite)
*/
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
initDone = true;
}
/*
* @see ClassFileDocumentProvider.InputChangeListener#inputChanged(IClassFileEditorInput)
*/
@Override
public void inputChanged(final IClassFileEditorInput input) {
Runnable updateInput = new Runnable() {
......@@ -698,9 +665,6 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
}
}
/*
* @see org.eclipse.ui.IWorkbenchPart#dispose()
*/
@Override
public void dispose() {
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=18510
......
......@@ -39,7 +39,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import de.loskutov.bco.BytecodeOutlinePlugin;
import de.loskutov.bco.asm.DecompiledClass;
import de.loskutov.bco.asm.DecompilerClassVisitor;
import de.loskutov.bco.asm.DecompilerHelper;
import de.loskutov.bco.asm.DecompilerOptions;
import de.loskutov.bco.ui.JdtUtils;
......@@ -50,13 +50,13 @@ import de.loskutov.bco.ui.JdtUtils;
public class BytecodeSourceMapper implements IDebugContextListener {
/** key is IClassFile, value is DecompiledClass */
private final WeakHashMap classToDecompiled;
private final WeakHashMap<IClassFile, DecompiledClass> classToDecompiled;
private IJavaReferenceType lastTypeInDebugger;
private String lastMethodInDebugger;
public BytecodeSourceMapper() {
super();
classToDecompiled = new WeakHashMap();
classToDecompiled = new WeakHashMap<IClassFile, DecompiledClass>();
DebugUITools.getDebugContextManager().addDebugContextListener(this);
}
......@@ -132,7 +132,7 @@ public class BytecodeSourceMapper implements IDebugContextListener {
}
public int getDecompiledLine(IMember elt, IClassFile cf) {
DecompiledClass dc = (DecompiledClass) classToDecompiled.get(cf);
DecompiledClass dc = classToDecompiled.get(cf);
if (dc != null) {
String signature = JdtUtils.getMethodSignature(elt);
if (signature != null) {
......@@ -193,7 +193,7 @@ public class BytecodeSourceMapper implements IDebugContextListener {
private static DecompiledClass decompile(StringBuffer source, InputStream is,
BitSet decompilerFlags) throws IOException {
DecompiledClass decompiledClass = DecompilerClassVisitor
DecompiledClass decompiledClass = DecompilerHelper
.getDecompiledClass(is, new DecompilerOptions(null, null, decompilerFlags, null));
source.append(decompiledClass.getText());
return decompiledClass;
......@@ -218,7 +218,7 @@ public class BytecodeSourceMapper implements IDebugContextListener {
}
protected IJavaElement findElement(IClassFile cf, int decompiledLine) {
DecompiledClass dc = (DecompiledClass) classToDecompiled.get(cf);
DecompiledClass dc = classToDecompiled.get(cf);
if (dc != null) {
return dc.getJavaElement(decompiledLine, cf);
}
......@@ -229,7 +229,7 @@ public class BytecodeSourceMapper implements IDebugContextListener {
if (cf == null) {
return 0;
}
DecompiledClass dc = (DecompiledClass) classToDecompiled.get(cf);
DecompiledClass dc = classToDecompiled.get(cf);
if (dc != null) {
return dc.getSourceLine(decompiledLine);
}
......@@ -245,14 +245,14 @@ public class BytecodeSourceMapper implements IDebugContextListener {
if(cf == null){
return null;
}
return (DecompiledClass) classToDecompiled.get(cf);
return classToDecompiled.get(cf);
}
public int mapToDecompiled(int sourceLine, IClassFile cf) {
if (cf == null) {
return 0;
}
DecompiledClass dc = (DecompiledClass) classToDecompiled.get(cf);
DecompiledClass dc = classToDecompiled.get(cf);
if (dc != null) {
return dc.getDecompiledLine(sourceLine);
}
......@@ -267,16 +267,13 @@ public class BytecodeSourceMapper implements IDebugContextListener {
if(cf == null || lastMethodInDebugger == null){
return -1;
}
DecompiledClass dc = (DecompiledClass) classToDecompiled.get(cf);
DecompiledClass dc = classToDecompiled.get(cf);
if (dc != null) {
return dc.getDecompiledLine(lastMethodInDebugger);
}
return -1;
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.contexts.IDebugContextListener#debugContextChanged(org.eclipse.debug.ui.contexts.DebugContextEvent)
*/
@Override
public void debugContextChanged(DebugContextEvent event) {
ISelection selection = event.getContext();
......
/*****************************************************************************************
* Copyright (c) 2004 Andrei Loskutov. All rights reserved. This program and the
* Copyright (c) 2011 Andrey Loskutov. All rights reserved. This program and the
* accompanying materials are made available under the terms of the BSD License which
* accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrei Loskutov -
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrey Loskutov -
* initial API and implementation
****************************************************************************************/
package de.loskutov.bco.ui;
......@@ -527,13 +527,13 @@ public class JdtUtils {
public static String getElementName(IJavaElement javaElement) {
if (isAnonymousType(javaElement)) {
IType anonType = (IType) javaElement;
List allAnonymous = new ArrayList();
List<IJavaElement> allAnonymous = new ArrayList<IJavaElement>();
/*
* in order to resolve anon. class name we need to know about all other
* anonymous classes in declaring class, therefore we need to collect all here
*/
collectAllAnonymous(allAnonymous, anonType);
int idx = getAnonimousIndex(anonType, (IType[]) allAnonymous
int idx = getAnonimousIndex(anonType, allAnonymous
.toArray(new IType[allAnonymous.size()]));
return Integer.toString(idx);
}
......@@ -1046,7 +1046,7 @@ public class JdtUtils {
* @param list for the found anon. classes, elements instanceof IType.
* @param anonType the anon. type
*/
private static void collectAllAnonymous(List list, IType anonType) {
private static void collectAllAnonymous(List<IJavaElement> list, IType anonType) {
/*
* For JDK >= 1.5 in Eclipse 3.1+ the naming shema for nested anonymous
* classes was changed from A$1, A$2, A$3, A$4, ..., A$n
......@@ -1077,7 +1077,7 @@ public class JdtUtils {
* @param allowNested true to search in IType child elements too
* @throws JavaModelException
*/
private static void collectAllAnonymous(List list, IParent parent,
private static void collectAllAnonymous(List<IJavaElement> list, IParent parent,
boolean allowNested) throws JavaModelException {
IJavaElement[] children = parent.getChildren();
for (int i = 0; i < children.length; i++) {
......@@ -1116,7 +1116,7 @@ public class JdtUtils {
* classes, in context of given anonymous type
* @param anonymous
*/
private static void sortAnonymous(List anonymous, IType anonType) {
private static void sortAnonymous(List<IJavaElement> anonymous, IType anonType) {
SourceOffsetComparator sourceComparator = new SourceOffsetComparator();
// Collections.sort(anonymous, sourceComparator);
......@@ -1132,12 +1132,12 @@ public class JdtUtils {
private static void debugCompilePrio(
final AnonymClassComparator classComparator) {
final Map map = classComparator.map;
Comparator prioComp = new Comparator() {
final Map<IType, Integer> map = classComparator.map;
Comparator<IType> prioComp = new Comparator() {
@Override
public int compare(Object e1, Object e2) {
int result = ((Comparable) map.get(e2)).compareTo(map.get(e1));
int result = map.get(e2).compareTo(map.get(e1));
if (result == 0) {
return e1.toString().compareTo(e2.toString());
}
......@@ -1146,9 +1146,9 @@ public class JdtUtils {
};
List keys = new ArrayList(map.keySet());
List<IType> keys = new ArrayList<IType>(map.keySet());
Collections.sort(keys, prioComp);
for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
for (Iterator<IType> iterator = keys.iterator(); iterator.hasNext();) {
Object key = iterator.next();
System.out.println(map.get(key) + " : " + key);
}
......@@ -1234,19 +1234,19 @@ public class JdtUtils {
ClassLoader cl;
IJavaProject javaProject = type.getJavaProject();
List urls = new ArrayList();
List<URL> urls = new ArrayList<URL>();
getClassURLs(javaProject, urls);
if (urls.isEmpty()) {
cl = JdtUtils.class.getClassLoader();
} else {
cl = new URLClassLoader((URL[]) urls.toArray(new URL[urls.size()]));
cl = new URLClassLoader(urls.toArray(new URL[urls.size()]));
}
return cl;
}
private static void getClassURLs(IJavaProject javaProject, List urls) {
private static void getClassURLs(IJavaProject javaProject, List<URL> urls) {
IProject project = javaProject.getProject();
IWorkspaceRoot workspaceRoot = project.getWorkspace().getRoot();
......@@ -1392,7 +1392,7 @@ public class JdtUtils {
private final IType topAncestorType;
private final SourceOffsetComparator sourceComparator;
private final boolean is50OrHigher;
private final Map/*<IJavaElement,Integer>*/ map;
private final Map/*<IJavaElement,Integer>*/<IType, Integer> map;
/**
* @param javaElement
......@@ -1403,7 +1403,7 @@ public class JdtUtils {
this.sourceComparator = sourceComparator;
is50OrHigher = is50OrHigher(javaElement);
topAncestorType = (IType) getLastAncestor(javaElement, IJavaElement.TYPE);
map = new IdentityHashMap();
map = new IdentityHashMap<IType, Integer>();
}
/**
......@@ -1504,7 +1504,7 @@ public class JdtUtils {
private int getCompilePrio(IType anonType, IJavaElement firstAncestor) {
int compilePrio;
Integer prio;
if ((prio = (Integer) map.get(anonType)) != null) {
if ((prio = map.get(anonType)) != null) {
compilePrio = prio.intValue();
if (BytecodeOutlinePlugin.DEBUG) {
System.out.println("Using cache");
......
/*******************************************************************************
* Copyright (c) 2004 Andrei Loskutov.
* Copyright (c) 2011 Andrey Loskutov.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the BSD License
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php
* Contributor: Andrei Loskutov - initial API and implementation
* Contributor: Andrey Loskutov - initial API and implementation
*******************************************************************************/
package de.loskutov.bco.ui.actions;
......@@ -40,27 +40,18 @@ public abstract class BytecodeAction implements IObjectActionDelegate {
protected IStructuredSelection selection;
protected Shell shell;
/**
* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection newSelection) {
if (newSelection instanceof IStructuredSelection) {
this.selection = (IStructuredSelection) newSelection;
}
}
/**
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
this.shell = targetPart.getSite().getShell();
}
/**
* @see de.loskutov.branchview.connection.Command#exec(java.lang.Object)
*/
protected void exec(IJavaElement element1, IJavaElement element2) throws Exception {
final BitSet modes = getModes();
CompareUI.openCompareEditor(new BytecodeCompare(
......@@ -93,7 +84,7 @@ public abstract class BytecodeAction implements IObjectActionDelegate {
return new TypedElement(name, methodName, TypedElement.TYPE_BYTECODE, javaElement, modes);
}
private BitSet getModes() {
private static BitSet getModes() {
IPreferenceStore store = BytecodeOutlinePlugin.getDefault().getPreferenceStore();
BitSet modes = new BitSet();
modes.set(BCOConstants.F_LINK_VIEW_TO_EDITOR, store.getBoolean(BCOConstants.LINK_VIEW_TO_EDITOR));
......@@ -109,9 +100,9 @@ public abstract class BytecodeAction implements IObjectActionDelegate {
}
protected IJavaElement[] getSelectedResources() {
ArrayList resources = null;
ArrayList<Object> resources = null;
if (!selection.isEmpty()) {
resources = new ArrayList();
resources = new ArrayList<Object>();
for (Iterator elements = selection.iterator(); elements.hasNext();) {
Object next = elements.next();
if (next instanceof IFile) {
......@@ -143,7 +134,7 @@ public abstract class BytecodeAction implements IObjectActionDelegate {
}
if (resources != null && !resources.isEmpty()) {
return (IJavaElement[]) resources.toArray(new IJavaElement[resources
return resources.toArray(new IJavaElement[resources
.size()]);
}
......
/*****************************************************************************************
* Copyright (c) 2004 Andrei Loskutov. All rights reserved. This program and the
* Copyright (c) 2011 Andrey Loskutov. All rights reserved. This program and the
* accompanying materials are made available under the terms of the BSD License which
* accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrei Loskutov -
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrey Loskutov -
* initial API and implementation
****************************************************************************************/
package de.loskutov.bco.ui.actions;
......@@ -14,19 +14,15 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IObjectActionDelegate;
import de.loskutov.bco.BytecodeOutlinePlugin;
/**
* @author Andrei
*/
public class CompareMemberBytecodeAction extends BytecodeAction implements IObjectActionDelegate {
public class CompareMemberBytecodeAction extends BytecodeAction {
/**
* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
IJavaElement[] resources = getSelectedResources();
try {
......@@ -37,11 +33,11 @@ public class CompareMemberBytecodeAction extends BytecodeAction implements IObje
}
}
@Override
protected IJavaElement[] getSelectedResources() {
ArrayList resources = null;
ArrayList<Object> resources = null;
if (!selection.isEmpty()) {
resources = new ArrayList();
resources = new ArrayList<Object>();
for (Iterator elements = selection.iterator(); elements.hasNext();) {
Object next = elements.next();
if (next instanceof IMember) {
......@@ -59,10 +55,10 @@ public class CompareMemberBytecodeAction extends BytecodeAction implements IObje
}
if (resources != null && !resources.isEmpty()) {
return (IJavaElement[]) resources.toArray(new IJavaElement[resources
return resources.toArray(new IJavaElement[resources
.size()]);
}
return new IJavaElement[0];
}
}
\ No newline at end of file
}
/*****************************************************************************************
* Copyright (c) 2007 Andrei Loskutov. All rights reserved. This program and the
* Copyright (c) 2011 Andrey Loskutov. All rights reserved. This program and the
* accompanying materials are made available under the terms of the BSD License which
* accompanies this distribution, and is available at
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrei Loskutov -
* http://www.opensource.org/licenses/bsd-license.php Contributor: Andrey Loskutov -
* initial API and implementation
****************************************************************************************/
package de.loskutov.bco.views;
......@@ -31,12 +31,12 @@ import de.loskutov.bco.BytecodeOutlinePlugin;
class BCOViewSelectionProvider implements IPostSelectionProvider {
private IPostSelectionProvider realProvider;
private final List selProviders;
private final List<IPostSelectionProvider> selProviders;
private ISelection selection;
public BCOViewSelectionProvider(){
super();
selProviders = new ArrayList();
selProviders = new ArrayList<IPostSelectionProvider>();
}