Commit cbecebe6 authored by Andrey Loskutov's avatar Andrey Loskutov

Fixed legacy code to use modern API

parent 80d36e3a
......@@ -281,9 +281,9 @@ public class CommentedASMifierClassVisitor extends ASMifier implements ICommente
@Override
public void visitMethodInsn(final int opcode, final String owner,
final String name1, final String desc) {
final String name1, final String desc, boolean itf) {
addIndex(opcode);
super.visitMethodInsn(opcode, owner, name1, desc);
super.visitMethodInsn(opcode, owner, name1, desc, itf);
}
@Override
......
......@@ -313,7 +313,7 @@ public class CommentedClassVisitor extends Textifier implements ICommentedClassV
@Override
public void visitMethodInsn(final int opcode, final String owner,
final String name, final String desc) {
final String name, final String desc, boolean itf) {
addIndex(opcode);
buf.setLength(0);
buf.append(tab2).append(OPCODES[opcode]).append(' ');
......
......@@ -19,7 +19,7 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarManager;
......@@ -126,7 +126,7 @@ public class BytecodeCompare extends CompareEditorInput {
initLabels();
Differencer differencer = new Differencer();
monitor.beginTask("Bytecode Outline: comparing...", 30); //$NON-NLS-1$
IProgressMonitor sub = new SubProgressMonitor(monitor, 10);
IProgressMonitor sub = SubMonitor.convert(monitor, 10);
try {
sub.beginTask("Bytecode Outline: comparing...", 100); //$NON-NLS-1$
......
......@@ -18,6 +18,7 @@ import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModelStatusConstants;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IOrdinaryClassFile;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
......@@ -202,7 +203,7 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
}
private IEditorInput doOpenBuffer(IJavaReferenceType type,
IClassFile parent, boolean externalClass) {
IOrdinaryClassFile parent, boolean externalClass) {
IClassFile classFile = null;
try {
classFile = JdtUtils.getInnerType(parent, getSourceMapper()
......@@ -238,13 +239,13 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
if (origSrc == null || (force && !reuseSource)) {
setDecompiled(true);
char[] src;
char[] src = null;
if (input instanceof ExternalClassFileEditorInput) {
ExternalClassFileEditorInput extInput = (ExternalClassFileEditorInput) input;
src = getSourceMapper().getSource(
extInput.getFile(), cf, decompilerFlags);
} else {
src = getSourceMapper().getSource(cf, decompilerFlags);
} else if(cf instanceof IOrdinaryClassFile) {
src = getSourceMapper().getSource((IOrdinaryClassFile)cf, decompilerFlags);
}
changeBufferContent(cf, src);
} else {
......@@ -697,7 +698,7 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
* @return The region in the inner class (if inner class could be found), or an empty
* zero-based region.
*/
public static IRegion checkForInnerClass(int sourceLine, IClassFile parent) {
public static IRegion checkForInnerClass(int sourceLine, IOrdinaryClassFile parent) {
IRegion region = new Region(0, 0);
// get the editor with given class file, if any
......@@ -765,7 +766,7 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
* @return non public class (local type class) with the name from "debugType" and
* which source was in the "parent" class. Null if no class file could be found.
*/
private static IClassFile getLocalTypeClass(IJavaReferenceType debugType, IClassFile parent) {
private static IClassFile getLocalTypeClass(IJavaReferenceType debugType, IOrdinaryClassFile parent) {
try {
IType type = parent.getType();
if((type.isLocal()) || (type.isMember())) {
......@@ -792,9 +793,11 @@ public class BytecodeClassFileEditor extends ClassFileEditor {
private static boolean hasInnerClass(IJavaReferenceType debugType,
IClassFile parent) {
try {
String parentName = parent.getType().getFullyQualifiedName();
String childName = debugType.getName();
return childName != null && childName.startsWith(parentName + "$");
if(parent instanceof IOrdinaryClassFile) {
String parentName = ((IOrdinaryClassFile)parent).getType().getFullyQualifiedName();
String childName = debugType.getName();
return childName != null && childName.startsWith(parentName + "$");
}
} catch (Exception e) {
BytecodeOutlinePlugin.log(e, IStatus.ERROR);
}
......
......@@ -4,6 +4,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jdt.core.IBuffer;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IOrdinaryClassFile;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.BufferManager;
import org.eclipse.jdt.internal.ui.javaeditor.ClassFileDocumentProvider;
......@@ -199,7 +200,9 @@ public class BytecodeDocumentProvider extends ClassFileDocumentProvider {
* expect that their source code is in our editor which is not the case for
* bytecode of inner classes => for inner classes we use another strategy
*/
return BytecodeClassFileEditor.checkForInnerClass(line, cf);
if(cf instanceof IOrdinaryClassFile) {
return BytecodeClassFileEditor.checkForInnerClass(line, (IOrdinaryClassFile) cf);
}
}
}
// editor start lines with 1
......
......@@ -26,6 +26,7 @@ import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IOrdinaryClassFile;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
......@@ -60,7 +61,7 @@ public class BytecodeSourceMapper implements IDebugContextListener {
DebugUITools.getDebugContextManager().addDebugContextListener(this);
}
public char[] getSource(IClassFile classFile, BitSet decompilerFlags) {
public char[] getSource(IOrdinaryClassFile classFile, BitSet decompilerFlags) {
IType type;
type = classFile.getType();
if (type == null || !type.isBinary()) {
......
......@@ -45,6 +45,7 @@ import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IOrdinaryClassFile;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IParent;
......@@ -389,7 +390,7 @@ public class JdtUtils {
* @param dc
* @return inner type which has the same name as the given string, or null
*/
public static IClassFile getInnerType(IClassFile cf, DecompiledClass dc,
public static IOrdinaryClassFile getInnerType(IOrdinaryClassFile cf, DecompiledClass dc,
String typeSignature) {
if(typeSignature.endsWith(";")){
typeSignature = typeSignature.substring(0, typeSignature.length()-1);
......@@ -422,7 +423,7 @@ public class JdtUtils {
className = typeSignature.substring(idx + 1, typeSignature.length());
}
className += ".class";
return cf.getType().getPackageFragment().getClassFile(className);
return (IOrdinaryClassFile) cf.getType().getPackageFragment().getClassFile(className);
}
}
return null;
......
......@@ -18,11 +18,11 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IOrdinaryClassFile;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
......@@ -59,8 +59,8 @@ public class TypeFactory {
if (container instanceof ICompilationUnit) {
return findTypeInCompilationUnit((ICompilationUnit) container,
getTypeQualifiedName());
} else if (container instanceof IClassFile) {
return ((IClassFile) container).getType();
} else if (container instanceof IOrdinaryClassFile) {
return ((IOrdinaryClassFile) container).getType();
}
return null;
} catch (JavaModelException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment