mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 18:55:38 +02:00
Generics.
This commit is contained in:
parent
9792e732c4
commit
f3b4634427
2 changed files with 226 additions and 242 deletions
|
@ -18,7 +18,6 @@ import java.nio.charset.Charset;
|
||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.transform.OutputKeys;
|
import javax.xml.transform.OutputKeys;
|
||||||
|
@ -62,155 +61,147 @@ import com.ibm.icu.text.MessageFormat;
|
||||||
*/
|
*/
|
||||||
public class CDebugUtils {
|
public class CDebugUtils {
|
||||||
|
|
||||||
public static boolean question( IStatus status, Object source ) {
|
public static boolean question(IStatus status, Object source) {
|
||||||
Boolean result = Boolean.FALSE;
|
Boolean result = Boolean.FALSE;
|
||||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( status );
|
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||||
if ( handler != null ) {
|
if (handler != null) {
|
||||||
try {
|
try {
|
||||||
result = (Boolean)handler.handleStatus( status, source );
|
result = (Boolean)handler.handleStatus(status, source);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.booleanValue();
|
return result.booleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info( IStatus status, Object source ) {
|
public static void info(IStatus status, Object source) {
|
||||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( status );
|
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||||
if ( handler != null ) {
|
if (handler != null) {
|
||||||
try {
|
try {
|
||||||
handler.handleStatus( status, source );
|
handler.handleStatus(status, source);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error( IStatus status, Object source ) {
|
public static void error(IStatus status, Object source) {
|
||||||
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler( status );
|
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
|
||||||
if ( handler != null ) {
|
if (handler != null) {
|
||||||
try {
|
try {
|
||||||
handler.handleStatus( status, source );
|
handler.handleStatus(status, source);
|
||||||
}
|
} catch (CoreException e) {
|
||||||
catch( CoreException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char[] getByteText( byte b ) {
|
public static char[] getByteText(byte b) {
|
||||||
return new char[]{ charFromByte( (byte)((b >>> 4) & 0x0f) ), charFromByte( (byte)(b & 0x0f) ) };
|
return new char[]{ charFromByte((byte)((b >>> 4) & 0x0f)), charFromByte((byte)(b & 0x0f)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte textToByte( char[] text ) {
|
public static byte textToByte(char[] text) {
|
||||||
byte result = 0;
|
byte result = 0;
|
||||||
if ( text.length == 2 ) {
|
if (text.length == 2) {
|
||||||
byte[] bytes = { charToByte( text[0] ), charToByte( text[1] ) };
|
byte[] bytes = { charToByte(text[0]), charToByte(text[1]) };
|
||||||
result = (byte)((bytes[0] << 4) + bytes[1]);
|
result = (byte) ((bytes[0] << 4) + bytes[1]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char charFromByte( byte value ) {
|
public static char charFromByte(byte value) {
|
||||||
if ( value >= 0x0 && value <= 0x9 )
|
if (value >= 0x0 && value <= 0x9)
|
||||||
return (char)(value + '0');
|
return (char) (value + '0');
|
||||||
if ( value >= 0xa && value <= 0xf )
|
if (value >= 0xa && value <= 0xf)
|
||||||
return (char)(value - 0xa + 'a');
|
return (char) (value - 0xa + 'a');
|
||||||
return '0';
|
return '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte charToByte( char ch ) {
|
public static byte charToByte(char ch) {
|
||||||
if ( Character.isDigit( ch ) ) {
|
if (Character.isDigit(ch)) {
|
||||||
return (byte)(ch - '0');
|
return (byte) (ch - '0');
|
||||||
}
|
}
|
||||||
if ( ch >= 'a' && ch <= 'f' ) {
|
if (ch >= 'a' && ch <= 'f') {
|
||||||
return (byte)(0xa + ch - 'a');
|
return (byte) (0xa + ch - 'a');
|
||||||
}
|
}
|
||||||
if ( ch >= 'A' && ch <= 'F' ) {
|
if (ch >= 'A' && ch <= 'F') {
|
||||||
return (byte)(0xa + ch - 'A');
|
return (byte) (0xa + ch - 'A');
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char bytesToChar( byte[] bytes ) {
|
public static char bytesToChar(byte[] bytes) {
|
||||||
try {
|
try {
|
||||||
return (char)Short.parseShort( new String( bytes ), 16 );
|
return (char)Short.parseShort(new String(bytes), 16);
|
||||||
}
|
} catch (RuntimeException e) {
|
||||||
catch( RuntimeException e ) {
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte toByte( char[] bytes, boolean le ) {
|
public static byte toByte(char[] bytes, boolean le) {
|
||||||
if ( bytes.length != 2 )
|
if (bytes.length != 2)
|
||||||
return 0;
|
return 0;
|
||||||
return (byte)Long.parseLong( bytesToString( bytes, le, true ), 16 );
|
return (byte)Long.parseLong(bytesToString(bytes, le, true), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short toUnsignedByte( char[] bytes, boolean le ) {
|
public static short toUnsignedByte(char[] bytes, boolean le) {
|
||||||
if ( bytes.length != 2 )
|
if (bytes.length != 2)
|
||||||
return 0;
|
return 0;
|
||||||
return (short)Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
return (short)Long.parseLong(bytesToString(bytes, le, false), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short toShort( char[] bytes, boolean le ) {
|
public static short toShort(char[] bytes, boolean le) {
|
||||||
if ( bytes.length != 4 )
|
if (bytes.length != 4)
|
||||||
return 0;
|
return 0;
|
||||||
return (short)Long.parseLong( bytesToString( bytes, le, true ), 16 );
|
return (short)Long.parseLong(bytesToString(bytes, le, true), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int toUnsignedShort( char[] bytes, boolean le ) {
|
public static int toUnsignedShort(char[] bytes, boolean le) {
|
||||||
if ( bytes.length != 4 )
|
if (bytes.length != 4)
|
||||||
return 0;
|
return 0;
|
||||||
return (int)Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
return (int)Long.parseLong(bytesToString(bytes, le, false), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int toInt( char[] bytes, boolean le ) {
|
public static int toInt(char[] bytes, boolean le) {
|
||||||
if ( bytes.length != 8 )
|
if (bytes.length != 8)
|
||||||
return 0;
|
return 0;
|
||||||
return (int)Long.parseLong( bytesToString( bytes, le, true ), 16 );
|
return (int)Long.parseLong(bytesToString(bytes, le, true), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long toUnsignedInt( char[] bytes, boolean le ) {
|
public static long toUnsignedInt(char[] bytes, boolean le) {
|
||||||
if ( bytes.length != 8 )
|
if (bytes.length != 8)
|
||||||
return 0;
|
return 0;
|
||||||
return Long.parseLong( bytesToString( bytes, le, false ), 16 );
|
return Long.parseLong(bytesToString(bytes, le, false), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String bytesToString( char[] bytes, boolean le, boolean signed ) {
|
private static String bytesToString(char[] bytes, boolean le, boolean signed) {
|
||||||
char[] copy = new char[bytes.length];
|
char[] copy = new char[bytes.length];
|
||||||
if ( le ) {
|
if (le) {
|
||||||
for( int i = 0; i < bytes.length / 2; ++i ) {
|
for (int i = 0; i < bytes.length / 2; ++i) {
|
||||||
copy[2 * i] = bytes[bytes.length - 2 * i - 2];
|
copy[2 * i] = bytes[bytes.length - 2 * i - 2];
|
||||||
copy[2 * i + 1] = bytes[bytes.length - 2 * i - 1];
|
copy[2 * i + 1] = bytes[bytes.length - 2 * i - 1];
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
System.arraycopy(bytes, 0, copy, 0, copy.length);
|
||||||
}
|
}
|
||||||
else {
|
return new String(copy);
|
||||||
System.arraycopy( bytes, 0, copy, 0, copy.length );
|
|
||||||
}
|
|
||||||
return new String( copy );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String prependString( String text, int length, char ch ) {
|
public static String prependString(String text, int length, char ch) {
|
||||||
StringBuffer sb = new StringBuffer( length );
|
StringBuffer sb = new StringBuffer(length);
|
||||||
if ( text.length() > length ) {
|
if (text.length() > length) {
|
||||||
sb.append( text.substring( 0, length ) );
|
sb.append(text.substring(0, length));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
char[] prefix = new char[length - text.length()];
|
char[] prefix = new char[length - text.length()];
|
||||||
Arrays.fill( prefix, ch );
|
Arrays.fill(prefix, ch);
|
||||||
sb.append( prefix );
|
sb.append(prefix);
|
||||||
sb.append( text );
|
sb.append(text);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isReferencedProject( IProject parent, IProject project ) {
|
public static boolean isReferencedProject(IProject parent, IProject project) {
|
||||||
if ( parent != null && parent.exists() ) {
|
if (parent != null && parent.exists()) {
|
||||||
List projects = CDebugUtils.getReferencedProjects( project );
|
List<IProject> projects = CDebugUtils.getReferencedProjects(project);
|
||||||
Iterator it = projects.iterator();
|
for (IProject proj : projects) {
|
||||||
while( it.hasNext() ) {
|
if (proj.exists() && (proj.equals(project)))
|
||||||
IProject prj = (IProject)it.next();
|
|
||||||
if ( prj.exists() && (prj.equals( project )) )
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,16 +216,16 @@ public class CDebugUtils {
|
||||||
*
|
*
|
||||||
* @return the document as a string
|
* @return the document as a string
|
||||||
*/
|
*/
|
||||||
public static String serializeDocument( Document doc, boolean indent ) throws IOException, TransformerException {
|
public static String serializeDocument(Document doc, boolean indent) throws IOException, TransformerException {
|
||||||
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
ByteArrayOutputStream s = new ByteArrayOutputStream();
|
||||||
TransformerFactory factory = TransformerFactory.newInstance();
|
TransformerFactory factory = TransformerFactory.newInstance();
|
||||||
Transformer transformer = factory.newTransformer();
|
Transformer transformer = factory.newTransformer();
|
||||||
transformer.setOutputProperty( OutputKeys.METHOD, "xml" ); //$NON-NLS-1$
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
||||||
transformer.setOutputProperty( OutputKeys.INDENT, indent ? "yes" : "no" ); //$NON-NLS-1$ //$NON-NLS-2$
|
transformer.setOutputProperty(OutputKeys.INDENT, indent ? "yes" : "no"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
DOMSource source = new DOMSource( doc );
|
DOMSource source = new DOMSource(doc);
|
||||||
StreamResult outputTarget = new StreamResult( s );
|
StreamResult outputTarget = new StreamResult(s);
|
||||||
transformer.transform( source, outputTarget );
|
transformer.transform(source, outputTarget);
|
||||||
return s.toString( "UTF8" ); //$NON-NLS-1$
|
return s.toString("UTF8"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,231 +234,228 @@ public class CDebugUtils {
|
||||||
* @param doc document to serialize
|
* @param doc document to serialize
|
||||||
* @return the document as a string
|
* @return the document as a string
|
||||||
*/
|
*/
|
||||||
public static String serializeDocument( Document doc ) throws IOException, TransformerException {
|
public static String serializeDocument(Document doc) throws IOException, TransformerException {
|
||||||
return serializeDocument(doc, true);
|
return serializeDocument(doc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Number getFloatingPointValue( ICValue value ) {
|
public static Number getFloatingPointValue(ICValue value) {
|
||||||
if ( value instanceof CFloatingPointValue ) {
|
if (value instanceof CFloatingPointValue) {
|
||||||
try {
|
try {
|
||||||
return ((CFloatingPointValue)value).getFloatingPointValue();
|
return ((CFloatingPointValue)value).getFloatingPointValue();
|
||||||
}
|
} catch (CDIException e) {
|
||||||
catch( CDIException e ) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNaN( Number value ) {
|
public static boolean isNaN(Number value) {
|
||||||
if ( value instanceof Double ) {
|
if (value instanceof Double) {
|
||||||
return ((Double)value).isNaN();
|
return ((Double) value).isNaN();
|
||||||
}
|
}
|
||||||
if ( value instanceof Float ) {
|
if (value instanceof Float) {
|
||||||
return ((Float)value).isNaN();
|
return ((Float) value).isNaN();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPositiveInfinity( Number value ) {
|
public static boolean isPositiveInfinity(Number value) {
|
||||||
if ( value instanceof Double ) {
|
if (value instanceof Double) {
|
||||||
return (((Double)value).isInfinite() && value.doubleValue() == Double.POSITIVE_INFINITY);
|
return (((Double) value).isInfinite() && value.doubleValue() == Double.POSITIVE_INFINITY);
|
||||||
}
|
}
|
||||||
if ( value instanceof Float ) {
|
if (value instanceof Float) {
|
||||||
return (((Float)value).isInfinite() && value.floatValue() == Float.POSITIVE_INFINITY);
|
return (((Float) value).isInfinite() && value.floatValue() == Float.POSITIVE_INFINITY);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNegativeInfinity( Number value ) {
|
public static boolean isNegativeInfinity(Number value) {
|
||||||
if ( value instanceof Double ) {
|
if (value instanceof Double) {
|
||||||
return (((Double)value).isInfinite() && value.doubleValue() == Double.NEGATIVE_INFINITY);
|
return (((Double) value).isInfinite() && value.doubleValue() == Double.NEGATIVE_INFINITY);
|
||||||
}
|
}
|
||||||
if ( value instanceof Float ) {
|
if (value instanceof Float) {
|
||||||
return (((Float)value).isInfinite() && value.floatValue() == Float.NEGATIVE_INFINITY);
|
return (((Float) value).isInfinite() && value.floatValue() == Float.NEGATIVE_INFINITY);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List getReferencedProjects( IProject project ) {
|
public static List<IProject> getReferencedProjects(IProject project) {
|
||||||
ArrayList list = new ArrayList( 10 );
|
ArrayList<IProject> list = new ArrayList<IProject>(10);
|
||||||
if ( project != null && project.exists() && project.isOpen() ) {
|
if (project != null && project.exists() && project.isOpen()) {
|
||||||
IProject[] refs = new IProject[0];
|
IProject[] refs = new IProject[0];
|
||||||
try {
|
try {
|
||||||
refs = project.getReferencedProjects();
|
refs = project.getReferencedProjects();
|
||||||
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
catch( CoreException e ) {
|
for (int i = 0; i < refs.length; ++i) {
|
||||||
}
|
if (!project.equals(refs[i]) && refs[i] != null && refs[i].exists() && refs[i].isOpen()) {
|
||||||
for( int i = 0; i < refs.length; ++i ) {
|
list.add(refs[i]);
|
||||||
if ( !project.equals( refs[i] ) && refs[i] != null && refs[i].exists() && refs[i].isOpen() ) {
|
getReferencedProjects(project, refs[i], list);
|
||||||
list.add( refs[i] );
|
|
||||||
getReferencedProjects( project, refs[i], list );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void getReferencedProjects( IProject root, IProject project, List list ) {
|
private static void getReferencedProjects(IProject root, IProject project, List<IProject> list) {
|
||||||
if ( project != null && project.exists() && project.isOpen() ) {
|
if (project != null && project.exists() && project.isOpen()) {
|
||||||
IProject[] refs = new IProject[0];
|
IProject[] refs = new IProject[0];
|
||||||
try {
|
try {
|
||||||
refs = project.getReferencedProjects();
|
refs = project.getReferencedProjects();
|
||||||
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
catch( CoreException e ) {
|
for (int i = 0; i < refs.length; ++i) {
|
||||||
}
|
if (!list.contains(refs[i]) && refs[i] != null && !refs[i].equals(root) && refs[i].exists() && refs[i].isOpen()) {
|
||||||
for( int i = 0; i < refs.length; ++i ) {
|
list.add(refs[i]);
|
||||||
if ( !list.contains( refs[i] ) && refs[i] != null && !refs[i].equals( root ) && refs[i].exists() && refs[i].isOpen() ) {
|
getReferencedProjects(root, refs[i], list);
|
||||||
list.add( refs[i] );
|
|
||||||
getReferencedProjects( root, refs[i], list );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getBreakpointText( IBreakpoint breakpoint, boolean qualified ) throws CoreException {
|
public static String getBreakpointText(IBreakpoint breakpoint, boolean qualified) throws CoreException {
|
||||||
if ( breakpoint instanceof ICAddressBreakpoint ) {
|
if (breakpoint instanceof ICAddressBreakpoint) {
|
||||||
return getAddressBreakpointText( (ICAddressBreakpoint)breakpoint, qualified );
|
return getAddressBreakpointText((ICAddressBreakpoint)breakpoint, qualified);
|
||||||
}
|
}
|
||||||
if ( breakpoint instanceof ICFunctionBreakpoint ) {
|
if (breakpoint instanceof ICFunctionBreakpoint) {
|
||||||
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
|
return getFunctionBreakpointText((ICFunctionBreakpoint)breakpoint, qualified);
|
||||||
}
|
}
|
||||||
if ( breakpoint instanceof ICLineBreakpoint ) {
|
if (breakpoint instanceof ICLineBreakpoint) {
|
||||||
return getLineBreakpointText( (ICLineBreakpoint)breakpoint, qualified );
|
return getLineBreakpointText((ICLineBreakpoint)breakpoint, qualified);
|
||||||
}
|
}
|
||||||
if ( breakpoint instanceof ICWatchpoint ) {
|
if (breakpoint instanceof ICWatchpoint) {
|
||||||
return getWatchpointText( (ICWatchpoint)breakpoint, qualified );
|
return getWatchpointText((ICWatchpoint)breakpoint, qualified);
|
||||||
}
|
}
|
||||||
// this allow to create new breakpoint without implemention one the interfaces above and still see a label
|
// this allow to create new breakpoint without implemention one the interfaces above and still see a label
|
||||||
Object message = breakpoint.getMarker().getAttribute(IMarker.MESSAGE);
|
Object message = breakpoint.getMarker().getAttribute(IMarker.MESSAGE);
|
||||||
if (message!=null) return message.toString();
|
if (message != null)
|
||||||
|
return message.toString();
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getLineBreakpointText( ICLineBreakpoint breakpoint, boolean qualified ) throws CoreException {
|
protected static String getLineBreakpointText(ICLineBreakpoint breakpoint, boolean qualified) throws CoreException {
|
||||||
StringBuffer label = new StringBuffer();
|
StringBuffer label = new StringBuffer();
|
||||||
appendSourceName( breakpoint, label, qualified );
|
appendSourceName(breakpoint, label, qualified);
|
||||||
appendLineNumber( breakpoint, label );
|
appendLineNumber(breakpoint, label);
|
||||||
appendBreakpointType( breakpoint, label );
|
appendBreakpointType(breakpoint, label);
|
||||||
appendIgnoreCount( breakpoint, label );
|
appendIgnoreCount(breakpoint, label);
|
||||||
appendCondition( breakpoint, label );
|
appendCondition(breakpoint, label);
|
||||||
return label.toString();
|
return label.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException {
|
protected static String getWatchpointText(ICWatchpoint watchpoint, boolean qualified) throws CoreException {
|
||||||
StringBuffer label = new StringBuffer();
|
StringBuffer label = new StringBuffer();
|
||||||
appendSourceName( watchpoint, label, qualified );
|
appendSourceName(watchpoint, label, qualified);
|
||||||
appendWatchExpression( watchpoint, label );
|
appendWatchExpression(watchpoint, label);
|
||||||
if ( watchpoint instanceof ICWatchpoint2 ) {
|
if (watchpoint instanceof ICWatchpoint2) {
|
||||||
ICWatchpoint2 wp2 = (ICWatchpoint2)watchpoint;
|
ICWatchpoint2 wp2 = (ICWatchpoint2)watchpoint;
|
||||||
appendWatchMemorySpace( wp2, label );
|
appendWatchMemorySpace(wp2, label);
|
||||||
appendWatchRange( wp2, label );
|
appendWatchRange(wp2, label);
|
||||||
}
|
}
|
||||||
appendIgnoreCount( watchpoint, label );
|
appendIgnoreCount(watchpoint, label);
|
||||||
appendCondition( watchpoint, label );
|
appendCondition(watchpoint, label);
|
||||||
return label.toString();
|
return label.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException {
|
protected static String getAddressBreakpointText(ICAddressBreakpoint breakpoint, boolean qualified) throws CoreException {
|
||||||
StringBuffer label = new StringBuffer();
|
StringBuffer label = new StringBuffer();
|
||||||
appendSourceName( breakpoint, label, qualified );
|
appendSourceName(breakpoint, label, qualified);
|
||||||
appendAddress( breakpoint, label );
|
appendAddress(breakpoint, label);
|
||||||
appendBreakpointType( breakpoint, label );
|
appendBreakpointType(breakpoint, label);
|
||||||
appendIgnoreCount( breakpoint, label );
|
appendIgnoreCount(breakpoint, label);
|
||||||
appendCondition( breakpoint, label );
|
appendCondition(breakpoint, label);
|
||||||
return label.toString();
|
return label.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getFunctionBreakpointText( ICFunctionBreakpoint breakpoint, boolean qualified ) throws CoreException {
|
protected static String getFunctionBreakpointText(ICFunctionBreakpoint breakpoint, boolean qualified) throws CoreException {
|
||||||
StringBuffer label = new StringBuffer();
|
StringBuffer label = new StringBuffer();
|
||||||
appendSourceName( breakpoint, label, qualified );
|
appendSourceName(breakpoint, label, qualified);
|
||||||
appendFunction( breakpoint, label );
|
appendFunction(breakpoint, label);
|
||||||
appendBreakpointType( breakpoint, label );
|
appendBreakpointType(breakpoint, label);
|
||||||
appendIgnoreCount( breakpoint, label );
|
appendIgnoreCount(breakpoint, label);
|
||||||
appendCondition( breakpoint, label );
|
appendCondition(breakpoint, label);
|
||||||
return label.toString();
|
return label.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuffer appendSourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException {
|
protected static StringBuffer appendSourceName(ICBreakpoint breakpoint, StringBuffer label, boolean qualified) throws CoreException {
|
||||||
String handle = breakpoint.getSourceHandle();
|
String handle = breakpoint.getSourceHandle();
|
||||||
if ( !isEmpty( handle ) ) {
|
if (!isEmpty(handle)) {
|
||||||
IPath path = new Path( handle );
|
IPath path = new Path(handle);
|
||||||
if ( path.isValidPath( handle ) ) {
|
if (path.isValidPath(handle)) {
|
||||||
label.append( qualified ? path.toOSString() : path.lastSegment() );
|
label.append(qualified ? path.toOSString() : path.lastSegment());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuffer appendLineNumber( ICLineBreakpoint breakpoint, StringBuffer label ) throws CoreException {
|
protected static StringBuffer appendLineNumber(ICLineBreakpoint breakpoint, StringBuffer label) throws CoreException {
|
||||||
int lineNumber = breakpoint.getLineNumber();
|
int lineNumber = breakpoint.getLineNumber();
|
||||||
if ( lineNumber > 0 ) {
|
if (lineNumber > 0) {
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.0" ), new String[]{ Integer.toString( lineNumber ) } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.0"), new String[]{ Integer.toString(lineNumber) })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuffer appendAddress( ICAddressBreakpoint breakpoint, StringBuffer label ) throws CoreException {
|
protected static StringBuffer appendAddress(ICAddressBreakpoint breakpoint, StringBuffer label) throws CoreException {
|
||||||
try {
|
try {
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.1" ), new String[]{ breakpoint.getAddress() } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.1"), new String[]{ breakpoint.getAddress() })); //$NON-NLS-1$
|
||||||
}
|
} catch (NumberFormatException e) {
|
||||||
catch( NumberFormatException e ) {
|
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuffer appendFunction( ICFunctionBreakpoint breakpoint, StringBuffer label ) throws CoreException {
|
protected static StringBuffer appendFunction(ICFunctionBreakpoint breakpoint, StringBuffer label) throws CoreException {
|
||||||
String function = breakpoint.getFunction();
|
String function = breakpoint.getFunction();
|
||||||
if ( function != null && function.trim().length() > 0 ) {
|
if (function != null && function.trim().length() > 0) {
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.2" ), new String[]{ function.trim() } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.2"), new String[]{ function.trim() })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuffer appendIgnoreCount( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException {
|
protected static StringBuffer appendIgnoreCount(ICBreakpoint breakpoint, StringBuffer label) throws CoreException {
|
||||||
int ignoreCount = breakpoint.getIgnoreCount();
|
int ignoreCount = breakpoint.getIgnoreCount();
|
||||||
if ( ignoreCount > 0 ) {
|
if (ignoreCount > 0) {
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.3" ), new String[]{ Integer.toString( ignoreCount ) } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.3"), new String[]{ Integer.toString(ignoreCount) })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException {
|
protected static void appendCondition(ICBreakpoint breakpoint, StringBuffer buffer) throws CoreException {
|
||||||
String condition = breakpoint.getCondition();
|
String condition = breakpoint.getCondition();
|
||||||
if ( condition != null && condition.length() > 0 ) {
|
if (condition != null && condition.length() > 0) {
|
||||||
buffer.append( ' ' );
|
buffer.append(' ');
|
||||||
buffer.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.4" ), new String[] { condition } ) ); //$NON-NLS-1$
|
buffer.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.4"), new String[] { condition })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException {
|
private static void appendWatchExpression(ICWatchpoint watchpoint, StringBuffer label) throws CoreException {
|
||||||
String expression = watchpoint.getExpression();
|
String expression = watchpoint.getExpression();
|
||||||
if ( expression != null && expression.length() > 0 ) {
|
if (expression != null && expression.length() > 0) {
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.5" ), new String[] { expression } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.5"), new String[] { expression })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendWatchMemorySpace( ICWatchpoint2 watchpoint, StringBuffer label ) throws CoreException {
|
private static void appendWatchMemorySpace(ICWatchpoint2 watchpoint, StringBuffer label) throws CoreException {
|
||||||
String memorySpace = watchpoint.getMemorySpace();
|
String memorySpace = watchpoint.getMemorySpace();
|
||||||
if ( memorySpace != null && memorySpace.length() > 0 ) {
|
if (memorySpace != null && memorySpace.length() > 0) {
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.6" ), new String[] { memorySpace } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format( DebugCoreMessages.getString("CDebugUtils.6"), new String[] { memorySpace })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendWatchRange( ICWatchpoint2 watchpoint, StringBuffer label ) throws CoreException {
|
private static void appendWatchRange(ICWatchpoint2 watchpoint, StringBuffer label) throws CoreException {
|
||||||
String range = watchpoint.getRange().toString();
|
String range = watchpoint.getRange().toString();
|
||||||
if ( range.length() > 0 && !range.equals( "0" ) ) { //$NON-NLS-1$
|
if (range.length() > 0 && !range.equals("0")) { //$NON-NLS-1$
|
||||||
label.append( ' ' );
|
label.append(' ');
|
||||||
label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.7" ), new String[]{ range } ) ); //$NON-NLS-1$
|
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.7"), new String[]{ range })); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static StringBuffer appendBreakpointType( ICBreakpoint breakpoint, StringBuffer label ) throws CoreException {
|
protected static StringBuffer appendBreakpointType(ICBreakpoint breakpoint, StringBuffer label) throws CoreException {
|
||||||
if (breakpoint instanceof ICBreakpointType) {
|
if (breakpoint instanceof ICBreakpointType) {
|
||||||
String typeString = ""; //$NON-NLS-1$
|
String typeString = ""; //$NON-NLS-1$
|
||||||
int type = ((ICBreakpointType) breakpoint).getType();
|
int type = ((ICBreakpointType) breakpoint).getType();
|
||||||
|
@ -500,19 +488,17 @@ public class CDebugUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isEmpty( String string ) {
|
private static boolean isEmpty(String string) {
|
||||||
return ( string == null || string.trim().length() == 0 );
|
return (string == null || string.trim().length() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CharsetDecoder fDecoder;
|
private static CharsetDecoder fDecoder;
|
||||||
|
|
||||||
public static CharsetDecoder getCharsetDecoder() {
|
public static CharsetDecoder getCharsetDecoder() {
|
||||||
String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_CHARSET );
|
String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_CHARSET);
|
||||||
if (fDecoder == null || !fDecoder.charset().name().equals(charsetName))
|
if (fDecoder == null || !fDecoder.charset().name().equals(charsetName)) {
|
||||||
{
|
|
||||||
Charset charset = Charset.forName(charsetName);
|
Charset charset = Charset.forName(charsetName);
|
||||||
fDecoder = charset.newDecoder();
|
fDecoder = charset.newDecoder();
|
||||||
}
|
}
|
||||||
|
@ -647,8 +633,7 @@ public class CDebugUtils {
|
||||||
IFile projFile = null;
|
IFile projFile = null;
|
||||||
try {
|
try {
|
||||||
projFile = cproject.getProject().getFile(CDebugUtils.getProgramPath(config));
|
projFile = cproject.getProject().getFile(CDebugUtils.getProgramPath(config));
|
||||||
}
|
} catch (IllegalArgumentException exc) {
|
||||||
catch (IllegalArgumentException exc) {
|
|
||||||
// thrown if relative path that resolves to a root file (e.g., "..\somefile")
|
// thrown if relative path that resolves to a root file (e.g., "..\somefile")
|
||||||
}
|
}
|
||||||
if (projFile != null && projFile.exists()) {
|
if (projFile != null && projFile.exists()) {
|
||||||
|
|
|
@ -6,14 +6,13 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.ui.sourcelookup;
|
package org.eclipse.cdt.debug.ui.sourcelookup;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.eclipse.cdt.debug.core.CDebugUtils;
|
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocation;
|
||||||
|
@ -37,39 +36,37 @@ public class DefaultSourceLocator extends CSourceLookupDirector {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#initializeFromMemento(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
|
* @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector#initializeFromMemento(java.lang.String, org.eclipse.debug.core.ILaunchConfiguration)
|
||||||
*/
|
*/
|
||||||
public void initializeFromMemento( String memento, ILaunchConfiguration configuration ) throws CoreException {
|
public void initializeFromMemento(String memento, ILaunchConfiguration configuration) throws CoreException {
|
||||||
Element rootElement = DebugPlugin.parseDocument( memento );
|
Element rootElement = DebugPlugin.parseDocument(memento);
|
||||||
if ( rootElement.getNodeName().equalsIgnoreCase( OldDefaultSourceLocator.ELEMENT_NAME ) ) {
|
if (rootElement.getNodeName().equalsIgnoreCase(OldDefaultSourceLocator.ELEMENT_NAME)) {
|
||||||
initializeFromOldMemento( memento, configuration );
|
initializeFromOldMemento(memento, configuration);
|
||||||
}
|
} else {
|
||||||
else {
|
super.initializeFromMemento(memento, configuration);
|
||||||
super.initializeFromMemento( memento, configuration );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeFromOldMemento( String memento, ILaunchConfiguration configuration ) throws CoreException {
|
private void initializeFromOldMemento(String memento, ILaunchConfiguration configuration) throws CoreException {
|
||||||
dispose();
|
dispose();
|
||||||
setLaunchConfiguration( configuration );
|
setLaunchConfiguration(configuration);
|
||||||
OldDefaultSourceLocator old = new OldDefaultSourceLocator();
|
OldDefaultSourceLocator old = new OldDefaultSourceLocator();
|
||||||
old.initializeFromMemento( memento );
|
old.initializeFromMemento(memento);
|
||||||
ICSourceLocator csl = (ICSourceLocator)old.getAdapter( ICSourceLocator.class );
|
ICSourceLocator csl = (ICSourceLocator)old.getAdapter(ICSourceLocator.class);
|
||||||
setFindDuplicates( csl.searchForDuplicateFiles() );
|
setFindDuplicates(csl.searchForDuplicateFiles());
|
||||||
ICSourceLocation[] locations = csl.getSourceLocations();
|
ICSourceLocation[] locations = csl.getSourceLocations();
|
||||||
|
|
||||||
// Check if the old source locator includes all referenced projects.
|
// Check if the old source locator includes all referenced projects.
|
||||||
// If so, DefaultSpourceContainer should be used.
|
// If so, DefaultSpourceContainer should be used.
|
||||||
IProject project = csl.getProject();
|
IProject project = csl.getProject();
|
||||||
List list = CDebugUtils.getReferencedProjects( project );
|
List<IProject> list = CDebugUtils.getReferencedProjects(project);
|
||||||
HashSet names = new HashSet( list.size() + 1 );
|
HashSet<String> names = new HashSet<String>(list.size() + 1);
|
||||||
names.add( project.getName() );
|
names.add(project.getName());
|
||||||
Iterator it = list.iterator();
|
for (IProject proj : list) {
|
||||||
while( it.hasNext() ) {
|
names.add(proj.getName());
|
||||||
names.add( ((IProject)it.next()).getName() );
|
|
||||||
}
|
}
|
||||||
boolean includesDefault = true;
|
boolean includesDefault = true;
|
||||||
for( int i = 0; i < locations.length; ++i ) {
|
for (int i = 0; i < locations.length; ++i) {
|
||||||
if ( locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation)locations[i]).isGeneric() ) {
|
if (locations[i] instanceof IProjectSourceLocation && ((IProjectSourceLocation)locations[i]).isGeneric()) {
|
||||||
if ( !names.contains( ((IProjectSourceLocation)locations[i]).getProject().getName() ) ) {
|
if (!names.contains(((IProjectSourceLocation)locations[i]).getProject().getName())) {
|
||||||
includesDefault = false;
|
includesDefault = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,20 +74,22 @@ public class DefaultSourceLocator extends CSourceLookupDirector {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate an array of new source containers including DefaultSourceContainer
|
// Generate an array of new source containers including DefaultSourceContainer
|
||||||
ArrayList locs = new ArrayList( locations.length );
|
ArrayList<ICSourceLocation> locs = new ArrayList<ICSourceLocation>(locations.length);
|
||||||
for ( int i = 0; i < locations.length; ++i ) {
|
for (int i = 0; i < locations.length; ++i) {
|
||||||
if ( !includesDefault || !( locations[i] instanceof IProjectSourceLocation && names.contains( ((IProjectSourceLocation)locations[i]).getProject().getName() ) ) )
|
if (!includesDefault || !(locations[i] instanceof IProjectSourceLocation &&
|
||||||
locs.add( locations[i] );
|
names.contains(((IProjectSourceLocation)locations[i]).getProject().getName()))) {
|
||||||
|
locs.add(locations[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISourceContainer[] containers = SourceUtils.convertSourceLocations( (ICSourceLocation[])locs.toArray( new ICSourceLocation[locs.size()] ) );
|
ISourceContainer[] containers = SourceUtils.convertSourceLocations(locs.toArray(new ICSourceLocation[locs.size()]));
|
||||||
ArrayList cons = new ArrayList( Arrays.asList( containers ) );
|
ArrayList<ISourceContainer> cons = new ArrayList<ISourceContainer>(Arrays.asList(containers));
|
||||||
if ( includesDefault ) {
|
if (includesDefault) {
|
||||||
DefaultSourceContainer defaultContainer = new DefaultSourceContainer();
|
DefaultSourceContainer defaultContainer = new DefaultSourceContainer();
|
||||||
defaultContainer.init( this );
|
defaultContainer.init(this);
|
||||||
cons.add( 0, defaultContainer );
|
cons.add(0, defaultContainer);
|
||||||
}
|
}
|
||||||
setSourceContainers( (ISourceContainer[])cons.toArray( new ISourceContainer[cons.size()] ) );
|
setSourceContainers(cons.toArray(new ISourceContainer[cons.size()]));
|
||||||
initializeParticipants();
|
initializeParticipants();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue