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.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
|
@ -68,8 +67,7 @@ public class CDebugUtils {
|
|||
if (handler != null) {
|
||||
try {
|
||||
result = (Boolean)handler.handleStatus(status, source);
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
return result.booleanValue();
|
||||
|
@ -80,8 +78,7 @@ public class CDebugUtils {
|
|||
if (handler != null) {
|
||||
try {
|
||||
handler.handleStatus(status, source);
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +88,7 @@ public class CDebugUtils {
|
|||
if (handler != null) {
|
||||
try {
|
||||
handler.handleStatus(status, source);
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,8 +130,7 @@ public class CDebugUtils {
|
|||
public static char bytesToChar(byte[] bytes) {
|
||||
try {
|
||||
return (char)Short.parseShort(new String(bytes), 16);
|
||||
}
|
||||
catch( RuntimeException e ) {
|
||||
} catch (RuntimeException e) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -183,8 +178,7 @@ public class CDebugUtils {
|
|||
copy[2 * i] = bytes[bytes.length - 2 * i - 2];
|
||||
copy[2 * i + 1] = bytes[bytes.length - 2 * i - 1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
System.arraycopy(bytes, 0, copy, 0, copy.length);
|
||||
}
|
||||
return new String(copy);
|
||||
|
@ -194,8 +188,7 @@ public class CDebugUtils {
|
|||
StringBuffer sb = new StringBuffer(length);
|
||||
if (text.length() > length) {
|
||||
sb.append(text.substring(0, length));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
char[] prefix = new char[length - text.length()];
|
||||
Arrays.fill(prefix, ch);
|
||||
sb.append(prefix);
|
||||
|
@ -206,11 +199,9 @@ public class CDebugUtils {
|
|||
|
||||
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 )) )
|
||||
List<IProject> projects = CDebugUtils.getReferencedProjects(project);
|
||||
for (IProject proj : projects) {
|
||||
if (proj.exists() && (proj.equals(project)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -251,8 +242,7 @@ public class CDebugUtils {
|
|||
if (value instanceof CFloatingPointValue) {
|
||||
try {
|
||||
return ((CFloatingPointValue)value).getFloatingPointValue();
|
||||
}
|
||||
catch( CDIException e ) {
|
||||
} catch (CDIException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -288,14 +278,13 @@ public class CDebugUtils {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static List getReferencedProjects( IProject project ) {
|
||||
ArrayList list = new ArrayList( 10 );
|
||||
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()) {
|
||||
|
@ -307,13 +296,12 @@ public class CDebugUtils {
|
|||
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()) {
|
||||
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()) {
|
||||
|
@ -339,7 +327,8 @@ public class CDebugUtils {
|
|||
}
|
||||
// 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$
|
||||
}
|
||||
|
||||
|
@ -411,8 +400,7 @@ public class CDebugUtils {
|
|||
try {
|
||||
label.append(' ');
|
||||
label.append(MessageFormat.format(DebugCoreMessages.getString("CDebugUtils.1"), new String[]{ breakpoint.getAddress() })); //$NON-NLS-1$
|
||||
}
|
||||
catch( NumberFormatException e ) {
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
@ -500,7 +488,6 @@ public class CDebugUtils {
|
|||
}
|
||||
}
|
||||
return label;
|
||||
|
||||
}
|
||||
|
||||
private static boolean isEmpty(String string) {
|
||||
|
@ -511,8 +498,7 @@ public class CDebugUtils {
|
|||
|
||||
public static CharsetDecoder getCharsetDecoder() {
|
||||
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);
|
||||
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()) {
|
||||
|
|
|
@ -13,7 +13,6 @@ 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;
|
||||
|
@ -41,8 +40,7 @@ public class DefaultSourceLocator extends CSourceLookupDirector {
|
|||
Element rootElement = DebugPlugin.parseDocument(memento);
|
||||
if (rootElement.getNodeName().equalsIgnoreCase(OldDefaultSourceLocator.ELEMENT_NAME)) {
|
||||
initializeFromOldMemento(memento, configuration);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.initializeFromMemento(memento, configuration);
|
||||
}
|
||||
}
|
||||
|
@ -59,12 +57,11 @@ public class DefaultSourceLocator extends CSourceLookupDirector {
|
|||
// 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 );
|
||||
List<IProject> list = CDebugUtils.getReferencedProjects(project);
|
||||
HashSet<String> names = new HashSet<String>(list.size() + 1);
|
||||
names.add(project.getName());
|
||||
Iterator it = list.iterator();
|
||||
while( it.hasNext() ) {
|
||||
names.add( ((IProject)it.next()).getName() );
|
||||
for (IProject proj : list) {
|
||||
names.add(proj.getName());
|
||||
}
|
||||
boolean includesDefault = true;
|
||||
for (int i = 0; i < locations.length; ++i) {
|
||||
|
@ -77,20 +74,22 @@ public class DefaultSourceLocator extends CSourceLookupDirector {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
if ( !includesDefault || !( locations[i] instanceof IProjectSourceLocation && names.contains( ((IProjectSourceLocation)locations[i]).getProject().getName() ) ) )
|
||||
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 ) );
|
||||
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);
|
||||
}
|
||||
setSourceContainers( (ISourceContainer[])cons.toArray( new ISourceContainer[cons.size()] ) );
|
||||
setSourceContainers(cons.toArray(new ISourceContainer[cons.size()]));
|
||||
initializeParticipants();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue