mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Contributing new disassembly.
This commit is contained in:
parent
b9f428181b
commit
0540c57e38
5 changed files with 73 additions and 18 deletions
|
@ -25,6 +25,9 @@ public class DisassemblyEditorPresentation extends PresentationContext implement
|
|||
|
||||
private boolean fShowInstructions = true;
|
||||
private boolean fShowSource = false;
|
||||
|
||||
private boolean fShowAddresses = true;
|
||||
private boolean fShowLineNumbers = true;
|
||||
|
||||
public DisassemblyEditorPresentation() {
|
||||
super( ICDebugUIConstants.ID_DEFAULT_DISASSEMBLY_EDITOR );
|
||||
|
@ -47,4 +50,20 @@ public class DisassemblyEditorPresentation extends PresentationContext implement
|
|||
public void setShowSource( boolean 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 ) {
|
||||
IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter( parent );
|
||||
IDocumentElementAnnotationProvider annotationProvider = getAnnotationAdapter( element );
|
||||
if ( annotationProvider != null ) {
|
||||
Object root = getDocument().getContentProvider().getRoot();
|
||||
Object base = getDocument().getContentProvider().getBase();
|
||||
|
|
|
@ -30,22 +30,22 @@ public class DocumentLabelProvider extends BaseLabelProvider {
|
|||
super();
|
||||
fDocument = document;
|
||||
}
|
||||
|
||||
public void update( Object parent, Object[] elements, IDocumentPresentation context ) {
|
||||
IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent );
|
||||
if ( labelProvider != null ) {
|
||||
Object root = getDocument().getContentProvider().getRoot();
|
||||
Object base = getDocument().getContentProvider().getBase();
|
||||
DocumentLabelUpdate[] updates = new DocumentLabelUpdate[elements.length];
|
||||
for ( int i = 0; i < elements.length; ++i ) {
|
||||
updates[i] = new DocumentLabelUpdate( this, context, root, base, elements[i], i );
|
||||
}
|
||||
labelProvider.update( updates );
|
||||
}
|
||||
}
|
||||
//
|
||||
// public void update( Object parent, Object[] elements, IDocumentPresentation context ) {
|
||||
// IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent );
|
||||
// if ( labelProvider != null ) {
|
||||
// Object root = getDocument().getContentProvider().getRoot();
|
||||
// Object base = getDocument().getContentProvider().getBase();
|
||||
// DocumentLabelUpdate[] updates = new DocumentLabelUpdate[elements.length];
|
||||
// for ( int i = 0; i < elements.length; ++i ) {
|
||||
// updates[i] = new DocumentLabelUpdate( this, context, root, base, elements[i], i );
|
||||
// }
|
||||
// labelProvider.update( updates );
|
||||
// }
|
||||
// }
|
||||
|
||||
public void update( Object parent, Object element, int index, IDocumentPresentation context ) {
|
||||
IDocumentElementLabelProvider labelProvider = getLabelAdapter( parent );
|
||||
IDocumentElementLabelProvider labelProvider = getLabelAdapter( element );
|
||||
if ( labelProvider != null ) {
|
||||
Object root = getDocument().getContentProvider().getRoot();
|
||||
Object base = getDocument().getContentProvider().getBase();
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
package org.eclipse.cdt.debug.internal.ui.disassembly.viewer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
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.source.Annotation;
|
||||
import org.eclipse.jface.text.source.AnnotationModel;
|
||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
|
||||
/**
|
||||
* Converts the model elements into the text content
|
||||
|
@ -140,9 +143,6 @@ public class VirtualDocument extends Document {
|
|||
}
|
||||
}
|
||||
else { // scrolling down
|
||||
for ( int i = 0; i < offset - oldOffset; ++i ) {
|
||||
// removePosition( CATEGORY_LINE, new LinePosition( ) )
|
||||
}
|
||||
line += offset - oldOffset;
|
||||
}
|
||||
for ( int i = 0; i < intersectCount; ++i ) {
|
||||
|
@ -196,10 +196,41 @@ public class VirtualDocument extends Document {
|
|||
getAnnotationProvider().update( getContentProvider().getInput(), element, index, getPresentationContext() );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
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 ) {
|
||||
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 ) {
|
||||
|
|
|
@ -25,4 +25,9 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationConte
|
|||
*/
|
||||
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