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

Back to the top