mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +02:00
Contributing new disassembly.
This commit is contained in:
parent
b9f428181b
commit
0540c57e38
5 changed files with 73 additions and 18 deletions
|
@ -26,6 +26,9 @@ public class DisassemblyEditorPresentation extends PresentationContext implement
|
||||||
private boolean fShowInstructions = true;
|
private boolean fShowInstructions = true;
|
||||||
private boolean fShowSource = false;
|
private boolean fShowSource = false;
|
||||||
|
|
||||||
|
private boolean fShowAddresses = true;
|
||||||
|
private boolean fShowLineNumbers = true;
|
||||||
|
|
||||||
public DisassemblyEditorPresentation() {
|
public DisassemblyEditorPresentation() {
|
||||||
super( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR );
|
super( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR );
|
||||||
fShowInstructions = CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS );
|
fShowInstructions = CDebugUIPlugin.getDefault().getPreferenceStore().getBoolean( ICDebugPreferenceConstants.PREF_DISASM_SHOW_INSTRUCTIONS );
|
||||||
|
@ -47,4 +50,20 @@ public class DisassemblyEditorPresentation extends PresentationContext implement
|
||||||
public void setShowSource( boolean showSource ) {
|
public void setShowSource( boolean showSource ) {
|
||||||
fShowSource = showSource;
|
fShowSource = showSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean showAddresses() {
|
||||||
|
return fShowAddresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowAddresses( boolean showAddresses ) {
|
||||||
|
fShowAddresses = showAddresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean showLineNumbers() {
|
||||||
|
return fShowLineNumbers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowLineNumbers( boolean showLineNumbers ) {
|
||||||
|
fShowLineNumbers = showLineNumbers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class DocumentAnnotationProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update( Object parent, Object element, int index, IDocumentPresentation context ) {
|
public void update( Object parent, Object element, int index, IDocumentPresentation context ) {
|
||||||
IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter( parent );
|
IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter( element );
|
||||||
if ( annotationProvider != null ) {
|
if ( annotationProvider != null ) {
|
||||||
Object root = getDocument().getContentProvider().getRoot();
|
Object root = getDocument().getContentProvider().getRoot();
|
||||||
Object base = getDocument().getContentProvider().getBase();
|
Object base = getDocument().getContentProvider().getBase();
|
||||||
|
|
|
@ -30,22 +30,22 @@ public class DocumentLabelProvider extends BaseLabelProvider {
|
||||||
super();
|
super();
|
||||||
fDocument = document;
|
fDocument = document;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
public void update( Object parent, Object[] elements, IDocumentPresentation context ) {
|
// public void update( Object parent, Object[] elements, IDocumentPresentation context ) {
|
||||||
IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent );
|
// IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent );
|
||||||
if ( labelProvider != null ) {
|
// if ( labelProvider != null ) {
|
||||||
Object root = getDocument().getContentProvider().getRoot();
|
// Object root = getDocument().getContentProvider().getRoot();
|
||||||
Object base = getDocument().getContentProvider().getBase();
|
// Object base = getDocument().getContentProvider().getBase();
|
||||||
DocumentLabelUpdate[] updates = new DocumentLabelUpdate[elements.length];
|
// DocumentLabelUpdate[] updates = new DocumentLabelUpdate[elements.length];
|
||||||
for ( int i = 0; i < elements.length; ++i ) {
|
// for ( int i = 0; i < elements.length; ++i ) {
|
||||||
updates[i] = new DocumentLabelUpdate( this, context, root, base, elements[i], i );
|
// updates[i] = new DocumentLabelUpdate( this, context, root, base, elements[i], i );
|
||||||
}
|
// }
|
||||||
labelProvider.update( updates );
|
// labelProvider.update( updates );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void update( Object parent, Object element, int index, IDocumentPresentation context ) {
|
public void update( Object parent, Object element, int index, IDocumentPresentation context ) {
|
||||||
IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent );
|
IDocumentElementLabelProvider labelProvider = getLabelAdapter( element );
|
||||||
if ( labelProvider != null ) {
|
if ( labelProvider != null ) {
|
||||||
Object root = getDocument().getContentProvider().getRoot();
|
Object root = getDocument().getContentProvider().getRoot();
|
||||||
Object base = getDocument().getContentProvider().getBase();
|
Object base = getDocument().getContentProvider().getBase();
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.internal.ui.disassembly.viewer;
|
package org.eclipse.cdt.debug.internal.ui.disassembly.viewer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation;
|
import org.eclipse.cdt.debug.ui.disassembly.IDocumentPresentation;
|
||||||
|
@ -22,6 +24,7 @@ import org.eclipse.jface.text.IRegion;
|
||||||
import org.eclipse.jface.text.Position;
|
import org.eclipse.jface.text.Position;
|
||||||
import org.eclipse.jface.text.source.Annotation;
|
import org.eclipse.jface.text.source.Annotation;
|
||||||
import org.eclipse.jface.text.source.AnnotationModel;
|
import org.eclipse.jface.text.source.AnnotationModel;
|
||||||
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the model elements into the text content
|
* Converts the model elements into the text content
|
||||||
|
@ -140,9 +143,6 @@ public class VirtualDocument extends Document {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // scrolling down
|
else { // scrolling down
|
||||||
for ( int i = 0; i < offset - oldOffset; ++i ) {
|
|
||||||
// removePosition( CATEGORY_LINE, new LinePosition( ) )
|
|
||||||
}
|
|
||||||
line += offset - oldOffset;
|
line += offset - oldOffset;
|
||||||
}
|
}
|
||||||
for ( int i = 0; i < intersectCount; ++i ) {
|
for ( int i = 0; i < intersectCount; ++i ) {
|
||||||
|
@ -196,10 +196,41 @@ public class VirtualDocument extends Document {
|
||||||
getAnnotationProvider().update( getContentProvider().getInput(), element, index, getPresentationContext() );
|
getAnnotationProvider().update( getContentProvider().getInput(), element, index, getPresentationContext() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected void updateAnnotations( int lineNumber, Annotation[] annotations ) {
|
protected void updateAnnotations( int lineNumber, Annotation[] annotations ) {
|
||||||
|
IAnnotationModel annotationModel = getAnnotationModel();
|
||||||
|
try {
|
||||||
|
Position[] positions = getPositions( CATEGORY_LINE );
|
||||||
|
if ( lineNumber < positions.length ) {
|
||||||
|
Iterator it = annotationModel.getAnnotationIterator();
|
||||||
|
ArrayList<Annotation> oldAnnotations = new ArrayList<Annotation>( 3 );
|
||||||
|
while( it.hasNext() ) {
|
||||||
|
Annotation ann = (Annotation)it.next();
|
||||||
|
if ( positions[lineNumber].equals( annotationModel.getPosition( ann ) ) ) {
|
||||||
|
oldAnnotations.add( ann );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( Annotation ann : oldAnnotations ) {
|
||||||
|
annotationModel.removeAnnotation( ann );
|
||||||
|
}
|
||||||
|
for ( Annotation ann : annotations ) {
|
||||||
|
annotationModel.addAnnotation( ann, positions[lineNumber] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( BadPositionCategoryException e ) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final void labelDone( Object element, int lineNumber, Properties labels ) {
|
final void labelDone( Object element, int lineNumber, Properties labels ) {
|
||||||
|
try {
|
||||||
|
String line = labels.getProperty( IDocumentPresentation.ATTR_LINE_LABEL );
|
||||||
|
IRegion region = getLineInformation( lineNumber );
|
||||||
|
if ( get( region.getOffset(), region.getLength() ).compareTo( line ) != 0 )
|
||||||
|
replace( region.getOffset(), region.getLength(), line );
|
||||||
|
}
|
||||||
|
catch( BadLocationException e ) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeLine( int lineNumber ) {
|
protected void removeLine( int lineNumber ) {
|
||||||
|
|
|
@ -25,4 +25,9 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationConte
|
||||||
*/
|
*/
|
||||||
public interface IDocumentPresentation extends IPresentationContext {
|
public interface IDocumentPresentation extends IPresentationContext {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temporary attribute for testing.
|
||||||
|
*/
|
||||||
|
public static final String ATTR_LINE_LABEL = "lineLabel"; //$NON-NLS-1$
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue