mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Cosmetics.
This commit is contained in:
parent
f3f2671d48
commit
885f6f1b7e
4 changed files with 149 additions and 790 deletions
|
@ -105,9 +105,9 @@ public class ASTProblem extends ASTNode implements IASTProblem {
|
|||
setOffset(startNumber);
|
||||
setLength(endNumber-startNumber);
|
||||
|
||||
this.isError= isError;
|
||||
this.id = id;
|
||||
this.arg = arg;
|
||||
this.isError= isError;
|
||||
}
|
||||
|
||||
public ASTProblem(int id, char[] arg, boolean isError) {
|
||||
|
|
|
@ -120,55 +120,38 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
fArguments= isProblem() ? problem.getArguments() : null;
|
||||
setType(problem instanceof CoreSpellingProblem ?
|
||||
SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
|
||||
if (problem instanceof IPersistableProblem)
|
||||
if (problem instanceof IPersistableProblem) {
|
||||
fMarkerType= ((IPersistableProblem) problem).getMarkerType();
|
||||
else
|
||||
} else {
|
||||
fMarkerType= null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#getArguments()
|
||||
*/
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return fArguments;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#getId()
|
||||
*/
|
||||
@Override
|
||||
public int getId() {
|
||||
return fId;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#isProblem()
|
||||
*/
|
||||
@Override
|
||||
public boolean isProblem() {
|
||||
return fIsProblem;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#hasOverlay()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasOverlay() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#getOverlay()
|
||||
*/
|
||||
@Override
|
||||
public ICAnnotation getOverlay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#addOverlaid(ICAnnotation)
|
||||
*/
|
||||
@Override
|
||||
public void addOverlaid(ICAnnotation annotation) {
|
||||
if (fOverlaids == null)
|
||||
|
@ -176,9 +159,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
fOverlaids.add(annotation);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#removeOverlaid(ICAnnotation)
|
||||
*/
|
||||
@Override
|
||||
public void removeOverlaid(ICAnnotation annotation) {
|
||||
if (fOverlaids != null) {
|
||||
|
@ -188,9 +168,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICAnnotation#getOverlaidIterator()
|
||||
*/
|
||||
@Override
|
||||
public Iterator<ICAnnotation> getOverlaidIterator() {
|
||||
if (fOverlaids != null)
|
||||
|
@ -198,17 +175,11 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getTranslationUnit()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getTranslationUnit() {
|
||||
return fTranslationUnit;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipsecjdt.internal.ui.editor.ICAnnotation#getMarkerType()
|
||||
*/
|
||||
@Override
|
||||
public String getMarkerType() {
|
||||
return fMarkerType;
|
||||
|
@ -235,7 +206,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
|
||||
public Object get(Position position) {
|
||||
|
||||
Entry entry;
|
||||
|
||||
// behind anchor
|
||||
|
@ -300,32 +270,22 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
* A marker updater which removes problems markers with length 0.
|
||||
*/
|
||||
public static class ProblemMarkerUpdater implements IMarkerUpdater {
|
||||
|
||||
/**
|
||||
* Default constructor (executable extension).
|
||||
*/
|
||||
public ProblemMarkerUpdater() {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.texteditor.IMarkerUpdater#getAttribute()
|
||||
*/
|
||||
@Override
|
||||
public String[] getAttribute() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.texteditor.IMarkerUpdater#getMarkerType()
|
||||
*/
|
||||
@Override
|
||||
public String getMarkerType() {
|
||||
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
|
||||
public boolean updateMarker(IMarker marker, IDocument document, Position position) {
|
||||
if (position == null) {
|
||||
|
@ -340,13 +300,14 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
|
||||
/**
|
||||
* 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
|
||||
* activated.
|
||||
* Also acts as a problem requestor for its translation unit. Initially inactive.
|
||||
* 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 {
|
||||
boolean fInsideReportingSequence= false;
|
||||
boolean fInsideReportingSequence;
|
||||
List<IProblem> fReportedProblems;
|
||||
}
|
||||
|
||||
|
@ -356,13 +317,12 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
private ITranslationUnit fTranslationUnit;
|
||||
private List<ProblemAnnotation> fGeneratedAnnotations;
|
||||
private IProgressMonitor fProgressMonitor;
|
||||
private boolean fIsActive= false;
|
||||
private boolean fIsActive;
|
||||
|
||||
private ReverseMap fReverseMap= new ReverseMap();
|
||||
private List<CMarkerAnnotation> fPreviouslyOverlaid= null;
|
||||
private List<CMarkerAnnotation> fPreviouslyOverlaid;
|
||||
private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
|
||||
|
||||
|
||||
public TranslationUnitAnnotationModel(IResource resource) {
|
||||
super(resource);
|
||||
}
|
||||
|
@ -380,10 +340,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
return super.createMarkerAnnotation(marker);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createPositionFromMarker(org.eclipse.core.resources.IMarker)
|
||||
*/
|
||||
@Override
|
||||
protected Position createPositionFromMarker(IMarker marker) {
|
||||
int start= MarkerUtilities.getCharStart(marker);
|
||||
|
@ -420,9 +376,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent()
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected AnnotationModelEvent createAnnotationModelEvent() {
|
||||
return new TranslationUnitAnnotationModelEvent(this, getResource());
|
||||
|
@ -439,9 +393,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
return new Position(start, length);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IProblemRequestor#beginReporting()
|
||||
*/
|
||||
@Override
|
||||
public void beginReporting() {
|
||||
ProblemRequestorState state= fProblemRequestorState.get();
|
||||
|
@ -449,9 +400,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
internalBeginReporting(false);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
|
||||
*/
|
||||
@Override
|
||||
public void beginReportingSequence() {
|
||||
ProblemRequestorState state= fProblemRequestorState.get();
|
||||
|
@ -477,9 +425,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IProblemRequestor#acceptProblem(IProblem)
|
||||
*/
|
||||
@Override
|
||||
public void acceptProblem(IProblem problem) {
|
||||
if (isActive()) {
|
||||
|
@ -489,9 +434,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IProblemRequestor#endReporting()
|
||||
*/
|
||||
@Override
|
||||
public void endReporting() {
|
||||
ProblemRequestorState state= fProblemRequestorState.get();
|
||||
|
@ -499,9 +441,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
internalEndReporting(state);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
|
||||
*/
|
||||
@Override
|
||||
public void endReportingSequence() {
|
||||
ProblemRequestorState state= fProblemRequestorState.get();
|
||||
|
@ -511,8 +450,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
|
||||
private void internalEndReporting(ProblemRequestorState state) {
|
||||
int stateCount= 0;
|
||||
synchronized(getLockObject()) {
|
||||
-- fStateCount;
|
||||
synchronized (getLockObject()) {
|
||||
--fStateCount;
|
||||
stateCount= fStateCount;
|
||||
fProblemRequestorState.set(null);
|
||||
}
|
||||
|
@ -542,19 +481,15 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
fGeneratedAnnotations.clear();
|
||||
}
|
||||
|
||||
if (reportedProblems != null && reportedProblems.size() > 0) {
|
||||
Iterator<IProblem> e= reportedProblems.iterator();
|
||||
while (e.hasNext()) {
|
||||
|
||||
if (reportedProblems != null) {
|
||||
for (IProblem problem : reportedProblems) {
|
||||
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
|
||||
isCanceled= true;
|
||||
break;
|
||||
}
|
||||
|
||||
IProblem problem= e.next();
|
||||
Position position= createPositionFromProblem(problem);
|
||||
if (position != null) {
|
||||
|
||||
try {
|
||||
ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit);
|
||||
overlayMarkers(position, annotation);
|
||||
|
@ -563,7 +498,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
|
||||
temporaryProblemsChanged= true;
|
||||
} catch (BadLocationException x) {
|
||||
// ignore invalid position
|
||||
// Ignore invalid position
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -601,7 +536,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
fPreviouslyOverlaid.remove(annotation);
|
||||
fCurrentlyOverlaid.add(annotation);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -609,8 +543,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
Object value= getAnnotations(position);
|
||||
if (value instanceof List<?>) {
|
||||
List<?> list= (List<?>) value;
|
||||
for (Object element : list)
|
||||
for (Object element : list) {
|
||||
setOverlay(element, problemAnnotation);
|
||||
}
|
||||
} else {
|
||||
setOverlay(value, problemAnnotation);
|
||||
}
|
||||
|
@ -632,25 +567,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
fGeneratedAnnotations= null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IProblemRequestor#isActive()
|
||||
*/
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return fIsActive;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IProblemRequestorExtension#setProgressMonitor(IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public void setProgressMonitor(IProgressMonitor monitor) {
|
||||
fProgressMonitor= monitor;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IProblemRequestorExtension#setIsActive(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setIsActive(boolean isActive) {
|
||||
if (fIsActive != isActive) {
|
||||
|
@ -668,9 +594,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
|
||||
|
@ -692,9 +615,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see AnnotationModel#removeAllAnnotations(boolean)
|
||||
*/
|
||||
@Override
|
||||
protected void removeAllAnnotations(boolean fireModelChanged) {
|
||||
super.removeAllAnnotations(fireModelChanged);
|
||||
|
@ -703,9 +623,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see AnnotationModel#removeAnnotation(Annotation, boolean)
|
||||
*/
|
||||
@Override
|
||||
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
|
||||
Position position= getPosition(annotation);
|
||||
|
@ -727,16 +644,12 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
|
||||
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
|
||||
|
||||
private ListenerList fListenerList;
|
||||
|
||||
public GlobalAnnotationModelListener() {
|
||||
fListenerList= new ListenerList(ListenerList.IDENTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
|
||||
*/
|
||||
@Override
|
||||
public void modelChanged(IAnnotationModel model) {
|
||||
Object[] listeners= fListenerList.getListeners();
|
||||
|
@ -745,9 +658,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
|
||||
*/
|
||||
@Override
|
||||
public void modelChanged(AnnotationModelEvent event) {
|
||||
Object[] listeners= fListenerList.getListeners();
|
||||
|
@ -775,9 +685,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
/** Annotation model listener added to all created CU annotation models */
|
||||
private GlobalAnnotationModelListener fGlobalAnnotationModelListener;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CDocumentProvider() {
|
||||
super();
|
||||
IDocumentProvider parentProvider= new ExternalSearchDocumentProvider();
|
||||
|
@ -794,9 +701,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#connect(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void connect(Object element) throws CoreException {
|
||||
super.connect(element);
|
||||
|
@ -811,8 +715,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
/**
|
||||
* Creates a translation unit from the given file.
|
||||
*
|
||||
* @param file
|
||||
* the file from which to create the translation unit
|
||||
* @param file the file from which to create the translation unit
|
||||
*/
|
||||
protected ITranslationUnit createTranslationUnit(IFile file) {
|
||||
Object element = CoreModel.getDefault().create(file);
|
||||
|
@ -820,7 +723,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
return (ITranslationUnit) element;
|
||||
}
|
||||
if (element == null) {
|
||||
// not in a source folder?
|
||||
// Not in a source folder?
|
||||
ICProject cproject= CoreModel.getDefault().create(file.getProject());
|
||||
if (cproject != null) {
|
||||
String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName());
|
||||
|
@ -832,25 +735,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createEmptyFileInfo()
|
||||
*/
|
||||
@Override
|
||||
protected FileInfo createEmptyFileInfo() {
|
||||
return new TranslationUnitInfo();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createAnnotationModel(org.eclipse.core.resources.IFile)
|
||||
*/
|
||||
@Override
|
||||
protected IAnnotationModel createAnnotationModel(IFile file) {
|
||||
return new TranslationUnitAnnotationModel(file);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
protected FileInfo createFileInfo(Object element) throws CoreException {
|
||||
ITranslationUnit original = 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
|
||||
* @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
|
||||
* @return a translation unit or <code>null</code>
|
||||
*/
|
||||
|
@ -946,10 +840,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disposeFileInfo(java.lang.Object,
|
||||
* org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo)
|
||||
*/
|
||||
@Override
|
||||
protected void disposeFileInfo(Object element, FileInfo info) {
|
||||
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
|
||||
protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document,
|
||||
final boolean overwrite) throws CoreException {
|
||||
final FileInfo info= getFileInfo(element);
|
||||
if (info instanceof TranslationUnitInfo) {
|
||||
return new DocumentProviderOperation() {
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
protected void execute(IProgressMonitor monitor) throws CoreException {
|
||||
commitWorkingCopy(monitor, element, (TranslationUnitInfo) info, overwrite);
|
||||
}
|
||||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ISchedulingRule getSchedulingRule() {
|
||||
if (info.fElement instanceof IFileEditorInput) {
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Anton Leherbauer (Wind River Systems) - Adapted for CDT
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.jface.resource.ColorRegistry;
|
||||
|
@ -26,7 +25,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
|||
* @since 4.0
|
||||
*/
|
||||
public abstract class SemanticHighlighting {
|
||||
|
||||
/**
|
||||
* @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 defaultRGB;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue