1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Fix warnings

This commit is contained in:
Anton Leherbauer 2009-04-24 10:51:48 +00:00
parent 88c2f4a063
commit eaeddf5e8b
4 changed files with 18 additions and 32 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems and others. * Copyright (c) 2007, 2009 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -107,10 +107,10 @@ public class DisassemblyViewerConfiguration extends TextSourceViewerConfiguratio
public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) { public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
IHyperlinkDetector[] inheritedDetectors= super.getHyperlinkDetectors(sourceViewer); IHyperlinkDetector[] inheritedDetectors= super.getHyperlinkDetectors(sourceViewer);
if (fPart == null) if (fPart == null || inheritedDetectors == null)
return inheritedDetectors; return inheritedDetectors;
int inheritedDetectorsLength= inheritedDetectors != null ? inheritedDetectors.length : 0; int inheritedDetectorsLength= inheritedDetectors.length;
IHyperlinkDetector[] detectors= new IHyperlinkDetector[inheritedDetectorsLength + 1]; IHyperlinkDetector[] detectors= new IHyperlinkDetector[inheritedDetectorsLength + 1];
detectors[0]= new DisassemblyHyperlinkDetector(fPart); detectors[0]= new DisassemblyHyperlinkDetector(fPart);
for (int i= 0; i < inheritedDetectorsLength; i++) { for (int i= 0; i < inheritedDetectorsLength; i++) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems and others. * Copyright (c) 2007, 2009 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -55,6 +55,8 @@ public class DisassemblyDocument extends REDDocument {
private int fNumberOfInstructions; private int fNumberOfInstructions;
private double fMeanSizeOfInstructions = 4; private double fMeanSizeOfInstructions = 4;
private long fErrorAlignment = 0x1L;
public DisassemblyDocument() { public DisassemblyDocument() {
super(); super();
} }
@ -1020,7 +1022,7 @@ public class DisassemblyDocument extends REDDocument {
public AddressRangePosition insertErrorLine(AddressRangePosition pos, BigInteger address, BigInteger length, String line) public AddressRangePosition insertErrorLine(AddressRangePosition pos, BigInteger address, BigInteger length, String line)
throws BadLocationException { throws BadLocationException {
int hashCode = line.hashCode(); int hashCode = line.hashCode();
final long alignment = 0x1L; final long alignment = fErrorAlignment;
if (alignment > 1 && !(pos instanceof ErrorPosition)) { if (alignment > 1 && !(pos instanceof ErrorPosition)) {
AddressRangePosition before = getPositionOfAddress(address.subtract(BigInteger.ONE)); AddressRangePosition before = getPositionOfAddress(address.subtract(BigInteger.ONE));
if (before instanceof ErrorPosition && before.hashCode() == hashCode && before.offset + before.length == pos.offset) { if (before instanceof ErrorPosition && before.hashCode() == hashCode && before.offset + before.length == pos.offset) {
@ -1050,7 +1052,7 @@ public class DisassemblyDocument extends REDDocument {
} }
} }
AddressRangePosition after = getPositionOfAddress(address.add(length)); AddressRangePosition after = getPositionOfAddress(address.add(length));
if (after instanceof ErrorPosition && after.hashCode() == hashCode && pos.offset + pos.length == after.offset) { if (after instanceof ErrorPosition && after.hashCode() == hashCode && pos != null && pos.offset + pos.length == after.offset) {
assert after.fAddressOffset == address.add(length); assert after.fAddressOffset == address.add(length);
assert pos.fAddressOffset.add(pos.fAddressLength).compareTo(after.fAddressOffset) == 0; assert pos.fAddressOffset.add(pos.fAddressLength).compareTo(after.fAddressOffset) == 0;
// merge with next error position // merge with next error position
@ -1079,16 +1081,6 @@ public class DisassemblyDocument extends REDDocument {
while (length.compareTo(BigInteger.ZERO) > 0) { while (length.compareTo(BigInteger.ZERO) > 0) {
AddressRangePosition errorPos = new ErrorPosition(0, 0, address, posLen, hashCode); AddressRangePosition errorPos = new ErrorPosition(0, 0, address, posLen, hashCode);
String errorLine = buildDisassemblyLine(address, null, line); String errorLine = buildDisassemblyLine(address, null, line);
// TLEHACK: check for error messages, which occur only temporarily:
// "Target is busy. Try again later"
// "Cannot Perform requested Operation"
if (line.startsWith("Target is busy") || line.startsWith("Cannot perform")) { //$NON-NLS-1$ //$NON-NLS-2$
// try again only once...
if (!(pos instanceof ErrorPosition)) {
errorLine = "...\n"; //$NON-NLS-1$
errorPos.fValid = false;
}
}
errorPos.length = errorLine.length(); errorPos.length = errorLine.length();
pos = insertAddressRange(pos, errorPos, errorLine, true); pos = insertAddressRange(pos, errorPos, errorLine, true);
addDisassemblyPosition(errorPos); addDisassemblyPosition(errorPos);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems and others. * Copyright (c) 2007, 2009 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -17,9 +17,7 @@ import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput; import org.eclipse.cdt.ui.CDTUITools;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration; import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration;
import org.eclipse.cdt.ui.text.CSourceViewerConfiguration; import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
@ -53,7 +51,6 @@ import org.eclipse.ui.IEditorInput;
/** /**
* A presentation creator based on CDT syntax highlighting. * A presentation creator based on CDT syntax highlighting.
*/ */
@SuppressWarnings("restriction")
public class CSourcePresentationCreator extends PresentationReconciler implements ISourcePresentationCreator, IPropertyChangeListener { public class CSourcePresentationCreator extends PresentationReconciler implements ISourcePresentationCreator, IPropertyChangeListener {
/** /**
@ -245,10 +242,10 @@ public class CSourcePresentationCreator extends PresentationReconciler implement
if (language != null) { if (language != null) {
fViewer= textViewer; fViewer= textViewer;
fPreferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore(); fPreferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
CTextTools textTools = CUIPlugin.getDefault().getTextTools(); final IColorManager colorManager= CDTUITools.getColorManager();
fSourceViewerConfiguration= new CustomCSourceViewerConfiguration(textTools.getColorManager(), fPreferenceStore, language); fSourceViewerConfiguration= new CustomCSourceViewerConfiguration(colorManager, fPreferenceStore, language);
setDocumentPartitioning(fSourceViewerConfiguration.getConfiguredDocumentPartitioning(null)); setDocumentPartitioning(fSourceViewerConfiguration.getConfiguredDocumentPartitioning(null));
initializeDamagerRepairer(storage, textTools.getColorManager(), fPreferenceStore); initializeDamagerRepairer(storage, colorManager, fPreferenceStore);
fPreferenceStore.addPropertyChangeListener(this); fPreferenceStore.addPropertyChangeListener(this);
} }
} }
@ -364,9 +361,9 @@ public class CSourcePresentationCreator extends PresentationReconciler implement
} catch (CModelException e) { } catch (CModelException e) {
} }
} else { } else {
IEditorInput input= EditorUtility.getEditorInputForLocation(storage.getFullPath(), null); IEditorInput input= CDTUITools.getEditorInputForLocation(storage.getFullPath(), null);
if (input instanceof ITranslationUnitEditorInput) { if (input != null) {
tUnit= ((ITranslationUnitEditorInput)input).getTranslationUnit(); tUnit= (ITranslationUnit) input.getAdapter(ITranslationUnit.class);
} }
} }
if (tUnit != null) { if (tUnit != null) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007, 2008 Wind River Systems and others. * Copyright (c) 2007, 2009 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -53,7 +53,6 @@ public final class REDTextStore implements ITextStore {
fText = text; fText = text;
setName("Swapping editor buffer to disk"); //$NON-NLS-1$ setName("Swapping editor buffer to disk"); //$NON-NLS-1$
setPriority(Job.LONG); setPriority(Job.LONG);
// setSystem(true);
} }
@Override @Override
@ -449,7 +448,6 @@ public final class REDTextStore implements ITextStore {
*/ */
private final static class RunSpec { private final static class RunSpec {
public LinkedRun fRun = null; public LinkedRun fRun = null;
public int fOrg = -1;
public int fOff = -1; public int fOff = -1;
public boolean isValid() { public boolean isValid() {
return fRun != null; return fRun != null;
@ -529,7 +527,7 @@ public final class REDTextStore implements ITextStore {
cur = cur.fNext; cur = cur.fNext;
} }
if (pos != 0) { if (pos != 0) {
while (pos - curPos <= 0) { while (pos - curPos <= 0 && cur != null) {
cur = cur.fPrev; cur = cur.fPrev;
curPos -= cur.fLength; curPos -= cur.fLength;
} }
@ -542,7 +540,6 @@ public final class REDTextStore implements ITextStore {
spec = fRunSpec; spec = fRunSpec;
} }
spec.fRun = cur; spec.fRun = cur;
spec.fOrg = curPos;
spec.fOff = pos - curPos; spec.fOff = pos - curPos;
return spec; return spec;