mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Bug 515296: Changed the message when only Address
When the Source Not Found Editor opens with only an address, the message is changed, to confuse the user less. Change-Id: I1dcc9fae80d20975b00d2d356469ddda8c2d8d2b Signed-off-by: Yannick Mayeur <yannick.mayeur@gmail.com> Signed-off-by: Jonah Graham <jonah@kichwacoders.com> Also-by: Pierre Sachot <sachot.pierre@laposte.net> Also-by: Jonah Graham <jonah@kichwacoders.com>
This commit is contained in:
parent
60503efc58
commit
832f7f5a47
4 changed files with 64 additions and 32 deletions
|
@ -28,4 +28,14 @@ public interface ICSourceNotFoundDescription {
|
|||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* Return true if the debug element only is an address, false if not. This
|
||||
* is used by the editor to know wich type of message he should use.
|
||||
*
|
||||
* @return a boolean that is true if the debug element only is an address
|
||||
*/
|
||||
default boolean isAddressOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -176,11 +176,18 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
if (context == null)
|
||||
return super.getText();
|
||||
String contextDescription;
|
||||
boolean isAddressOnly;
|
||||
ICSourceNotFoundDescription description = context.getAdapter(ICSourceNotFoundDescription.class);
|
||||
if (description != null)
|
||||
if (description != null) {
|
||||
contextDescription = description.getDescription();
|
||||
else
|
||||
isAddressOnly = description.isAddressOnly();
|
||||
} else {
|
||||
contextDescription = context.toString();
|
||||
isAddressOnly = false;
|
||||
}
|
||||
if (isAddressOnly) {
|
||||
return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_8, contextDescription);
|
||||
}
|
||||
return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_3, contextDescription);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ CSourceNotFoundEditor_4=View Disassembly...
|
|||
CSourceNotFoundEditor_5=Edit Source Lookup Path...
|
||||
CSourceNotFoundEditor_6=Configure when this editor is shown
|
||||
CSourceNotFoundEditor_7=Preferences...
|
||||
CSourceNotFoundEditor_8=Break at address \"{0}\" with no debug information available, or outside of program code.
|
||||
CompilationDirectorySourceContainerDialog_0=Directory Selection
|
||||
CompilationDirectorySourceContainerDialog_1=Choose directory to add:
|
||||
CompilationDirectorySourceContainerDialog_2=Compilation directory
|
||||
|
|
|
@ -44,39 +44,32 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
|||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
||||
if (adapterType.equals(ICSourceNotFoundDescription.class) && adaptableObject instanceof IFrameDMContext) {
|
||||
final IFrameDMContext frameDMC = (IFrameDMContext) adaptableObject;
|
||||
return (T) new ICSourceNotFoundDescription() {
|
||||
|
||||
Query<IStack.IFrameDMData> query = new Query<IStack.IFrameDMData>() {
|
||||
@Override
|
||||
public String getDescription() {
|
||||
Query<IStack.IFrameDMData> query = new Query<IStack.IFrameDMData>() {
|
||||
@Override
|
||||
protected void execute(DataRequestMonitor<IStack.IFrameDMData> rm) {
|
||||
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(),
|
||||
frameDMC.getSessionId());
|
||||
protected void execute(DataRequestMonitor<IStack.IFrameDMData> rm) {
|
||||
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(),
|
||||
frameDMC.getSessionId());
|
||||
|
||||
IStack stack = tracker.getService(IStack.class);
|
||||
if (stack != null) {
|
||||
stack.getFrameData(frameDMC, rm);
|
||||
} else {
|
||||
rm.setData(null);
|
||||
rm.done();
|
||||
}
|
||||
tracker.dispose();
|
||||
}
|
||||
};
|
||||
DsfSession session = DsfSession.getSession(frameDMC.getSessionId());
|
||||
if (session != null && session.getExecutor() != null) {
|
||||
session.getExecutor().execute(query);
|
||||
try {
|
||||
IFrameDMData dmData = query.get();
|
||||
return getFrameDescription(dmData);
|
||||
} catch (Exception e) {
|
||||
return frameDMC.toString();
|
||||
}
|
||||
IStack stack = tracker.getService(IStack.class);
|
||||
if (stack != null) {
|
||||
stack.getFrameData(frameDMC, rm);
|
||||
} else {
|
||||
rm.setData(null);
|
||||
rm.done();
|
||||
}
|
||||
return frameDMC.toString();
|
||||
tracker.dispose();
|
||||
}
|
||||
};
|
||||
DsfSession session = DsfSession.getSession(frameDMC.getSessionId());
|
||||
if (session != null && session.getExecutor() != null) {
|
||||
session.getExecutor().execute(query);
|
||||
try {
|
||||
IFrameDMData dmData = query.get();
|
||||
return (T) getFrameDescription(dmData);
|
||||
} catch (Exception e) {
|
||||
// fall through, not able to adapt
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -93,7 +86,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
|||
* @param frame
|
||||
* @return the frame description
|
||||
*/
|
||||
private static String getFrameDescription(IStack.IFrameDMData frame) {
|
||||
private static ICSourceNotFoundDescription getFrameDescription(IStack.IFrameDMData frame) {
|
||||
String formatString = ""; //$NON-NLS-1$
|
||||
String[] propertyNames = null;
|
||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
||||
|
@ -103,6 +96,9 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
|||
String file = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FILE);
|
||||
String function = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FUNCTION);
|
||||
String module = (String) properties.get(ILaunchVMConstants.PROP_FRAME_MODULE);
|
||||
|
||||
boolean isAddress = false;
|
||||
|
||||
if (line != null && line >= 0 && file != null && !file.isEmpty()) {
|
||||
if (function != null && function.contains(")")) //$NON-NLS-1$
|
||||
formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__text_format;
|
||||
|
@ -133,6 +129,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
|||
} else {
|
||||
formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__Address_only__text_format;
|
||||
propertyNames = new String[] { ILaunchVMConstants.PROP_FRAME_ADDRESS };
|
||||
isAddress = true;
|
||||
}
|
||||
|
||||
Object[] propertyValues = new Object[propertyNames.length];
|
||||
|
@ -140,7 +137,24 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
|||
propertyValues[i] = properties.get(propertyNames[i]);
|
||||
}
|
||||
|
||||
return new MessageFormat(formatString).format(propertyValues, new StringBuffer(), null).toString();
|
||||
String description = new MessageFormat(formatString).format(propertyValues, new StringBuffer(), null)
|
||||
.toString();
|
||||
// makes the variable effectively final
|
||||
boolean isAddressReturn = isAddress;
|
||||
|
||||
return new ICSourceNotFoundDescription() {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddressOnly() {
|
||||
return isAddressReturn;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private static void fillFrameDataProperties(java.util.Map<String, Object> properties, IFrameDMData data) {
|
||||
|
|
Loading…
Add table
Reference in a new issue