1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-17 22:15:23 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-04-17 18:15:00 -07:00
parent f3f2671d48
commit 885f6f1b7e
4 changed files with 149 additions and 790 deletions

View file

@ -105,9 +105,9 @@ public class ASTProblem extends ASTNode implements IASTProblem {
setOffset(startNumber); setOffset(startNumber);
setLength(endNumber-startNumber); setLength(endNumber-startNumber);
this.isError= isError;
this.id = id; this.id = id;
this.arg = arg; this.arg = arg;
this.isError= isError;
} }
public ASTProblem(int id, char[] arg, boolean isError) { public ASTProblem(int id, char[] arg, boolean isError) {

View file

@ -104,7 +104,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/ */
static protected class ProblemAnnotation extends Annotation implements ICAnnotation { static protected class ProblemAnnotation extends Annotation implements ICAnnotation {
private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$ private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$
private final ITranslationUnit fTranslationUnit; private final ITranslationUnit fTranslationUnit;
private final int fId; private final int fId;
private final boolean fIsProblem; private final boolean fIsProblem;
@ -120,65 +120,45 @@ public class CDocumentProvider extends TextFileDocumentProvider {
fArguments= isProblem() ? problem.getArguments() : null; fArguments= isProblem() ? problem.getArguments() : null;
setType(problem instanceof CoreSpellingProblem ? setType(problem instanceof CoreSpellingProblem ?
SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE); SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
if (problem instanceof IPersistableProblem) if (problem instanceof IPersistableProblem) {
fMarkerType= ((IPersistableProblem) problem).getMarkerType(); fMarkerType= ((IPersistableProblem) problem).getMarkerType();
else } else {
fMarkerType= null; fMarkerType= null;
}
} }
/*
* @see ICAnnotation#getArguments()
*/
@Override @Override
public String[] getArguments() { public String[] getArguments() {
return fArguments; return fArguments;
} }
/*
* @see ICAnnotation#getId()
*/
@Override @Override
public int getId() { public int getId() {
return fId; return fId;
} }
/*
* @see ICAnnotation#isProblem()
*/
@Override @Override
public boolean isProblem() { public boolean isProblem() {
return fIsProblem; return fIsProblem;
} }
/*
* @see ICAnnotation#hasOverlay()
*/
@Override @Override
public boolean hasOverlay() { public boolean hasOverlay() {
return false; return false;
} }
/*
* @see ICAnnotation#getOverlay()
*/
@Override @Override
public ICAnnotation getOverlay() { public ICAnnotation getOverlay() {
return null; return null;
} }
/*
* @see ICAnnotation#addOverlaid(ICAnnotation)
*/
@Override @Override
public void addOverlaid(ICAnnotation annotation) { public void addOverlaid(ICAnnotation annotation) {
if (fOverlaids == null) if (fOverlaids == null)
fOverlaids= new ArrayList<ICAnnotation>(1); fOverlaids= new ArrayList<ICAnnotation>(1);
fOverlaids.add(annotation); fOverlaids.add(annotation);
} }
/*
* @see ICAnnotation#removeOverlaid(ICAnnotation)
*/
@Override @Override
public void removeOverlaid(ICAnnotation annotation) { public void removeOverlaid(ICAnnotation annotation) {
if (fOverlaids != null) { if (fOverlaids != null) {
@ -187,34 +167,25 @@ public class CDocumentProvider extends TextFileDocumentProvider {
fOverlaids= null; fOverlaids= null;
} }
} }
/*
* @see ICAnnotation#getOverlaidIterator()
*/
@Override @Override
public Iterator<ICAnnotation> getOverlaidIterator() { public Iterator<ICAnnotation> getOverlaidIterator() {
if (fOverlaids != null) if (fOverlaids != null)
return fOverlaids.iterator(); return fOverlaids.iterator();
return null; return null;
} }
/*
* @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getTranslationUnit()
*/
@Override @Override
public ITranslationUnit getTranslationUnit() { public ITranslationUnit getTranslationUnit() {
return fTranslationUnit; return fTranslationUnit;
} }
/*
* @see org.eclipsecjdt.internal.ui.editor.ICAnnotation#getMarkerType()
*/
@Override @Override
public String getMarkerType() { public String getMarkerType() {
return fMarkerType; return fMarkerType;
} }
} }
/** /**
* Internal structure for mapping positions to some value. * Internal structure for mapping positions to some value.
* The reason for this specific structure is that positions can * The reason for this specific structure is that positions can
@ -222,22 +193,21 @@ public class CDocumentProvider extends TextFileDocumentProvider {
* on hash value. * on hash value.
*/ */
protected static class ReverseMap { protected static class ReverseMap {
static class Entry { static class Entry {
Position fPosition; Position fPosition;
Object fValue; Object fValue;
} }
private List<Entry> fList= new ArrayList<Entry>(2); private List<Entry> fList= new ArrayList<Entry>(2);
private int fAnchor= 0; private int fAnchor= 0;
public ReverseMap() { public ReverseMap() {
} }
public Object get(Position position) { public Object get(Position position) {
Entry entry; Entry entry;
// behind anchor // behind anchor
int length= fList.size(); int length= fList.size();
for (int i= fAnchor; i < length; i++) { for (int i= fAnchor; i < length; i++) {
@ -247,7 +217,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return entry.fValue; return entry.fValue;
} }
} }
// before anchor // before anchor
for (int i= 0; i < fAnchor; i++) { for (int i= 0; i < fAnchor; i++) {
entry= fList.get(i); entry= fList.get(i);
@ -256,10 +226,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return entry.fValue; return entry.fValue;
} }
} }
return null; return null;
} }
private int getIndex(Position position) { private int getIndex(Position position) {
Entry entry; Entry entry;
int length= fList.size(); int length= fList.size();
@ -270,7 +240,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
return -1; return -1;
} }
public void put(Position position, Object value) { public void put(Position position, Object value) {
int index= getIndex(position); int index= getIndex(position);
if (index == -1) { if (index == -1) {
@ -283,13 +253,13 @@ public class CDocumentProvider extends TextFileDocumentProvider {
entry.fValue= value; entry.fValue= value;
} }
} }
public void remove(Position position) { public void remove(Position position) {
int index= getIndex(position); int index= getIndex(position);
if (index > -1) if (index > -1)
fList.remove(index); fList.remove(index);
} }
public void clear() { public void clear() {
fList.clear(); fList.clear();
fAnchor= 0; fAnchor= 0;
@ -300,32 +270,22 @@ public class CDocumentProvider extends TextFileDocumentProvider {
* A marker updater which removes problems markers with length 0. * A marker updater which removes problems markers with length 0.
*/ */
public static class ProblemMarkerUpdater implements IMarkerUpdater { public static class ProblemMarkerUpdater implements IMarkerUpdater {
/** /**
* Default constructor (executable extension). * Default constructor (executable extension).
*/ */
public ProblemMarkerUpdater() { public ProblemMarkerUpdater() {
} }
/*
* @see org.eclipse.ui.texteditor.IMarkerUpdater#getAttribute()
*/
@Override @Override
public String[] getAttribute() { public String[] getAttribute() {
return null; return null;
} }
/*
* @see org.eclipse.ui.texteditor.IMarkerUpdater#getMarkerType()
*/
@Override @Override
public String getMarkerType() { public String getMarkerType() {
return ICModelMarker.C_MODEL_PROBLEM_MARKER; return ICModelMarker.C_MODEL_PROBLEM_MARKER;
} }
/*
* @see org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core.resources.IMarker, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position)
*/
@Override @Override
public boolean updateMarker(IMarker marker, IDocument document, Position position) { public boolean updateMarker(IMarker marker, IDocument document, Position position) {
if (position == null) { if (position == null) {
@ -340,37 +300,37 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** /**
* Annotation model dealing with c marker annotations and temporary problems. * Annotation model dealing with c marker annotations and temporary problems.
* Also acts as a problem requestor for its translation unit. Initially inactive. Must be explicitly * Also acts as a problem requestor for its translation unit. Initially inactive.
* activated. * Must be explicitly activated.
*/ */
protected static class TranslationUnitAnnotationModel extends ResourceMarkerAnnotationModel implements IProblemRequestor, IProblemRequestorExtension { protected static class TranslationUnitAnnotationModel extends ResourceMarkerAnnotationModel
implements IProblemRequestor, IProblemRequestorExtension {
private static class ProblemRequestorState { private static class ProblemRequestorState {
boolean fInsideReportingSequence= false; boolean fInsideReportingSequence;
List<IProblem> fReportedProblems; List<IProblem> fReportedProblems;
} }
private ThreadLocal<ProblemRequestorState> fProblemRequestorState= new ThreadLocal<ProblemRequestorState>(); private ThreadLocal<ProblemRequestorState> fProblemRequestorState= new ThreadLocal<ProblemRequestorState>();
private int fStateCount= 0; private int fStateCount= 0;
private ITranslationUnit fTranslationUnit; private ITranslationUnit fTranslationUnit;
private List<ProblemAnnotation> fGeneratedAnnotations; private List<ProblemAnnotation> fGeneratedAnnotations;
private IProgressMonitor fProgressMonitor; private IProgressMonitor fProgressMonitor;
private boolean fIsActive= false; private boolean fIsActive;
private ReverseMap fReverseMap= new ReverseMap(); private ReverseMap fReverseMap= new ReverseMap();
private List<CMarkerAnnotation> fPreviouslyOverlaid= null; private List<CMarkerAnnotation> fPreviouslyOverlaid;
private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>(); private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
public TranslationUnitAnnotationModel(IResource resource) { public TranslationUnitAnnotationModel(IResource resource) {
super(resource); super(resource);
} }
public void setTranslationUnit(ITranslationUnit unit) { public void setTranslationUnit(ITranslationUnit unit) {
fTranslationUnit= unit; fTranslationUnit= unit;
} }
@Override @Override
protected MarkerAnnotation createMarkerAnnotation(IMarker marker) { protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
String markerType= MarkerUtilities.getMarkerType(marker); String markerType= MarkerUtilities.getMarkerType(marker);
@ -379,22 +339,18 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
return super.createMarkerAnnotation(marker); return super.createMarkerAnnotation(marker);
} }
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createPositionFromMarker(org.eclipse.core.resources.IMarker)
*/
@Override @Override
protected Position createPositionFromMarker(IMarker marker) { protected Position createPositionFromMarker(IMarker marker) {
int start= MarkerUtilities.getCharStart(marker); int start= MarkerUtilities.getCharStart(marker);
int end= MarkerUtilities.getCharEnd(marker); int end= MarkerUtilities.getCharEnd(marker);
if (start > end) { if (start > end) {
end= start + end; end= start + end;
start= end - start; start= end - start;
end= end - start; end= end - start;
} }
if (start == -1 && end == -1) { if (start == -1 && end == -1) {
// marker line number is 1-based // marker line number is 1-based
int line= MarkerUtilities.getLineNumber(marker); int line= MarkerUtilities.getLineNumber(marker);
@ -414,56 +370,48 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
} }
if (start > -1 && end > -1) if (start > -1 && end > -1)
return new Position(start, end - start); return new Position(start, end - start);
return null; return null;
} }
/*
* @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent()
*/
@Override @Override
protected AnnotationModelEvent createAnnotationModelEvent() { protected AnnotationModelEvent createAnnotationModelEvent() {
return new TranslationUnitAnnotationModelEvent(this, getResource()); return new TranslationUnitAnnotationModelEvent(this, getResource());
} }
protected Position createPositionFromProblem(IProblem problem) { protected Position createPositionFromProblem(IProblem problem) {
int start= problem.getSourceStart(); int start= problem.getSourceStart();
if (start < 0) if (start < 0)
return null; return null;
int length= problem.getSourceEnd() - problem.getSourceStart() + 1; int length= problem.getSourceEnd() - problem.getSourceStart() + 1;
if (length < 0) if (length < 0)
return null; return null;
return new Position(start, length); return new Position(start, length);
} }
/*
* @see IProblemRequestor#beginReporting()
*/
@Override @Override
public void beginReporting() { public void beginReporting() {
ProblemRequestorState state= fProblemRequestorState.get(); ProblemRequestorState state= fProblemRequestorState.get();
if (state == null) if (state == null)
internalBeginReporting(false); internalBeginReporting(false);
} }
/*
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
*/
@Override @Override
public void beginReportingSequence() { public void beginReportingSequence() {
ProblemRequestorState state= fProblemRequestorState.get(); ProblemRequestorState state= fProblemRequestorState.get();
if (state == null) if (state == null)
internalBeginReporting(true); internalBeginReporting(true);
} }
/** /**
* Sets up the infrastructure necessary for problem reporting. * Sets up the infrastructure necessary for problem reporting.
* *
* @param insideReportingSequence <code>true</code> if this method * @param insideReportingSequence <code>true</code> if this method
* call is issued from inside a reporting sequence * call is issued from inside a reporting sequence
*/ */
private void internalBeginReporting(boolean insideReportingSequence) { private void internalBeginReporting(boolean insideReportingSequence) {
if (fTranslationUnit != null) { if (fTranslationUnit != null) {
@ -476,10 +424,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
} }
/*
* @see IProblemRequestor#acceptProblem(IProblem)
*/
@Override @Override
public void acceptProblem(IProblem problem) { public void acceptProblem(IProblem problem) {
if (isActive()) { if (isActive()) {
@ -488,95 +433,85 @@ public class CDocumentProvider extends TextFileDocumentProvider {
state.fReportedProblems.add(problem); state.fReportedProblems.add(problem);
} }
} }
/*
* @see IProblemRequestor#endReporting()
*/
@Override @Override
public void endReporting() { public void endReporting() {
ProblemRequestorState state= fProblemRequestorState.get(); ProblemRequestorState state= fProblemRequestorState.get();
if (state != null && !state.fInsideReportingSequence) if (state != null && !state.fInsideReportingSequence)
internalEndReporting(state); internalEndReporting(state);
} }
/*
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
*/
@Override @Override
public void endReportingSequence() { public void endReportingSequence() {
ProblemRequestorState state= fProblemRequestorState.get(); ProblemRequestorState state= fProblemRequestorState.get();
if (state != null && state.fInsideReportingSequence) if (state != null && state.fInsideReportingSequence)
internalEndReporting(state); internalEndReporting(state);
} }
private void internalEndReporting(ProblemRequestorState state) { private void internalEndReporting(ProblemRequestorState state) {
int stateCount= 0; int stateCount= 0;
synchronized(getLockObject()) { synchronized (getLockObject()) {
-- fStateCount; --fStateCount;
stateCount= fStateCount; stateCount= fStateCount;
fProblemRequestorState.set(null); fProblemRequestorState.set(null);
} }
if (stateCount == 0 && isActive()) if (stateCount == 0 && isActive())
reportProblems(state.fReportedProblems); reportProblems(state.fReportedProblems);
} }
/** /**
* Signals the end of problem reporting. * Signals the end of problem reporting.
*/ */
private void reportProblems(List<IProblem> reportedProblems) { private void reportProblems(List<IProblem> reportedProblems) {
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) if (fProgressMonitor != null && fProgressMonitor.isCanceled())
return; return;
boolean temporaryProblemsChanged= false; boolean temporaryProblemsChanged= false;
synchronized (getLockObject()) { synchronized (getLockObject()) {
boolean isCanceled= false; boolean isCanceled= false;
fPreviouslyOverlaid= fCurrentlyOverlaid; fPreviouslyOverlaid= fCurrentlyOverlaid;
fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>(); fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
if (fGeneratedAnnotations.size() > 0) { if (fGeneratedAnnotations.size() > 0) {
temporaryProblemsChanged= true; temporaryProblemsChanged= true;
removeAnnotations(fGeneratedAnnotations, false, true); removeAnnotations(fGeneratedAnnotations, false, true);
fGeneratedAnnotations.clear(); fGeneratedAnnotations.clear();
} }
if (reportedProblems != null && reportedProblems.size() > 0) { if (reportedProblems != null) {
Iterator<IProblem> e= reportedProblems.iterator(); for (IProblem problem : reportedProblems) {
while (e.hasNext()) {
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) { if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
isCanceled= true; isCanceled= true;
break; break;
} }
IProblem problem= e.next();
Position position= createPositionFromProblem(problem); Position position= createPositionFromProblem(problem);
if (position != null) { if (position != null) {
try { try {
ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit); ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit);
overlayMarkers(position, annotation); overlayMarkers(position, annotation);
addAnnotation(annotation, position, false); addAnnotation(annotation, position, false);
fGeneratedAnnotations.add(annotation); fGeneratedAnnotations.add(annotation);
temporaryProblemsChanged= true; temporaryProblemsChanged= true;
} catch (BadLocationException x) { } catch (BadLocationException x) {
// ignore invalid position // Ignore invalid position
} }
} }
} }
} }
removeMarkerOverlays(isCanceled); removeMarkerOverlays(isCanceled);
fPreviouslyOverlaid= null; fPreviouslyOverlaid= null;
} }
if (temporaryProblemsChanged) if (temporaryProblemsChanged)
fireModelChanged(); fireModelChanged();
} }
private void removeMarkerOverlays(boolean isCanceled) { private void removeMarkerOverlays(boolean isCanceled) {
if (isCanceled) { if (isCanceled) {
fCurrentlyOverlaid.addAll(fPreviouslyOverlaid); fCurrentlyOverlaid.addAll(fPreviouslyOverlaid);
@ -588,7 +523,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
} }
/** /**
* Overlays value with problem annotation. * Overlays value with problem annotation.
* @param problemAnnotation * @param problemAnnotation
@ -601,28 +536,28 @@ public class CDocumentProvider extends TextFileDocumentProvider {
fPreviouslyOverlaid.remove(annotation); fPreviouslyOverlaid.remove(annotation);
fCurrentlyOverlaid.add(annotation); fCurrentlyOverlaid.add(annotation);
} }
} else {
} }
} }
private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) { private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
Object value= getAnnotations(position); Object value= getAnnotations(position);
if (value instanceof List<?>) { if (value instanceof List<?>) {
List<?> list= (List<?>) value; List<?> list= (List<?>) value;
for (Object element : list) for (Object element : list) {
setOverlay(element, problemAnnotation); setOverlay(element, problemAnnotation);
}
} else { } else {
setOverlay(value, problemAnnotation); setOverlay(value, problemAnnotation);
} }
} }
/** /**
* Tells this annotation model to collect temporary problems from now on. * Tells this annotation model to collect temporary problems from now on.
*/ */
private void startCollectingProblems() { private void startCollectingProblems() {
fGeneratedAnnotations= new ArrayList<ProblemAnnotation>(); fGeneratedAnnotations= new ArrayList<ProblemAnnotation>();
} }
/** /**
* Tells this annotation model to no longer collect temporary problems. * Tells this annotation model to no longer collect temporary problems.
*/ */
@ -631,26 +566,17 @@ public class CDocumentProvider extends TextFileDocumentProvider {
removeAnnotations(fGeneratedAnnotations, true, true); removeAnnotations(fGeneratedAnnotations, true, true);
fGeneratedAnnotations= null; fGeneratedAnnotations= null;
} }
/*
* @see IProblemRequestor#isActive()
*/
@Override @Override
public boolean isActive() { public boolean isActive() {
return fIsActive; return fIsActive;
} }
/*
* @see IProblemRequestorExtension#setProgressMonitor(IProgressMonitor)
*/
@Override @Override
public void setProgressMonitor(IProgressMonitor monitor) { public void setProgressMonitor(IProgressMonitor monitor) {
fProgressMonitor= monitor; fProgressMonitor= monitor;
} }
/*
* @see IProblemRequestorExtension#setIsActive(boolean)
*/
@Override @Override
public void setIsActive(boolean isActive) { public void setIsActive(boolean isActive) {
if (fIsActive != isActive) { if (fIsActive != isActive) {
@ -661,21 +587,18 @@ public class CDocumentProvider extends TextFileDocumentProvider {
stopCollectingProblems(); stopCollectingProblems();
} }
} }
private Object getAnnotations(Position position) { private Object getAnnotations(Position position) {
synchronized (getLockObject()) { synchronized (getLockObject()) {
return fReverseMap.get(position); return fReverseMap.get(position);
} }
} }
/*
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
*/
@Override @Override
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException { protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
super.addAnnotation(annotation, position, fireModelChanged); super.addAnnotation(annotation, position, fireModelChanged);
synchronized (getLockObject()) { synchronized (getLockObject()) {
Object cached= fReverseMap.get(position); Object cached= fReverseMap.get(position);
if (cached == null) { if (cached == null) {
@ -691,10 +614,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
} }
/*
* @see AnnotationModel#removeAllAnnotations(boolean)
*/
@Override @Override
protected void removeAllAnnotations(boolean fireModelChanged) { protected void removeAllAnnotations(boolean fireModelChanged) {
super.removeAllAnnotations(fireModelChanged); super.removeAllAnnotations(fireModelChanged);
@ -702,10 +622,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
fReverseMap.clear(); fReverseMap.clear();
} }
} }
/*
* @see AnnotationModel#removeAnnotation(Annotation, boolean)
*/
@Override @Override
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) { protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
Position position= getPosition(annotation); Position position= getPosition(annotation);
@ -727,16 +644,12 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension { protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
private ListenerList fListenerList; private ListenerList fListenerList;
public GlobalAnnotationModelListener() { public GlobalAnnotationModelListener() {
fListenerList= new ListenerList(ListenerList.IDENTITY); fListenerList= new ListenerList(ListenerList.IDENTITY);
} }
/**
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
*/
@Override @Override
public void modelChanged(IAnnotationModel model) { public void modelChanged(IAnnotationModel model) {
Object[] listeners= fListenerList.getListeners(); Object[] listeners= fListenerList.getListeners();
@ -745,9 +658,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
/**
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
*/
@Override @Override
public void modelChanged(AnnotationModelEvent event) { public void modelChanged(AnnotationModelEvent event) {
Object[] listeners= fListenerList.getListeners(); Object[] listeners= fListenerList.getListeners();
@ -757,16 +667,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
} }
public void addListener(IAnnotationModelListener listener) { public void addListener(IAnnotationModelListener listener) {
fListenerList.add(listener); fListenerList.add(listener);
} }
public void removeListener(IAnnotationModelListener listener) { public void removeListener(IAnnotationModelListener listener) {
fListenerList.remove(listener); fListenerList.remove(listener);
} }
} }
/** Preference key for temporary problems */ /** Preference key for temporary problems */
private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS; private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
@ -775,9 +685,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** Annotation model listener added to all created CU annotation models */ /** Annotation model listener added to all created CU annotation models */
private GlobalAnnotationModelListener fGlobalAnnotationModelListener; private GlobalAnnotationModelListener fGlobalAnnotationModelListener;
/**
*
*/
public CDocumentProvider() { public CDocumentProvider() {
super(); super();
IDocumentProvider parentProvider= new ExternalSearchDocumentProvider(); IDocumentProvider parentProvider= new ExternalSearchDocumentProvider();
@ -794,9 +701,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener); CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener);
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#connect(java.lang.Object)
*/
@Override @Override
public void connect(Object element) throws CoreException { public void connect(Object element) throws CoreException {
super.connect(element); super.connect(element);
@ -810,9 +714,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** /**
* Creates a translation unit from the given file. * Creates a translation unit from the given file.
* *
* @param file * @param file the file from which to create the translation unit
* the file from which to create the translation unit
*/ */
protected ITranslationUnit createTranslationUnit(IFile file) { protected ITranslationUnit createTranslationUnit(IFile file) {
Object element = CoreModel.getDefault().create(file); Object element = CoreModel.getDefault().create(file);
@ -820,7 +723,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return (ITranslationUnit) element; return (ITranslationUnit) element;
} }
if (element == null) { if (element == null) {
// not in a source folder? // Not in a source folder?
ICProject cproject= CoreModel.getDefault().create(file.getProject()); ICProject cproject= CoreModel.getDefault().create(file.getProject());
if (cproject != null) { if (cproject != null) {
String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName()); String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName());
@ -832,25 +735,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return null; return null;
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createEmptyFileInfo()
*/
@Override @Override
protected FileInfo createEmptyFileInfo() { protected FileInfo createEmptyFileInfo() {
return new TranslationUnitInfo(); return new TranslationUnitInfo();
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createAnnotationModel(org.eclipse.core.resources.IFile)
*/
@Override @Override
protected IAnnotationModel createAnnotationModel(IFile file) { protected IAnnotationModel createAnnotationModel(IFile file) {
return new TranslationUnitAnnotationModel(file); return new TranslationUnitAnnotationModel(file);
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object)
*/
@Override @Override
protected FileInfo createFileInfo(Object element) throws CoreException { protected FileInfo createFileInfo(Object element) throws CoreException {
ITranslationUnit original = null; ITranslationUnit original = null;
@ -876,7 +770,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
if (original == null) { if (original == null) {
return null; return null;
} }
FileInfo info = super.createFileInfo(element); FileInfo info = super.createFileInfo(element);
if (!(info instanceof TranslationUnitInfo)) if (!(info instanceof TranslationUnitInfo))
return null; return null;
@ -915,7 +809,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
/** /**
* Try to synthesize an ITranslationUnit out of thin air. * Tries to synthesize an ITranslationUnit out of thin air.
* @param location the file system location of the file in question * @param location the file system location of the file in question
* @return a translation unit or <code>null</code> * @return a translation unit or <code>null</code>
*/ */
@ -931,7 +825,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
/** /**
* Try to synthesize an ITranslationUnit out of thin air. * Tries to synthesize an ITranslationUnit out of thin air.
* @param uri the URU of the file in question * @param uri the URU of the file in question
* @return a translation unit or <code>null</code> * @return a translation unit or <code>null</code>
*/ */
@ -946,10 +840,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return null; return null;
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disposeFileInfo(java.lang.Object,
* org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo)
*/
@Override @Override
protected void disposeFileInfo(Object element, FileInfo info) { protected void disposeFileInfo(Object element, FileInfo info) {
if (info instanceof TranslationUnitInfo) { if (info instanceof TranslationUnitInfo) {
@ -1020,25 +910,17 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createSaveOperation(java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
*/
@Override @Override
protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document,
final boolean overwrite) throws CoreException { final boolean overwrite) throws CoreException {
final FileInfo info= getFileInfo(element); final FileInfo info= getFileInfo(element);
if (info instanceof TranslationUnitInfo) { if (info instanceof TranslationUnitInfo) {
return new DocumentProviderOperation() { return new DocumentProviderOperation() {
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
protected void execute(IProgressMonitor monitor) throws CoreException { protected void execute(IProgressMonitor monitor) throws CoreException {
commitWorkingCopy(monitor, element, (TranslationUnitInfo) info, overwrite); commitWorkingCopy(monitor, element, (TranslationUnitInfo) info, overwrite);
} }
/*
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
*/
@Override @Override
public ISchedulingRule getSchedulingRule() { public ISchedulingRule getSchedulingRule() {
if (info.fElement instanceof IFileEditorInput) { if (info.fElement instanceof IFileEditorInput) {
@ -1055,7 +937,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** /**
* Removes trailing whitespaces from changed lines and adds newline at the end of the file, * Removes trailing whitespaces from changed lines and adds newline at the end of the file,
* if the last line of the file was changed. * if the last line of the file was changed.
* @throws BadLocationException * @throws BadLocationException
*/ */
private void performSaveActions(ITextFileBuffer buffer, IProgressMonitor monitor) throws CoreException { private void performSaveActions(ITextFileBuffer buffer, IProgressMonitor monitor) throws CoreException {
if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof()) { if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof()) {
@ -1099,7 +981,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return PreferenceConstants.getPreferenceStore().getBoolean( return PreferenceConstants.getPreferenceStore().getBoolean(
PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES); PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES);
} }
private static boolean needsChangedRegions() { private static boolean needsChangedRegions() {
return shouldRemoveTrailingWhitespace() && isLimitedRemoveTrailingWhitespace(); return shouldRemoveTrailingWhitespace() && isLimitedRemoveTrailingWhitespace();
} }
@ -1182,7 +1064,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
// } // }
// return true; // return true;
// } // }
/** /**
* Returns the preference whether handling temporary problems is enabled. * Returns the preference whether handling temporary problems is enabled.
*/ */
@ -1190,7 +1072,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS); return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS);
} }
/** /**
* Switches the state of problem acceptance according to the value in the preference store. * Switches the state of problem acceptance according to the value in the preference store.
*/ */

View file

@ -10,7 +10,6 @@
* Anton Leherbauer (Wind River Systems) - Adapted for CDT * Anton Leherbauer (Wind River Systems) - Adapted for CDT
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.jface.resource.ColorRegistry;
@ -26,7 +25,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
* @since 4.0 * @since 4.0
*/ */
public abstract class SemanticHighlighting { public abstract class SemanticHighlighting {
/** /**
* @return the preference key, will be augmented by a prefix and a suffix for each preference * @return the preference key, will be augmented by a prefix and a suffix for each preference
*/ */
@ -126,5 +124,4 @@ public abstract class SemanticHighlighting {
return rgb; return rgb;
return defaultRGB; return defaultRGB;
} }
} }