Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2018-11-20 21:20:39 +0000
committerJonah Graham2018-11-20 21:20:39 +0000
commit48d2271a58a68743e428d3096d2bca054d04e310 (patch)
tree235ba23e71c393ad22d1d57fc8fdfec14754c4ee /dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug
parent3cf0297769e5cfb91823e93ce570120a75fe01ce (diff)
downloadorg.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.gz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.tar.xz
org.eclipse.cdt-48d2271a58a68743e428d3096d2bca054d04e310.zip
Bug 540373: Normalize newlines with .gitattributes
There is also a new script to verify completeness of .gitattributes: releng/scripts/verify_gitattributes.sh Change-Id: I2ce270852ab54b66b6c474a6ec94203fe5bba78b
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java410
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java252
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyAnnotationModel.java178
3 files changed, 420 insertions, 420 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java
index aee832fb070..baccd1edea5 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java
@@ -1,206 +1,206 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.debug.ui.disassembly.rulers.IColumnSupport;
-import org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn;
-import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnDescriptor;
-import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnRegistry;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.text.source.CompositeRuler;
-import org.eclipse.jface.text.source.IVerticalRulerColumn;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.jface.util.SafeRunnable;
-
-/**
- * Implements the ruler column support of for the given disassembly part.
- * <p>
- * This is currently only used to support vertical ruler columns.
- * </p>
- */
-class DisassemblyColumnSupport implements IColumnSupport {
- private final DisassemblyPart fDisassembly;
- private final RulerColumnRegistry fRegistry;
- private final List<IContributedRulerColumn> fColumns;
-
- /**
- * Creates a new column support for the given disassembly part. Only the disassembly part itself should normally
- * create such an instance.
- *
- * @param editor the disassembly part
- * @param registry the contribution registry to refer to
- */
- public DisassemblyColumnSupport(DisassemblyPart disassembly, RulerColumnRegistry registry) {
- Assert.isLegal(disassembly != null);
- Assert.isLegal(registry != null);
- fDisassembly= disassembly;
- fRegistry= registry;
- fColumns= new ArrayList<IContributedRulerColumn>();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IColumnSupport#setColumnVisible(java.lang.String, boolean)
- */
- @Override
- public final void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible) {
- Assert.isLegal(descriptor != null);
-
- final CompositeRuler ruler= getRuler();
- if (ruler == null)
- return;
-
- if (!isColumnSupported(descriptor))
- visible= false;
-
- if (isColumnVisible(descriptor)) {
- if (!visible)
- removeColumn(ruler, descriptor);
- } else {
- if (visible)
- addColumn(ruler, descriptor);
- }
- }
-
- private void addColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) {
-
- final int idx= computeIndex(ruler, descriptor);
-
- SafeRunnable runnable= new SafeRunnable() {
- @Override
- public void run() throws Exception {
- IContributedRulerColumn column= descriptor.createColumn(fDisassembly);
- fColumns.add(column);
- initializeColumn(column);
- ruler.addDecorator(idx, column);
- }
- };
- SafeRunner.run(runnable);
- }
-
- /**
- * Hook to let subclasses initialize a newly created column.
- * <p>
- * Subclasses may extend this method.</p>
- *
- * @param column the created column
- */
- protected void initializeColumn(IContributedRulerColumn column) {
- }
-
- private void removeColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) {
- removeColumn(ruler, getVisibleColumn(ruler, descriptor));
- }
-
- private void removeColumn(final CompositeRuler ruler, final IContributedRulerColumn rulerColumn) {
- if (rulerColumn != null) {
- SafeRunnable runnable= new SafeRunnable() {
- @Override
- public void run() throws Exception {
- if (ruler != null)
- ruler.removeDecorator(rulerColumn);
- rulerColumn.columnRemoved();
- }
- };
- SafeRunner.run(runnable);
- }
- }
-
- /**
- * Returns the currently visible column matching <code>id</code>, <code>null</code> if
- * none.
- *
- * @param ruler the composite ruler to scan
- * @param descriptor the descriptor of the column of interest
- * @return the matching column or <code>null</code>
- */
- private IContributedRulerColumn getVisibleColumn(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
- for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
- IVerticalRulerColumn column= (IVerticalRulerColumn)it.next();
- if (column instanceof IContributedRulerColumn) {
- IContributedRulerColumn rulerColumn= (IContributedRulerColumn)column;
- RulerColumnDescriptor rcd= rulerColumn.getDescriptor();
- if (descriptor.equals(rcd))
- return rulerColumn;
- }
- }
- return null;
- }
-
- /**
- * Computes the insertion index for a column contribution into the currently visible columns.
- *
- * @param ruler the composite ruler into which to insert the column
- * @param descriptor the descriptor to compute the index for
- * @return the insertion index for a new column
- */
- private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
- int index= 0;
- List<?> all= fRegistry.getColumnDescriptors();
- int newPos= all.indexOf(descriptor);
- for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) it.next();
- if (column instanceof IContributedRulerColumn) {
- RulerColumnDescriptor rcd= ((IContributedRulerColumn)column).getDescriptor();
- if (rcd != null && all.indexOf(rcd) > newPos)
- break;
- }
- index++;
- }
- return index;
- }
-
- @Override
- public final boolean isColumnVisible(RulerColumnDescriptor descriptor) {
- Assert.isLegal(descriptor != null);
- CompositeRuler ruler= getRuler();
- return ruler != null && getVisibleColumn(ruler, descriptor) != null;
- }
-
- @Override
- public final boolean isColumnSupported(RulerColumnDescriptor descriptor) {
- Assert.isLegal(descriptor != null);
- if (getRuler() == null)
- return false;
-
- return descriptor.matchesPart(fDisassembly);
- }
-
- /**
- * Returns the disassembly part's vertical ruler, if it is a {@link CompositeRuler}, <code>null</code>
- * otherwise.
- *
- * @return the disassembly part's {@link CompositeRuler} or <code>null</code>
- */
- private CompositeRuler getRuler() {
- Object ruler= fDisassembly.getAdapter(IVerticalRulerInfo.class);
- if (ruler instanceof CompositeRuler)
- return (CompositeRuler) ruler;
- return null;
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * Subclasses may extend this method.</p>
- *
- */
- @Override
- public void dispose() {
- for (Iterator<IContributedRulerColumn> iter= new ArrayList<IContributedRulerColumn>(fColumns).iterator(); iter.hasNext();)
- removeColumn(getRuler(), iter.next());
- fColumns.clear();
- }
-}
+package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.debug.ui.disassembly.rulers.IColumnSupport;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnDescriptor;
+import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnRegistry;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.jface.util.SafeRunnable;
+
+/**
+ * Implements the ruler column support of for the given disassembly part.
+ * <p>
+ * This is currently only used to support vertical ruler columns.
+ * </p>
+ */
+class DisassemblyColumnSupport implements IColumnSupport {
+ private final DisassemblyPart fDisassembly;
+ private final RulerColumnRegistry fRegistry;
+ private final List<IContributedRulerColumn> fColumns;
+
+ /**
+ * Creates a new column support for the given disassembly part. Only the disassembly part itself should normally
+ * create such an instance.
+ *
+ * @param editor the disassembly part
+ * @param registry the contribution registry to refer to
+ */
+ public DisassemblyColumnSupport(DisassemblyPart disassembly, RulerColumnRegistry registry) {
+ Assert.isLegal(disassembly != null);
+ Assert.isLegal(registry != null);
+ fDisassembly= disassembly;
+ fRegistry= registry;
+ fColumns= new ArrayList<IContributedRulerColumn>();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.IColumnSupport#setColumnVisible(java.lang.String, boolean)
+ */
+ @Override
+ public final void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible) {
+ Assert.isLegal(descriptor != null);
+
+ final CompositeRuler ruler= getRuler();
+ if (ruler == null)
+ return;
+
+ if (!isColumnSupported(descriptor))
+ visible= false;
+
+ if (isColumnVisible(descriptor)) {
+ if (!visible)
+ removeColumn(ruler, descriptor);
+ } else {
+ if (visible)
+ addColumn(ruler, descriptor);
+ }
+ }
+
+ private void addColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) {
+
+ final int idx= computeIndex(ruler, descriptor);
+
+ SafeRunnable runnable= new SafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ IContributedRulerColumn column= descriptor.createColumn(fDisassembly);
+ fColumns.add(column);
+ initializeColumn(column);
+ ruler.addDecorator(idx, column);
+ }
+ };
+ SafeRunner.run(runnable);
+ }
+
+ /**
+ * Hook to let subclasses initialize a newly created column.
+ * <p>
+ * Subclasses may extend this method.</p>
+ *
+ * @param column the created column
+ */
+ protected void initializeColumn(IContributedRulerColumn column) {
+ }
+
+ private void removeColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) {
+ removeColumn(ruler, getVisibleColumn(ruler, descriptor));
+ }
+
+ private void removeColumn(final CompositeRuler ruler, final IContributedRulerColumn rulerColumn) {
+ if (rulerColumn != null) {
+ SafeRunnable runnable= new SafeRunnable() {
+ @Override
+ public void run() throws Exception {
+ if (ruler != null)
+ ruler.removeDecorator(rulerColumn);
+ rulerColumn.columnRemoved();
+ }
+ };
+ SafeRunner.run(runnable);
+ }
+ }
+
+ /**
+ * Returns the currently visible column matching <code>id</code>, <code>null</code> if
+ * none.
+ *
+ * @param ruler the composite ruler to scan
+ * @param descriptor the descriptor of the column of interest
+ * @return the matching column or <code>null</code>
+ */
+ private IContributedRulerColumn getVisibleColumn(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
+ for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= (IVerticalRulerColumn)it.next();
+ if (column instanceof IContributedRulerColumn) {
+ IContributedRulerColumn rulerColumn= (IContributedRulerColumn)column;
+ RulerColumnDescriptor rcd= rulerColumn.getDescriptor();
+ if (descriptor.equals(rcd))
+ return rulerColumn;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Computes the insertion index for a column contribution into the currently visible columns.
+ *
+ * @param ruler the composite ruler into which to insert the column
+ * @param descriptor the descriptor to compute the index for
+ * @return the insertion index for a new column
+ */
+ private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
+ int index= 0;
+ List<?> all= fRegistry.getColumnDescriptors();
+ int newPos= all.indexOf(descriptor);
+ for (Iterator<?> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= (IVerticalRulerColumn) it.next();
+ if (column instanceof IContributedRulerColumn) {
+ RulerColumnDescriptor rcd= ((IContributedRulerColumn)column).getDescriptor();
+ if (rcd != null && all.indexOf(rcd) > newPos)
+ break;
+ }
+ index++;
+ }
+ return index;
+ }
+
+ @Override
+ public final boolean isColumnVisible(RulerColumnDescriptor descriptor) {
+ Assert.isLegal(descriptor != null);
+ CompositeRuler ruler= getRuler();
+ return ruler != null && getVisibleColumn(ruler, descriptor) != null;
+ }
+
+ @Override
+ public final boolean isColumnSupported(RulerColumnDescriptor descriptor) {
+ Assert.isLegal(descriptor != null);
+ if (getRuler() == null)
+ return false;
+
+ return descriptor.matchesPart(fDisassembly);
+ }
+
+ /**
+ * Returns the disassembly part's vertical ruler, if it is a {@link CompositeRuler}, <code>null</code>
+ * otherwise.
+ *
+ * @return the disassembly part's {@link CompositeRuler} or <code>null</code>
+ */
+ private CompositeRuler getRuler() {
+ Object ruler= fDisassembly.getAdapter(IVerticalRulerInfo.class);
+ if (ruler instanceof CompositeRuler)
+ return (CompositeRuler) ruler;
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ * <p>
+ * Subclasses may extend this method.</p>
+ *
+ */
+ @Override
+ public void dispose() {
+ for (Iterator<IContributedRulerColumn> iter= new ArrayList<IContributedRulerColumn>(fColumns).iterator(); iter.hasNext();)
+ removeColumn(getRuler(), iter.next());
+ fColumns.clear();
+ }
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
index 923bc1be350..60aef05e688 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java
@@ -1,126 +1,126 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2014 Wind River Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
-
-import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
-import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
-import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
-import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
-import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-/**
- * A vertical ruler column to display the opcodes of instructions.
- */
-public class OpcodeRulerColumn extends DisassemblyRulerColumn {
-
- public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.opcode"; //$NON-NLS-1$
-
- /** Maximum width of column (in characters) */
- private static final int MAXWIDTH= 20;
-
- private int fRadix;
- private String fRadixPrefix;
-
- /**
- * Default constructor.
- */
- public OpcodeRulerColumn() {
- super();
- setForeground(getColor(DisassemblyPreferenceConstants.CODE_BYTES_COLOR));
- setRadix(getPreferenceStore().getInt(DisassemblyPreferenceConstants.OPCODE_RADIX));
- }
-
- public void setRadix(int radix) {
- fRadix= radix;
- setShowRadixPrefix();
- }
-
- public void setShowRadixPrefix() {
- if (fRadix == 16) {
- fRadixPrefix = "0x"; //$NON-NLS-1$
- } else if (fRadix == 8) {
- fRadixPrefix = "0"; //$NON-NLS-1$
- } else {
- fRadixPrefix = null;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.LineNumberRulerColumn#createDisplayString(int)
- */
- @Override
- protected String createDisplayString(int line) {
- int nChars = computeNumberOfCharacters();
- if (nChars > 0) {
- DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
- try {
- int offset = doc.getLineOffset(line);
- AddressRangePosition pos = doc.getDisassemblyPosition(offset);
- if (pos instanceof DisassemblyPosition && pos.length > 0 && pos.offset == offset && pos.fValid) {
- DisassemblyPosition disassPos = (DisassemblyPosition)pos;
- if (disassPos.fOpcodes != null) {
- // Format the output.
- String str = disassPos.fOpcodes.toString(fRadix);
- int prefixLength = 0;
-
- if (fRadixPrefix != null)
- prefixLength = fRadixPrefix.length();
-
- StringBuilder buf = new StringBuilder(nChars);
-
- if (prefixLength != 0)
- buf.append(fRadixPrefix);
-
- for (int i=str.length()+prefixLength; i < nChars; ++i)
- buf.append('0');
- buf.append(str);
- if (buf.length() > nChars)
- buf.delete(nChars, buf.length());
- return buf.toString();
- }
- } else if (pos != null && !pos.fValid) {
- return DOTS.substring(0, nChars);
- }
- } catch (BadLocationException e) {
- // silently ignored
- }
- }
- return ""; //$NON-NLS-1$
- }
-
- @Override
- protected int computeNumberOfCharacters() {
- DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
- return Math.min(MAXWIDTH, doc.getMaxOpcodeLength(fRadix));
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- IPreferenceStore store = getPreferenceStore();
- boolean needRedraw = false;
- if (DisassemblyPreferenceConstants.CODE_BYTES_COLOR.equals(property)) {
- setForeground(getColor(property));
- needRedraw = true;
- } else if (DisassemblyPreferenceConstants.OPCODE_RADIX.equals(property)) {
- setRadix(store.getInt(property));
- layout(false);
- needRedraw = true;
- }
- if (needRedraw) {
- redraw();
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2011, 2014 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.debug.internal.ui.disassembly;
+
+import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
+import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * A vertical ruler column to display the opcodes of instructions.
+ */
+public class OpcodeRulerColumn extends DisassemblyRulerColumn {
+
+ public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.opcode"; //$NON-NLS-1$
+
+ /** Maximum width of column (in characters) */
+ private static final int MAXWIDTH= 20;
+
+ private int fRadix;
+ private String fRadixPrefix;
+
+ /**
+ * Default constructor.
+ */
+ public OpcodeRulerColumn() {
+ super();
+ setForeground(getColor(DisassemblyPreferenceConstants.CODE_BYTES_COLOR));
+ setRadix(getPreferenceStore().getInt(DisassemblyPreferenceConstants.OPCODE_RADIX));
+ }
+
+ public void setRadix(int radix) {
+ fRadix= radix;
+ setShowRadixPrefix();
+ }
+
+ public void setShowRadixPrefix() {
+ if (fRadix == 16) {
+ fRadixPrefix = "0x"; //$NON-NLS-1$
+ } else if (fRadix == 8) {
+ fRadixPrefix = "0"; //$NON-NLS-1$
+ } else {
+ fRadixPrefix = null;
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.LineNumberRulerColumn#createDisplayString(int)
+ */
+ @Override
+ protected String createDisplayString(int line) {
+ int nChars = computeNumberOfCharacters();
+ if (nChars > 0) {
+ DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
+ try {
+ int offset = doc.getLineOffset(line);
+ AddressRangePosition pos = doc.getDisassemblyPosition(offset);
+ if (pos instanceof DisassemblyPosition && pos.length > 0 && pos.offset == offset && pos.fValid) {
+ DisassemblyPosition disassPos = (DisassemblyPosition)pos;
+ if (disassPos.fOpcodes != null) {
+ // Format the output.
+ String str = disassPos.fOpcodes.toString(fRadix);
+ int prefixLength = 0;
+
+ if (fRadixPrefix != null)
+ prefixLength = fRadixPrefix.length();
+
+ StringBuilder buf = new StringBuilder(nChars);
+
+ if (prefixLength != 0)
+ buf.append(fRadixPrefix);
+
+ for (int i=str.length()+prefixLength; i < nChars; ++i)
+ buf.append('0');
+ buf.append(str);
+ if (buf.length() > nChars)
+ buf.delete(nChars, buf.length());
+ return buf.toString();
+ }
+ } else if (pos != null && !pos.fValid) {
+ return DOTS.substring(0, nChars);
+ }
+ } catch (BadLocationException e) {
+ // silently ignored
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ protected int computeNumberOfCharacters() {
+ DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument();
+ return Math.min(MAXWIDTH, doc.getMaxOpcodeLength(fRadix));
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ IPreferenceStore store = getPreferenceStore();
+ boolean needRedraw = false;
+ if (DisassemblyPreferenceConstants.CODE_BYTES_COLOR.equals(property)) {
+ setForeground(getColor(property));
+ needRedraw = true;
+ } else if (DisassemblyPreferenceConstants.OPCODE_RADIX.equals(property)) {
+ setRadix(store.getInt(property));
+ layout(false);
+ needRedraw = true;
+ }
+ if (needRedraw) {
+ redraw();
+ }
+ }
+
+}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyAnnotationModel.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyAnnotationModel.java
index 89848d1c955..bcf08590494 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyAnnotationModel.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyAnnotationModel.java
@@ -1,90 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2015 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
-
-import java.math.BigInteger;
-
-import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
-import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.LabelPosition;
-import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.AnnotationModel;
-
-public class DisassemblyAnnotationModel extends AnnotationModel {
-
- public DisassemblyAnnotationModel() {
- super();
- }
-
- private DisassemblyDocument getDisassemblyDocument() {
- return (DisassemblyDocument) fDocument;
- }
-
- protected Position createPositionFromSourceLine(String fileName, int lineNumber) {
- if (fileName != null) {
- return getDisassemblyDocument().getSourcePosition(fileName, lineNumber);
- }
- return null;
- }
-
- protected Position createPositionFromSourceLine(IFile file, int lineNumber) {
- if (file != null) {
- return getDisassemblyDocument().getSourcePosition(file, lineNumber);
- }
- return null;
- }
-
- protected Position createPositionFromAddress(BigInteger address) {
- if (address != null) {
- AddressRangePosition p= getDisassemblyDocument().getDisassemblyPosition(address);
- if (p != null && p.fValid) {
- return new Position(p.offset, p.length);
- }
- }
- return null;
- }
-
- protected Position createPositionFromLabel(BigInteger address) {
- if (address != null) {
- LabelPosition p = getDisassemblyDocument().getLabelPosition(address);
- if (p != null && p.fValid) {
- return new Position(p.offset, p.length);
- }
- }
- return null;
- }
-
- protected Position createPositionFromLabel(String label) {
- if (label != null) {
- try {
- Position[] labelPositions = getDisassemblyDocument().getPositions(DisassemblyDocument.CATEGORY_LABELS);
- int labelLen = label.length();
- for (Position position : labelPositions) {
- if (position instanceof LabelPosition) {
- String candidate = ((LabelPosition) position).fLabel;
- if (candidate != null && candidate.startsWith(label)) {
- // exact match or followed by ()
- if (candidate.length() == labelLen || candidate.charAt(labelLen) == '(') {
- return new Position(position.offset, position.length);
- }
- }
- }
- }
- } catch (BadPositionCategoryException exc) {
- return null;
- }
- }
- return null;
- }
-
+/*******************************************************************************
+ * Copyright (c) 2011, 2015 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional;
+
+import java.math.BigInteger;
+
+import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition;
+import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.LabelPosition;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.AnnotationModel;
+
+public class DisassemblyAnnotationModel extends AnnotationModel {
+
+ public DisassemblyAnnotationModel() {
+ super();
+ }
+
+ private DisassemblyDocument getDisassemblyDocument() {
+ return (DisassemblyDocument) fDocument;
+ }
+
+ protected Position createPositionFromSourceLine(String fileName, int lineNumber) {
+ if (fileName != null) {
+ return getDisassemblyDocument().getSourcePosition(fileName, lineNumber);
+ }
+ return null;
+ }
+
+ protected Position createPositionFromSourceLine(IFile file, int lineNumber) {
+ if (file != null) {
+ return getDisassemblyDocument().getSourcePosition(file, lineNumber);
+ }
+ return null;
+ }
+
+ protected Position createPositionFromAddress(BigInteger address) {
+ if (address != null) {
+ AddressRangePosition p= getDisassemblyDocument().getDisassemblyPosition(address);
+ if (p != null && p.fValid) {
+ return new Position(p.offset, p.length);
+ }
+ }
+ return null;
+ }
+
+ protected Position createPositionFromLabel(BigInteger address) {
+ if (address != null) {
+ LabelPosition p = getDisassemblyDocument().getLabelPosition(address);
+ if (p != null && p.fValid) {
+ return new Position(p.offset, p.length);
+ }
+ }
+ return null;
+ }
+
+ protected Position createPositionFromLabel(String label) {
+ if (label != null) {
+ try {
+ Position[] labelPositions = getDisassemblyDocument().getPositions(DisassemblyDocument.CATEGORY_LABELS);
+ int labelLen = label.length();
+ for (Position position : labelPositions) {
+ if (position instanceof LabelPosition) {
+ String candidate = ((LabelPosition) position).fLabel;
+ if (candidate != null && candidate.startsWith(label)) {
+ // exact match or followed by ()
+ if (candidate.length() == labelLen || candidate.charAt(labelLen) == '(') {
+ return new Position(position.offset, position.length);
+ }
+ }
+ }
+ }
+ } catch (BadPositionCategoryException exc) {
+ return null;
+ }
+ }
+ return null;
+ }
+
} \ No newline at end of file

Back to the top