mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +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();
|
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)
|
if (context == null)
|
||||||
return super.getText();
|
return super.getText();
|
||||||
String contextDescription;
|
String contextDescription;
|
||||||
|
boolean isAddressOnly;
|
||||||
ICSourceNotFoundDescription description = context.getAdapter(ICSourceNotFoundDescription.class);
|
ICSourceNotFoundDescription description = context.getAdapter(ICSourceNotFoundDescription.class);
|
||||||
if (description != null)
|
if (description != null) {
|
||||||
contextDescription = description.getDescription();
|
contextDescription = description.getDescription();
|
||||||
else
|
isAddressOnly = description.isAddressOnly();
|
||||||
|
} else {
|
||||||
contextDescription = context.toString();
|
contextDescription = context.toString();
|
||||||
|
isAddressOnly = false;
|
||||||
|
}
|
||||||
|
if (isAddressOnly) {
|
||||||
|
return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_8, contextDescription);
|
||||||
|
}
|
||||||
return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_3, contextDescription);
|
return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_3, contextDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ CSourceNotFoundEditor_4=View Disassembly...
|
||||||
CSourceNotFoundEditor_5=Edit Source Lookup Path...
|
CSourceNotFoundEditor_5=Edit Source Lookup Path...
|
||||||
CSourceNotFoundEditor_6=Configure when this editor is shown
|
CSourceNotFoundEditor_6=Configure when this editor is shown
|
||||||
CSourceNotFoundEditor_7=Preferences...
|
CSourceNotFoundEditor_7=Preferences...
|
||||||
|
CSourceNotFoundEditor_8=Break at address \"{0}\" with no debug information available, or outside of program code.
|
||||||
CompilationDirectorySourceContainerDialog_0=Directory Selection
|
CompilationDirectorySourceContainerDialog_0=Directory Selection
|
||||||
CompilationDirectorySourceContainerDialog_1=Choose directory to add:
|
CompilationDirectorySourceContainerDialog_1=Choose directory to add:
|
||||||
CompilationDirectorySourceContainerDialog_2=Compilation directory
|
CompilationDirectorySourceContainerDialog_2=Compilation directory
|
||||||
|
|
|
@ -44,39 +44,32 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
||||||
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
|
||||||
if (adapterType.equals(ICSourceNotFoundDescription.class) && adaptableObject instanceof IFrameDMContext) {
|
if (adapterType.equals(ICSourceNotFoundDescription.class) && adaptableObject instanceof IFrameDMContext) {
|
||||||
final IFrameDMContext frameDMC = (IFrameDMContext) adaptableObject;
|
final IFrameDMContext frameDMC = (IFrameDMContext) adaptableObject;
|
||||||
return (T) new ICSourceNotFoundDescription() {
|
Query<IStack.IFrameDMData> query = new Query<IStack.IFrameDMData>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
protected void execute(DataRequestMonitor<IStack.IFrameDMData> rm) {
|
||||||
Query<IStack.IFrameDMData> query = new Query<IStack.IFrameDMData>() {
|
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(),
|
||||||
@Override
|
frameDMC.getSessionId());
|
||||||
protected void execute(DataRequestMonitor<IStack.IFrameDMData> rm) {
|
|
||||||
DsfServicesTracker tracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(),
|
|
||||||
frameDMC.getSessionId());
|
|
||||||
|
|
||||||
IStack stack = tracker.getService(IStack.class);
|
IStack stack = tracker.getService(IStack.class);
|
||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
stack.getFrameData(frameDMC, rm);
|
stack.getFrameData(frameDMC, rm);
|
||||||
} else {
|
} else {
|
||||||
rm.setData(null);
|
rm.setData(null);
|
||||||
rm.done();
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +86,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
||||||
* @param frame
|
* @param frame
|
||||||
* @return the frame description
|
* @return the frame description
|
||||||
*/
|
*/
|
||||||
private static String getFrameDescription(IStack.IFrameDMData frame) {
|
private static ICSourceNotFoundDescription getFrameDescription(IStack.IFrameDMData frame) {
|
||||||
String formatString = ""; //$NON-NLS-1$
|
String formatString = ""; //$NON-NLS-1$
|
||||||
String[] propertyNames = null;
|
String[] propertyNames = null;
|
||||||
HashMap<String, Object> properties = new HashMap<String, Object>();
|
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 file = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FILE);
|
||||||
String function = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FUNCTION);
|
String function = (String) properties.get(ILaunchVMConstants.PROP_FRAME_FUNCTION);
|
||||||
String module = (String) properties.get(ILaunchVMConstants.PROP_FRAME_MODULE);
|
String module = (String) properties.get(ILaunchVMConstants.PROP_FRAME_MODULE);
|
||||||
|
|
||||||
|
boolean isAddress = false;
|
||||||
|
|
||||||
if (line != null && line >= 0 && file != null && !file.isEmpty()) {
|
if (line != null && line >= 0 && file != null && !file.isEmpty()) {
|
||||||
if (function != null && function.contains(")")) //$NON-NLS-1$
|
if (function != null && function.contains(")")) //$NON-NLS-1$
|
||||||
formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__text_format;
|
formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__text_format;
|
||||||
|
@ -133,6 +129,7 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
||||||
} else {
|
} else {
|
||||||
formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__Address_only__text_format;
|
formatString = MessagesForLaunchVM.StackFramesVMNode_No_columns__Address_only__text_format;
|
||||||
propertyNames = new String[] { ILaunchVMConstants.PROP_FRAME_ADDRESS };
|
propertyNames = new String[] { ILaunchVMConstants.PROP_FRAME_ADDRESS };
|
||||||
|
isAddress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] propertyValues = new Object[propertyNames.length];
|
Object[] propertyValues = new Object[propertyNames.length];
|
||||||
|
@ -140,7 +137,24 @@ public class CSourceNotFoundDescriptionFactory implements IAdapterFactory {
|
||||||
propertyValues[i] = properties.get(propertyNames[i]);
|
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) {
|
private static void fillFrameDataProperties(java.util.Map<String, Object> properties, IFrameDMData data) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue