1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 01:35:39 +02:00

Fix compiler warnings in packages dnd, editor, navigator, text

This commit is contained in:
Anton Leherbauer 2006-07-06 14:52:55 +00:00
parent af6000c0e0
commit fa69bd28e9
42 changed files with 278 additions and 1011 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2005 QNX Software Systems and others. * Copyright (c) 2002, 2006 QNX Software 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
@ -11,7 +11,7 @@
package org.eclipse.cdt.internal.ui.dnd; package org.eclipse.cdt.internal.ui.dnd;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.util.Assert; import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.SafeRunnable; import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DND;
@ -79,7 +79,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
// operation change. otherwise the new listener would get a dragEnter // operation change. otherwise the new listener would get a dragEnter
// followed by a dragOperationChanged with the exact same event. // followed by a dragOperationChanged with the exact same event.
if (newListener != null && newListener == oldListener) { if (newListener != null && newListener == oldListener) {
Platform.run(new SafeRunnable() { SafeRunner.run(new SafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
newListener.dragOperationChanged(event); newListener.dragOperationChanged(event);
} }
@ -105,7 +105,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
// drag over. otherwise the new listener would get a dragEnter // drag over. otherwise the new listener would get a dragEnter
// followed by a dragOver with the exact same event. // followed by a dragOver with the exact same event.
if (newListener != null && newListener == oldListener) { if (newListener != null && newListener == oldListener) {
Platform.run(new SafeRunnable() { SafeRunner.run(new SafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
newListener.dragOver(event); newListener.dragOver(event);
} }
@ -123,7 +123,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
public void drop(final DropTargetEvent event) { public void drop(final DropTargetEvent event) {
updateCurrentListener(event); updateCurrentListener(event);
if (getCurrentListener() != null) { if (getCurrentListener() != null) {
Platform.run(new SafeRunnable() { SafeRunner.run(new SafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
getCurrentListener().drop(event); getCurrentListener().drop(event);
} }
@ -140,7 +140,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
*/ */
public void dropAccept(final DropTargetEvent event) { public void dropAccept(final DropTargetEvent event) {
if (getCurrentListener() != null) { if (getCurrentListener() != null) {
Platform.run(new SafeRunnable() { SafeRunner.run(new SafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
getCurrentListener().dropAccept(event); getCurrentListener().dropAccept(event);
} }
@ -203,7 +203,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
if (fCurrentListener == listener) if (fCurrentListener == listener)
return false; return false;
if (fCurrentListener != null) { if (fCurrentListener != null) {
Platform.run(new SafeRunnable() { SafeRunner.run(new SafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
fCurrentListener.dragLeave(event); fCurrentListener.dragLeave(event);
} }
@ -211,7 +211,7 @@ public class DelegatingDropAdapter implements DropTargetListener {
} }
fCurrentListener= listener; fCurrentListener= listener;
if (fCurrentListener != null) { if (fCurrentListener != null) {
Platform.run(new SafeRunnable() { SafeRunner.run(new SafeRunnable() {
public void run() throws Exception { public void run() throws Exception {
fCurrentListener.dragEnter(event); fCurrentListener.dragEnter(event);
} }

View file

@ -128,8 +128,6 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
* Extract the includes for the given selection. This can be both used to perform * Extract the includes for the given selection. This can be both used to perform
* the work as well as being invoked when there is a change. The actual results * the work as well as being invoked when there is a change. The actual results
* can and should be cached as the lookup process could be potentially costly. * can and should be cached as the lookup process could be potentially costly.
*
* @return IRequiredInclude [] An array of the required includes, or null if this action is invalid.
*/ */
private void extractIncludes(ITextEditor editor) { private void extractIncludes(ITextEditor editor) {
if (editor == null) { if (editor == null) {

View file

@ -155,9 +155,9 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
} }
/** /**
* Returns the CEditor corresponding to this CContentOutlinePage. * Provide access to the CEditor corresponding to this CContentOutlinePage.
* @param return * @returns the CEditor corresponding to this CContentOutlinePage.
*/ */
public CEditor getEditor() { public CEditor getEditor() {
return fEditor; return fEditor;
} }
@ -364,7 +364,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
/** /**
* Fires a selection changed event. * Fires a selection changed event.
* *
* @param selction the new selection * @param selection the new selection
*/ */
protected void fireSelectionChanged(ISelection selection) { protected void fireSelectionChanged(ISelection selection) {
// create an event // create an event

View file

@ -126,11 +126,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
* Called after CEditor contents is changed. * Called after CEditor contents is changed.
* Existing elements can change their offset and length. * Existing elements can change their offset and length.
* *
* @param offset * @param sdata delta information
* position where source was changed
* @param size
* length of ins
* ertion (negaive for deletion)
*/ */
public void contentShift(CShiftData sdata) { public void contentShift(CShiftData sdata) {
try { try {

View file

@ -15,17 +15,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IProblemRequestor;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -55,7 +44,6 @@ import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextFileDocumentProvider; import org.eclipse.ui.editors.text.TextFileDocumentProvider;
@ -65,6 +53,20 @@ import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel; import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IProblemRequestor;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.ui.CFileElementWorkingCopy;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
/** /**
* CDocumentProvider2 * CDocumentProvider2
*/ */
@ -162,7 +164,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private void initializeImages() { private void initializeImages() {
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=18936 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=18936
if (!fQuickFixImagesInitialized) { if (!fQuickFixImagesInitialized) {
if (isProblem() && indicateQuixFixableProblems() /*&& JavaCorrectionProcessor.hasCorrections(this)*/) { // no light bulb for tasks if (isProblem() && indicateQuixFixableProblems()) { // no light bulb for tasks
if (!fgQuickFixImagesInitialized) { if (!fgQuickFixImagesInitialized) {
fgQuickFixImage= CPluginImages.get(CPluginImages.IMG_OBJS_FIXABLE_PROBLEM); fgQuickFixImage= CPluginImages.get(CPluginImages.IMG_OBJS_FIXABLE_PROBLEM);
fgQuickFixErrorImage= CPluginImages.get(CPluginImages.IMG_OBJS_FIXABLE_ERROR); fgQuickFixErrorImage= CPluginImages.get(CPluginImages.IMG_OBJS_FIXABLE_ERROR);
@ -180,9 +182,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private boolean indicateQuixFixableProblems() { private boolean indicateQuixFixableProblems() {
return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION); return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
} }
/* /*
* @see Annotation#paint * @see org.eclipse.jface.text.source.IAnnotationPresentation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
*/ */
public void paint(GC gc, Canvas canvas, Rectangle r) { public void paint(GC gc, Canvas canvas, Rectangle r) {
initializeImages(); initializeImages();
@ -191,14 +193,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} }
/*
* @see ICAnnotation#getImage(Display)
*/
public Image getImage(Display display) {
initializeImages();
return fImage;
}
/* /*
* @see ICAnnotation#getMessage() * @see ICAnnotation#getMessage()
*/ */
@ -766,8 +760,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** 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;
/** Indicates whether the save has been initialized by this provider */
private boolean fIsAboutToSave = false;
/** Internal property changed listener */ /** Internal property changed listener */
private IPropertyChangeListener fPropertyListener; private IPropertyChangeListener fPropertyListener;
/** Annotation model listener added to all created CU annotation models */ /** Annotation model listener added to all created CU annotation models */
@ -903,7 +895,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
// fSavePolicy.preSave(info.fCopy); // fSavePolicy.preSave(info.fCopy);
try { try {
fIsAboutToSave = true;
//info.fCopy.commit(overwrite, monitor); //info.fCopy.commit(overwrite, monitor);
commitFileBuffer(monitor, info, overwrite); commitFileBuffer(monitor, info, overwrite);
} catch (CoreException x) { } catch (CoreException x) {
@ -915,7 +906,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
fireElementStateChangeFailed(element); fireElementStateChangeFailed(element);
throw x; throw x;
} finally { } finally {
fIsAboutToSave = false;
} }
// If here, the dirty state of the editor will change to "not dirty". // If here, the dirty state of the editor will change to "not dirty".
@ -1021,7 +1011,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** /**
* Returns the underlying resource for the given element. * Returns the underlying resource for the given element.
* *
* @param the element * @param element the element
* @return the underlying resource of the given element * @return the underlying resource of the given element
*/ */
public IResource getUnderlyingResource(Object element) { public IResource getUnderlyingResource(Object element) {
@ -1032,20 +1022,6 @@ public class CDocumentProvider extends TextFileDocumentProvider {
return null; return null;
} }
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#saveDocumentContent(org.eclipse.core.runtime.IProgressMonitor,
* java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
*/
public void saveDocumentContent(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
throws CoreException {
if (!fIsAboutToSave)
return;
super.saveDocument(monitor, element, document, overwrite);
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.ICompilationUnitDocumentProvider#createLineTracker(java.lang.Object)
*/
public ILineTracker createLineTracker(Object element) { public ILineTracker createLineTracker(Object element) {
return new DefaultLineTracker(); return new DefaultLineTracker();
} }

View file

@ -8,50 +8,16 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QNX Software System * QNX Software System
* Anton Leherbauer, Wind River Systems, Inc. * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.JoinLinesAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.cdt.internal.ui.util.CUIHelp;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.actions.ShowInCViewAction;
import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
@ -86,7 +52,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.search.ui.actions.TextSearchGroup; import org.eclipse.search.ui.actions.TextSearchGroup;
import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DND;
@ -104,30 +69,57 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPartService; import org.eclipse.ui.IPartService;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.part.EditorActionBarContributor; import org.eclipse.ui.part.EditorActionBarContributor;
import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTargetList; import org.eclipse.ui.part.IShowInTargetList;
import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.part.ShowInContext;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.ContentAssistAction; import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
import org.eclipse.ui.texteditor.ITextEditorDropTargetListener; import org.eclipse.ui.texteditor.ITextEditorDropTargetListener;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.actions.ShowInCViewAction;
import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.JoinLinesAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter;
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
import org.eclipse.cdt.internal.ui.util.CUIHelp;
/** /**
* C specific text editor. * C specific text editor.
@ -206,21 +198,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
/** /**
* The action group for folding. * The action group for folding.
*
*/ */
private FoldingActionGroup fFoldingGroup; private FoldingActionGroup fFoldingGroup;
/**
* Indicates whether this editor is about to update any annotation views.
* @since 3.0
*/
private boolean fIsUpdatingAnnotationViews= false;
/**
* The marker that served as last target for a goto marker request.
* @since 3.0
*/
private IMarker fLastMarkerTarget= null;
/** /**
* Default constructor. * Default constructor.
*/ */
@ -868,43 +848,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
dragSource.addDragListener(dragSourceListener); dragSource.addDragListener(dragSourceListener);
} }
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#gotoMarker(org.eclipse.core.resources.IMarker)
*/
public void gotoMarker(IMarker marker) {
fLastMarkerTarget= marker;
if (!fIsUpdatingAnnotationViews) {
super.gotoMarker(marker);
}
}
/**
* Jumps to the next enabled annotation according to the given direction.
* An annotation type is enabled if it is configured to be in the
* Next/Previous tool bar drop down menu and if it is checked.
*
* @param forward <code>true</code> if search direction is forward, <code>false</code> if backward
*/
public Annotation gotoAnnotation(boolean forward) {
Annotation annotation = null;
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Position position= new Position(0, 0);
if (false /* delayed - see bug 18316 */) {
getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
selectAndReveal(position.getOffset(), position.getLength());
} else /* no delay - see bug 18316 */ {
annotation= getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
updateAnnotationViews(annotation);
selectAndReveal(position.getOffset(), position.getLength());
setStatusLineMessage(annotation.getText());
}
}
return annotation;
}
/** /**
* Jumps to the matching bracket. * Jumps to the matching bracket.
*/ */
@ -969,161 +912,18 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
sourceViewer.revealRange(targetOffset, selection.getLength()); sourceViewer.revealRange(targetOffset, selection.getLength());
} }
/**
* Returns whether the given annotation is configured as a target for the
* "Go to Next/Previous Annotation" actions
*
* @param annotation the annotation
* @return <code>true</code> if this is a target, <code>false</code>
* otherwise
* @since 3.0
*/
protected boolean isNavigationTarget(Annotation annotation) {
Preferences preferences= EditorsUI.getPluginPreferences();
AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
// See bug 41689
// String key= forward ? preference.getIsGoToNextNavigationTargetKey() : preference.getIsGoToPreviousNavigationTargetKey();
String key= preference == null ? null : preference.getIsGoToNextNavigationTargetKey();
return (key != null && preferences.getBoolean(key));
}
/**
* Returns the annotation closest to the given range respecting the given
* direction. If an annotation is found, the annotations current position
* is copied into the provided annotation position.
*
* @param offset the region offset
* @param length the region length
* @param forward <code>true</code> for forwards, <code>false</code> for backward
* @param annotationPosition the position of the found annotation
* @return the found annotation
*/
private Annotation getNextAnnotation(final int offset, final int length, boolean forward, Position annotationPosition) {
Annotation nextAnnotation= null;
Position nextAnnotationPosition= null;
Annotation containingAnnotation= null;
Position containingAnnotationPosition= null;
boolean currentAnnotation= false;
IDocument document= getDocumentProvider().getDocument(getEditorInput());
int endOfDocument= document.getLength();
int distance= Integer.MAX_VALUE;
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
Iterator e= new CAnnotationIterator(model, true, true);
while (e.hasNext()) {
Annotation a= (Annotation) e.next();
if ((a instanceof ICAnnotation) && ((ICAnnotation)a).hasOverlay() || !isNavigationTarget(a))
continue;
Position p= model.getPosition(a);
if (p == null)
continue;
if (forward && p.offset == offset || !forward && p.offset + p.getLength() == offset + length) {// || p.includes(offset)) {
if (containingAnnotation == null || (forward && p.length >= containingAnnotationPosition.length || !forward && p.length >= containingAnnotationPosition.length)) {
containingAnnotation= a;
containingAnnotationPosition= p;
currentAnnotation= (p.length == length) || (p.length - 1 == length);
}
} else {
int currentDistance= 0;
if (forward) {
currentDistance= p.getOffset() - offset;
if (currentDistance < 0)
currentDistance= endOfDocument + currentDistance;
if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
distance= currentDistance;
nextAnnotation= a;
nextAnnotationPosition= p;
}
} else {
currentDistance= offset + length - (p.getOffset() + p.length);
if (currentDistance < 0)
currentDistance= endOfDocument + currentDistance;
if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
distance= currentDistance;
nextAnnotation= a;
nextAnnotationPosition= p;
}
}
}
}
if (containingAnnotationPosition != null && (!currentAnnotation || nextAnnotation == null)) {
annotationPosition.setOffset(containingAnnotationPosition.getOffset());
annotationPosition.setLength(containingAnnotationPosition.getLength());
return containingAnnotation;
}
if (nextAnnotationPosition != null) {
annotationPosition.setOffset(nextAnnotationPosition.getOffset());
annotationPosition.setLength(nextAnnotationPosition.getLength());
}
return nextAnnotation;
}
protected void updateStatusLine() { protected void updateStatusLine() {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection(); ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength()); Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
setStatusLineErrorMessage(null); setStatusLineErrorMessage(null);
setStatusLineMessage(null); setStatusLineMessage(null);
if (annotation != null) { if (annotation != null) {
try { updateMarkerViews(annotation);
fIsUpdatingAnnotationViews= true;
updateAnnotationViews(annotation);
} finally {
fIsUpdatingAnnotationViews= false;
}
if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem()) if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem())
setStatusLineMessage(annotation.getText()); setStatusLineMessage(annotation.getText());
} }
} }
/**
* Updates the annotation views that show the given annotation.
*
* @param annotation the annotation
*/
private void updateAnnotationViews(Annotation annotation) {
IMarker marker= null;
if (annotation instanceof MarkerAnnotation)
marker= ((MarkerAnnotation) annotation).getMarker();
else if (annotation instanceof ICAnnotation) {
Iterator e= ((ICAnnotation) annotation).getOverlaidIterator();
if (e != null) {
while (e.hasNext()) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
marker= ((MarkerAnnotation) o).getMarker();
break;
}
}
}
}
if (marker != null && !marker.equals(fLastMarkerTarget)) {
try {
boolean isProblem= marker.isSubtypeOf(IMarker.PROBLEM);
IWorkbenchPage page= getSite().getPage();
IViewPart view= page.findView(isProblem ? IPageLayout.ID_PROBLEM_VIEW: IPageLayout.ID_TASK_LIST);
if (view != null) {
Method method= view.getClass().getMethod("setSelection", new Class[] { IStructuredSelection.class, boolean.class}); //$NON-NLS-1$
method.invoke(view, new Object[] {new StructuredSelection(marker), Boolean.TRUE });
}
} catch (CoreException x) {
} catch (NoSuchMethodException x) {
} catch (IllegalAccessException x) {
} catch (InvocationTargetException x) {
}
// ignore exceptions, don't update any of the lists, just set status line
}
}
/** /**
* Returns the annotation overlapping with the given range or <code>null</code>. * Returns the annotation overlapping with the given range or <code>null</code>.
* *
@ -1151,7 +951,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
* @see org.eclipse.ui.part.IShowInSource#getShowInContext() * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
* *
* This is required by the IShowInSource interface for the "ShowIn" * This is required by the IShowInSource interface for the "ShowIn"
* navigation menu generalized in Eclipse. * navigation menu generalized in Eclipse.
*/ */
public ShowInContext getShowInContext() { public ShowInContext getShowInContext() {
return new ShowInContext( getEditorInput(), null ); return new ShowInContext( getEditorInput(), null );

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others. * Copyright (c) 2005, 2006 IBM Corporation 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
@ -75,9 +75,9 @@ public class CEditorActionContributor extends TextEditorActionContributor {
boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
setEnabled(isEnabled); setEnabled(isEnabled);
} }
/** /*
* @see Action#run() * @see org.eclipse.jface.action.Action#run()
*/ */
public void run() { public void run() {
if (fOperationCode != -1 && fOperationTarget != null) if (fOperationCode != -1 && fOperationTarget != null)
@ -134,9 +134,8 @@ public class CEditorActionContributor extends TextEditorActionContributor {
} }
/*
/** * @see org.eclipse.ui.texteditor.BasicTextEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
* @see IActionBarContributor#contributeToMenu(MenuManager)
*/ */
public void contributeToMenu(IMenuManager menu) { public void contributeToMenu(IMenuManager menu) {
@ -178,8 +177,8 @@ public class CEditorActionContributor extends TextEditorActionContributor {
} }
/** /*
* @see IEditorActionBarContributor#setActiveEditor(IEditorPart) * @see org.eclipse.ui.editors.text.TextEditorActionContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
*/ */
public void setActiveEditor(IEditorPart part) { public void setActiveEditor(IEditorPart part) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others. * Copyright (c) 2005, 2006 IBM Corporation 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
@ -8,26 +8,21 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QNX Software System * QNX Software System
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer; import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.ui.texteditor.MarkerUtilities;
public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnotation, ICAnnotation { public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnotation, ICAnnotation {
@ -39,159 +34,12 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
public static final String TASK_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$ public static final String TASK_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
private boolean fIsProblemMarker; private boolean fIsProblemMarker;
private IDocument fDocument;
private int error_start = -1;
private int error_length = 0;
private ICAnnotation fOverlay; private ICAnnotation fOverlay;
public CMarkerAnnotation(IMarker marker, IDocument document) { public CMarkerAnnotation(IMarker marker, IDocument document) {
super(marker); super(marker);
fDocument = document; fIsProblemMarker = MarkerUtilities.isMarkerType(getMarker(), ICModelMarker.C_MODEL_PROBLEM_MARKER);
if (MarkerUtilities.isMarkerType(getMarker(), ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
fIsProblemMarker = true;
try {
String var = (String) getMarker().getAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE);
if(var != null && fDocument != null) {
int line = getMarker().getAttribute(IMarker.LOCATION, -1) - 1;
if(line >= 0) {
int position = fDocument.getLineOffset(line);
String text = fDocument.get(position, fDocument.getLineLength(line));
int start = 0, end, pos;
pos = 0;
while(start != -1) {
start = getStart(text, var, pos);
if(start >= 0) {
if(Character.isJavaIdentifierStart(text.charAt(start + var.length())) == false) {
break;
}
}
pos += var.length();
}
//start = text.indexOf(var);
if(start >= 0) {
end = start + var.length();
// We cannot just update the marker attributes as the workspace resource tree is locked
Map map = marker.getAttributes();
MarkerUtilities.setCharStart(map, position+start);
MarkerUtilities.setCharEnd(map, position+end);
error_start = position+start;
error_length = end-start;
//getMarker().setAttribute(IMarker.CHAR_START, position+start);
//getMarker().setAttribute(IMarker.CHAR_END, position+end);
}
}
}
} catch (CoreException e) {
} catch (BadLocationException e) {
}
}
}
/**
* Ensures that we return a value that is not encased in a String
*/
private int getStart(String text, String var, int pos){
// determine if there are more than one instance of var in this text
int count = 0;
int currentPosition = pos;
while(currentPosition != -1){
currentPosition = text.indexOf(var, currentPosition);
if (currentPosition != -1){
// found one!
count++;
currentPosition += var.length();
}
}
// only one occurrence return its index
if (count == 1){
return text.indexOf(var, pos);
}
// otherwise we need to find the first one not inside of quotes
int indexOfStringStart = pos;
final String QUOTE = "\""; //$NON-NLS-1$
indexOfStringStart = text.indexOf(QUOTE, indexOfStringStart);
int newPosition = -1;
currentPosition = pos; // reinitialize currentPosition
if (indexOfStringStart == -1) {
// No Strings ... return the first occurrence of var
newPosition = text.indexOf(var, currentPosition);
} else {
// we have Strings
StringTokenizer tokens = new StringTokenizer(text.substring(currentPosition), QUOTE, true);
String nextToken = null;
int quoteCount = 0;
int potentialStart = -1;
boolean found = false;
while (tokens.hasMoreTokens() && !found){
nextToken = tokens.nextToken();
if(QUOTE.equals(nextToken)){
quoteCount++;
} else {
if ((quoteCount % 2) == 0){
// no open quotes .. we can check this token
potentialStart = nextToken.indexOf(var, 0);
if (potentialStart != -1){
found = true;
currentPosition += potentialStart;
newPosition = currentPosition;
break;
}
}// else ... we have an open quote and must
// throw away this non-quote token
}
currentPosition += nextToken.length();
}
}
return newPosition;
}
/**
* Initializes the annotation's icon representation and its drawing layer
* based upon the properties of the underlying marker.
*/
protected void initialize() {
try {
IMarker marker= getMarker();
if (MarkerUtilities.isMarkerType(marker, SearchUI.SEARCH_MARKER)) {
setLayer(2);
setImage(SearchUI.getSearchMarkerImage());
fIsProblemMarker= false;
return;
} else if (MarkerUtilities.isMarkerType(getMarker(), ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
fIsProblemMarker = true;
String var = (String) marker.getAttribute(ICModelMarker.C_MODEL_MARKER_VARIABLE);
if(var != null && fDocument != null) {
int line = marker.getAttribute(IMarker.LOCATION, -1);
if(line >= 0 && line == -1) {
try {
int position = fDocument.getLineOffset(line);
System.out.println("offset " + position); //$NON-NLS-1$
String text = fDocument.get(position, fDocument.getLineLength(line));
System.out.println("text:" + text); //$NON-NLS-1$
} catch (BadLocationException e) {}
}
}
} else {
if(marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)) { //|| getMarker().isSubtypeOf(IMarker.SEVERITY_WARNING)) {
fIsProblemMarker= true;
} else if (marker.isSubtypeOf(IMarker.TASK) || marker.isSubtypeOf(ICModelMarker.TASK_MARKER)) {
fIsProblemMarker= false;
} else
fIsProblemMarker = true;
}
} catch (CoreException e) {
}
super.initialize();
} }
/** /**
@ -252,20 +100,13 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
return 0; return 0;
} }
/** /*
* @see IProblemAnnotation#isProblem() * @see org.eclipse.cdt.internal.ui.editor.IProblemAnnotation#isProblem()
*/ */
public boolean isProblem() { public boolean isProblem() {
return fIsProblemMarker; return fIsProblemMarker;
} }
public int getErrorStart() {
return error_start;
}
public int getErrorLength() {
return error_length;
}
/** /**
* Overlays this annotation with the given cAnnotation. * Overlays this annotation with the given cAnnotation.
* *
@ -329,12 +170,4 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
} }
return null; return null;
} }
/*
* @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getImage(org.eclipse.swt.widgets.Display)
*/
public Image getImage(Display display) {
return super.getImage(display);
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2005 IBM Corporation and others. * Copyright (c) 2002, 2006 IBM Corporation 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
@ -242,14 +242,14 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#append(char) * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
*/ */
public void append(char[] text) { public void append(char[] text) {
append(new String(text)); append(new String(text));
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#append(java.lang.String) * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
*/ */
public void append(String text) { public void append(String text) {
if (DEBUG_LINE_DELIMITERS) { if (DEBUG_LINE_DELIMITERS) {
@ -260,7 +260,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#close() * @see org.eclipse.cdt.core.model.IBuffer#close()
*/ */
public void close() { public void close() {
@ -286,7 +286,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getChar(int) * @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
*/ */
public char getChar(int position) { public char getChar(int position) {
try { try {
@ -297,7 +297,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getCharacters() * @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
*/ */
public char[] getCharacters() { public char[] getCharacters() {
String content= getContents(); String content= getContents();
@ -305,28 +305,28 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getContents() * @see org.eclipse.cdt.core.model.IBuffer#getContents()
*/ */
public String getContents() { public String getContents() {
return fDocument.get(); return fDocument.get();
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getLength() * @see org.eclipse.cdt.core.model.IBuffer#getLength()
*/ */
public int getLength() { public int getLength() {
return fDocument.getLength(); return fDocument.getLength();
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getOwner() * @see org.eclipse.cdt.core.model.IBuffer#getOwner()
*/ */
public IOpenable getOwner() { public IOpenable getOwner() {
return fOwner; return fOwner;
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getText(int, int) * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
*/ */
public String getText(int offset, int length) { public String getText(int offset, int length) {
try { try {
@ -337,28 +337,28 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#getUnderlyingResource() * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
*/ */
public IResource getUnderlyingResource() { public IResource getUnderlyingResource() {
return fFile; return fFile;
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#hasUnsavedChanges() * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
*/ */
public boolean hasUnsavedChanges() { public boolean hasUnsavedChanges() {
return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false; return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false;
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#isClosed() * @see org.eclipse.cdt.core.model.IBuffer#isClosed()
*/ */
public boolean isClosed() { public boolean isClosed() {
return fDocument == null; return fDocument == null;
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#isReadOnly() * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
*/ */
public boolean isReadOnly() { public boolean isReadOnly() {
IResource resource= getUnderlyingResource(); IResource resource= getUnderlyingResource();
@ -372,14 +372,14 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#replace(int, int, char) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
*/ */
public void replace(int position, int length, char[] text) { public void replace(int position, int length, char[] text) {
replace(position, length, new String(text)); replace(position, length, new String(text));
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#replace(int, int, java.lang.String) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
*/ */
public void replace(int position, int length, String text) { public void replace(int position, int length, String text) {
if (DEBUG_LINE_DELIMITERS) { if (DEBUG_LINE_DELIMITERS) {
@ -389,7 +389,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean) * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
*/ */
public void save(IProgressMonitor progress, boolean force) throws CModelException { public void save(IProgressMonitor progress, boolean force) throws CModelException {
try { try {
@ -401,14 +401,14 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#setContents(char) * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
*/ */
public void setContents(char[] contents) { public void setContents(char[] contents) {
setContents(new String(contents)); setContents(new String(contents));
} }
/** /**
* @see org.eclipse.cdt.internal.core.model.IBuffer#setContents(java.lang.String) * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
*/ */
public void setContents(String contents) { public void setContents(String contents) {
int oldLength= fDocument.getLength(); int oldLength= fDocument.getLength();

View file

@ -48,7 +48,7 @@ public class ExternalSearchDocumentProvider extends FileDocumentProvider {
/** /**
* @param externalInput * @param externalInput
* @return * @return a new annotation model for the editor input
*/ */
private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) { private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) {

View file

@ -14,8 +14,6 @@ package org.eclipse.cdt.internal.ui.editor;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
/** /**
* ICAnnotation * ICAnnotation
@ -24,7 +22,7 @@ import org.eclipse.swt.widgets.Display;
* and problems. * and problems.
* *
* @see org.eclipse.core.resources.IMarker * @see org.eclipse.core.resources.IMarker
* @see org.eclipse.jdt.core.compiler.IProblem * @see org.eclipse.cdt.core.parser.IProblem
*/ */
public interface ICAnnotation { public interface ICAnnotation {
@ -103,6 +101,4 @@ public interface ICAnnotation {
String[] getArguments(); String[] getArguments();
int getId(); int getId();
Image getImage(Display display);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others. * Copyright (c) 2005, 2006 IBM Corporation 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
@ -8,28 +8,29 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QNX Software System * QNX Software System
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor.asm; package org.eclipse.cdt.internal.ui.editor.asm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.ui.text.AbstractCScanner;
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.IColorManager;
import org.eclipse.cdt.internal.ui.text.util.CWhitespaceDetector;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.rules.EndOfLineRule; import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.ICharacterScanner; import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken; import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WhitespaceRule; import org.eclipse.jface.text.rules.WhitespaceRule;
import org.eclipse.jface.text.rules.WordPatternRule; import org.eclipse.jface.text.rules.WordPatternRule;
import org.eclipse.jface.text.rules.WordRule; import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.cdt.internal.ui.text.AbstractCScanner;
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.IColorManager;
import org.eclipse.cdt.internal.ui.text.util.CWhitespaceDetector;
/** /**
* A C code scanner. * A C code scanner.
@ -79,17 +80,11 @@ public final class AsmCodeScanner extends AbstractCScanner {
List rules= new ArrayList(); List rules= new ArrayList();
// Add rule for strings
Token token= getToken(ICColorConstants.C_SINGLE_LINE_COMMENT); Token token= getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
// Add rule for single line comments. // Add rule for single line comments.
rules.add(new EndOfLineRule("#", token)); //$NON-NLS-1$ rules.add(new EndOfLineRule("#", token)); //$NON-NLS-1$
token= getToken(ICColorConstants.C_STRING);
// Add rule for strings and character constants.
rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
//rules.add(new SingleLineRule("\"", "\"", token, '\\'));
Token other= getToken(ICColorConstants.C_DEFAULT); Token other= getToken(ICColorConstants.C_DEFAULT);
// Add generic whitespace rule. // Add generic whitespace rule.

View file

@ -1,138 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005 IBM Corporation 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:
* IBM Corporation - initial API and implementation
* QNX Software System
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor.asm;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.ICPartitions;
import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.IWordDetector;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WordRule;
/**
* This scanner recognizes comments
*/
public class AsmPartitionScanner extends RuleBasedPartitionScanner {
//private final static String SKIP= "__skip";
public final static String ASM_MULTILINE_COMMENT= ICColorConstants.C_MULTI_LINE_COMMENT;
public final static String ASM_SINGLE_LINE_COMMENT= ICColorConstants.C_SINGLE_LINE_COMMENT;
public final static String ASM_STRING= ICColorConstants.C_STRING;
/**
* Detector for empty comments.
*/
static class EmptyCommentDetector implements IWordDetector {
/**
* @see IWordDetector#isWordStart
*/
public boolean isWordStart(char c) {
return (c == '/');
}
/**
* @see IWordDetector#isWordPart
*/
public boolean isWordPart(char c) {
return (c == '*' || c == '/');
}
}
/**
* Word rule for empty comments.
*/
static class EmptyCommentRule extends WordRule implements IPredicateRule {
private IToken fSuccessToken;
/**
* Constructor for EmptyCommentRule.
* @param defaultToken
*/
public EmptyCommentRule(IToken successToken) {
super(new EmptyCommentDetector());
fSuccessToken= successToken;
addWord("/**/", fSuccessToken); //$NON-NLS-1$
}
/*
* @see IPredicateRule#evaluate(ICharacterScanner, boolean)
*/
public IToken evaluate(ICharacterScanner scanner, boolean resume) {
return evaluate(scanner);
}
/*
* @see IPredicateRule#getSuccessToken()
*/
public IToken getSuccessToken() {
return fSuccessToken;
}
}
/**
* Creates the partitioner and sets up the appropriate rules.
*/
public AsmPartitionScanner() {
super();
IToken comment= new Token(ICPartitions.C_MULTILINE_COMMENT);
IToken single_comment= new Token(ICPartitions.C_SINGLE_LINE_COMMENT);
IToken string= new Token(ICPartitions.C_STRING);
// IToken skip= new Token(SKIP);
List rules= new ArrayList();
// Minimize the number of rules, since we have duplicate rules
// in the CCodeScanner...
// Add rule for single line comments.
rules.add(new EndOfLineRule("//", single_comment)); //$NON-NLS-1$
rules.add(new EndOfLineRule("#", single_comment)); //$NON-NLS-1$
// Add rule for strings and character constants.
rules.add(new SingleLineRule("\"", "\"", string, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
rules.add(new SingleLineRule("'", "'", string, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
EmptyCommentRule wordRule= new EmptyCommentRule(comment);
rules.add(wordRule);
// Add rules for multi-line comments.
rules.add(new MultiLineRule("/*", "*/", comment)); //$NON-NLS-1$ //$NON-NLS-2$
IPredicateRule[] result= new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}
}

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor.asm; package org.eclipse.cdt.internal.ui.editor.asm;
@ -17,23 +18,32 @@ import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer; import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.text.ICPartitions;
public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration { public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration {
private AsmTextTools fAsmTextTools;
private AsmTextEditor fEditor;
private AsmTextTools fTextTools;
/**
* Constructor for AsmSourceViewerConfiguration
*/
public AsmSourceViewerConfiguration(AsmTextTools tools) {
super();
fAsmTextTools = tools;
}
/** /**
* Returns the ASM multiline comment scanner for this configuration. * Returns the ASM multiline comment scanner for this configuration.
* *
* @return the ASM multiline comment scanner * @return the ASM multiline comment scanner
*/ */
protected RuleBasedScanner getMultilineCommentScanner() { protected RuleBasedScanner getMultilineCommentScanner() {
return fTextTools.getMultilineCommentScanner(); return fAsmTextTools.getMultilineCommentScanner();
} }
/** /**
@ -42,7 +52,7 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* @return the ASM singleline comment scanner * @return the ASM singleline comment scanner
*/ */
protected RuleBasedScanner getSinglelineCommentScanner() { protected RuleBasedScanner getSinglelineCommentScanner() {
return fTextTools.getSinglelineCommentScanner(); return fAsmTextTools.getSinglelineCommentScanner();
} }
/** /**
@ -51,60 +61,59 @@ public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration
* @return the ASM string scanner * @return the ASM string scanner
*/ */
protected RuleBasedScanner getStringScanner() { protected RuleBasedScanner getStringScanner() {
return fTextTools.getStringScanner(); return fAsmTextTools.getStringScanner();
} }
/** /*
* Constructor for AsmSourceViewerConfiguration * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
*/ */
public AsmSourceViewerConfiguration(AsmTextTools tools, AsmTextEditor editor) { public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
super(); // the ASM editor also uses the CDocumentPartitioner
fEditor = editor; return CUIPlugin.getDefault().getTextTools().getDocumentPartitioning();
fTextTools = tools;
} }
/** /*
* @see ISourceViewerConfiguration#getPresentationReconciler(ISourceViewer) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
*/ */
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
// CColorManager manager= fTextTools.getColorManager();
PresentationReconciler reconciler= new PresentationReconciler(); PresentationReconciler reconciler= new PresentationReconciler();
DefaultDamagerRepairer dr= new DefaultDamagerRepairer(fAsmTextTools.getCodeScanner());
DefaultDamagerRepairer dr= new DefaultDamagerRepairer(fTextTools.getCodeScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr= new DefaultDamagerRepairer(getMultilineCommentScanner()); dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
reconciler.setDamager(dr, AsmPartitionScanner.ASM_MULTILINE_COMMENT); reconciler.setDamager(dr, ICPartitions.C_MULTILINE_COMMENT);
reconciler.setRepairer(dr, AsmPartitionScanner.ASM_MULTILINE_COMMENT); reconciler.setRepairer(dr, ICPartitions.C_MULTILINE_COMMENT);
dr= new DefaultDamagerRepairer(getSinglelineCommentScanner()); dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
reconciler.setDamager(dr, AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT); reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
reconciler.setRepairer(dr, AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT); reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
dr= new DefaultDamagerRepairer(getStringScanner()); dr= new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, AsmPartitionScanner.ASM_STRING); reconciler.setDamager(dr, ICPartitions.C_STRING);
reconciler.setRepairer(dr, AsmPartitionScanner.ASM_STRING); reconciler.setRepairer(dr, ICPartitions.C_STRING);
dr= new DefaultDamagerRepairer(getStringScanner());
reconciler.setDamager(dr, ICPartitions.C_CHARACTER);
reconciler.setRepairer(dr, ICPartitions.C_CHARACTER);
reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
return reconciler; return reconciler;
} }
/** /*
* @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredContentTypes(org.eclipse.jface.text.source.ISourceViewer)
*/ */
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] { IDocument.DEFAULT_CONTENT_TYPE, return new String[] {
AsmPartitionScanner.ASM_MULTILINE_COMMENT, IDocument.DEFAULT_CONTENT_TYPE,
AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT, ICPartitions.C_MULTILINE_COMMENT,
AsmPartitionScanner.ASM_STRING }; ICPartitions.C_SINGLE_LINE_COMMENT,
ICPartitions.C_STRING,
ICPartitions.C_CHARACTER };
} }

View file

@ -32,7 +32,7 @@ public class AsmTextEditor extends TextEditor {
*/ */
protected void initializeEditor() { protected void initializeEditor() {
AsmTextTools textTools= CUIPlugin.getDefault().getAsmTextTools(); AsmTextTools textTools= CUIPlugin.getDefault().getAsmTextTools();
setSourceViewerConfiguration(new AsmSourceViewerConfiguration(textTools, this)); setSourceViewerConfiguration(new AsmSourceViewerConfiguration(textTools));
setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider()); setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
// FIXME: Should this editor have a different preference store ? // FIXME: Should this editor have a different preference store ?
// For now we are sharing with the CEditor and any changes will in the // For now we are sharing with the CEditor and any changes will in the

View file

@ -12,20 +12,19 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor.asm; package org.eclipse.cdt.internal.ui.editor.asm;
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.CCommentScanner;
import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
import org.eclipse.cdt.internal.ui.text.util.CColorManager;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jface.text.rules.IPartitionTokenScanner;
import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.text.rules.RuleBasedScanner;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.text.CCommentScanner;
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
import org.eclipse.cdt.internal.ui.text.util.CColorManager;
/** /**
* This type shares all scanners and the color manager between * This type shares all scanners and the color manager between
@ -46,8 +45,6 @@ public class AsmTextTools {
private CColorManager fColorManager; private CColorManager fColorManager;
/** The Asm source code scanner */ /** The Asm source code scanner */
private AsmCodeScanner fCodeScanner; private AsmCodeScanner fCodeScanner;
/** The Asm partitions scanner */
private AsmPartitionScanner fPartitionScanner;
/** The ASM multiline comment scanner */ /** The ASM multiline comment scanner */
private CCommentScanner fMultilineCommentScanner; private CCommentScanner fMultilineCommentScanner;
/** The ASM singleline comment scanner */ /** The ASM singleline comment scanner */
@ -83,7 +80,6 @@ public class AsmTextTools {
fColorManager= new CColorManager(); fColorManager= new CColorManager();
fCodeScanner= new AsmCodeScanner(fColorManager, store); fCodeScanner= new AsmCodeScanner(fColorManager, store);
fPartitionScanner= new AsmPartitionScanner();
fMultilineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_MULTI_LINE_COMMENT); fMultilineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_MULTI_LINE_COMMENT);
fSinglelineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_SINGLE_LINE_COMMENT); fSinglelineCommentScanner= new CCommentScanner(fColorManager, store, coreStore, ICColorConstants.C_SINGLE_LINE_COMMENT);
@ -111,7 +107,6 @@ public class AsmTextTools {
public void dispose() { public void dispose() {
fCodeScanner= null; fCodeScanner= null;
fPartitionScanner= null;
fMultilineCommentScanner= null; fMultilineCommentScanner= null;
fSinglelineCommentScanner= null; fSinglelineCommentScanner= null;
@ -148,30 +143,7 @@ public class AsmTextTools {
public RuleBasedScanner getCodeScanner() { public RuleBasedScanner getCodeScanner() {
return fCodeScanner; return fCodeScanner;
} }
/**
* Gets the partition scanner used.
*/
public IPartitionTokenScanner getPartitionScanner() {
return fPartitionScanner;
}
/**
* Gets the document provider used.
*/
public IDocumentPartitioner createDocumentPartitioner() {
String[] types= new String[] {
AsmPartitionScanner.ASM_MULTILINE_COMMENT,
AsmPartitionScanner.ASM_SINGLE_LINE_COMMENT,
AsmPartitionScanner.ASM_STRING
};
//return new RuleBasedPartitioner(getPartitionScanner(), types);
//return new DefaultPartitioner(getPartitionScanner(), types);
return new FastPartitioner(getPartitionScanner(), types);
}
/** /**
* Returns a scanner which is configured to scan Java multiline comments. * Returns a scanner which is configured to scan Java multiline comments.
* *

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005 IBM Corporation and others. * Copyright (c) 2005, 2006 IBM Corporation 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
@ -37,8 +37,8 @@ public class AsmWordDetector implements IWordDetector {
fPrefix = prefix; fPrefix = prefix;
fExtra = extra; fExtra = extra;
} }
/** /*
* @see IWordDetector#isWordIdentifierStart * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
*/ */
public boolean isWordStart(char c) { public boolean isWordStart(char c) {
if(fPrefix != 0) { if(fPrefix != 0) {
@ -49,9 +49,8 @@ public class AsmWordDetector implements IWordDetector {
} }
return (Character.isJavaIdentifierPart(c) || (c == fExtra)); return (Character.isJavaIdentifierPart(c) || (c == fExtra));
} }
/*
/** * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
* @see IWordDetector#isWordIdentifierPart
*/ */
public boolean isWordPart(char c) { public boolean isWordPart(char c) {
return Character.isJavaIdentifierPart(c); return Character.isJavaIdentifierPart(c);

View file

@ -26,7 +26,6 @@ import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
* <code>ISourceReference</code>s. * <code>ISourceReference</code>s.
* *
* @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter * @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter
* @see org.eclipse.cdt.internal.ui.cview.CView#initDrag()
*/ */
public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant { public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
@ -45,7 +44,7 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
*/ */
public boolean setDragData(DragSourceEvent event, public boolean setDragData(DragSourceEvent event,
IStructuredSelection selection) { IStructuredSelection selection) {
if (selection instanceof IStructuredSelection) { if (selection != null) {
for (Iterator iter= (selection).iterator(); iter.hasNext();) { for (Iterator iter= (selection).iterator(); iter.hasNext();) {
Object element= iter.next(); Object element= iter.next();
if (element instanceof ICElement) { if (element instanceof ICElement) {

View file

@ -41,7 +41,6 @@ import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
* A Common Navigator drop adapter assistant handling dropping of <code>ICElement</code>s. * A Common Navigator drop adapter assistant handling dropping of <code>ICElement</code>s.
* *
* @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter * @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter
* @see org.eclipse.cdt.internal.ui.cview.CView#initDrop()
*/ */
public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {

View file

@ -30,14 +30,13 @@ import org.eclipse.ui.navigator.ICommonLabelProvider;
* A label provider suitable for the Common Navigator providing also * A label provider suitable for the Common Navigator providing also
* status message text for the current selected item. * status message text for the current selected item.
* *
* @see org.eclipse.cdt.internal.ui.cview.CView#getStatusLineMessage() * @see org.eclipse.cdt.internal.ui.cview.CView#createLabelProvider
* @see org.eclipse.cdt.internal.ui.cview.CView#getStatusLineMessage
*/ */
public class CNavigatorLabelProvider extends CViewLabelProvider implements ICommonLabelProvider { public class CNavigatorLabelProvider extends CViewLabelProvider implements ICommonLabelProvider {
/** /**
* Create a default label provider. * Create a default label provider.
*
* @see org.eclipse.cdt.internal.ui.cview.CView#createLabelProvider()
*/ */
public CNavigatorLabelProvider() { public CNavigatorLabelProvider() {
super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,

View file

@ -30,7 +30,7 @@ import org.eclipse.ui.navigator.ICommonMenuConstants;
/** /**
* This is basically a clone of {@link org.eclipse.cdt.internal.ui.OpenFileGroup}, * This is basically a clone of {@link org.eclipse.cdt.internal.ui.cview.OpenFileGroup},
* but without explicit dependency on CView. This opens it up for use in the * but without explicit dependency on CView. This opens it up for use in the
* Common Navigator framework. * Common Navigator framework.
* <p> * <p>

View file

@ -32,7 +32,7 @@ import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
* A Common Navigator action provider adding standard working set filter support. * A Common Navigator action provider adding standard working set filter support.
* *
* @see CNavigatorWorkingSetActionGroup * @see CNavigatorWorkingSetActionGroup
* @see org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilter * @see ResourceWorkingSetFilter
*/ */
public class CNavigatorWorkingSetActionProvider extends CommonActionProvider { public class CNavigatorWorkingSetActionProvider extends CommonActionProvider {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.internal.ui.CUIMessages;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
@ -23,10 +22,10 @@ import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.IAnnotationHover; import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.texteditor.MarkerAnnotation; import org.eclipse.ui.texteditor.MarkerAnnotation;
import org.eclipse.cdt.internal.ui.CUIMessages;
public class CAnnotationHover implements IAnnotationHover { public class CAnnotationHover implements IAnnotationHover {
/** /**
@ -128,16 +127,6 @@ public class CAnnotationHover implements IAnnotationHover {
} }
private int getHoverWidth(Display display) {
Rectangle displayBounds= display.getBounds();
int hoverWidth= displayBounds.width - (display.getCursorLocation().x - displayBounds.x);
hoverWidth-= 12; // XXX: Add some space to the border, Revisit
if (hoverWidth < 200) {
hoverWidth= 200;
}
return hoverWidth;
}
/* /*
* Formats a message as HTML text. * Formats a message as HTML text.
*/ */

View file

@ -218,9 +218,8 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
return false; return false;
} }
/*
/** * @see org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
* @see IAutoIndentStrategy#customizeDocumentCommand
*/ */
public void customizeDocumentCommand(IDocument d, DocumentCommand c) { public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text)) { if (c.length == 0 && c.text != null && endsWithDelimiter(d, c.text)) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QNX Software System * QNX Software System
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.text; package org.eclipse.cdt.internal.ui.text;
@ -15,17 +16,18 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WordRule; import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
/** /**
* A C code scanner. * A C code scanner.
@ -72,12 +74,7 @@ public final class CCodeScanner extends AbstractCScanner {
protected List createRules() { protected List createRules() {
List rules= new ArrayList(); List rules= new ArrayList();
Token token;
// Add rule for strings
Token token= getToken(ICColorConstants.C_STRING);
// Add rule for strings and character constants.
rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
// Add generic white space rule. // Add generic white space rule.
//rules.add(new WhitespaceRule(new CWhitespaceDetector())); //rules.add(new WhitespaceRule(new CWhitespaceDetector()));

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2005 QNX Software Systems and others. * Copyright (c) 2000, 2006 QNX Software 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
@ -65,7 +65,6 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
final TypedPosition partition= (TypedPosition)fPartitions.removeFirst(); final TypedPosition partition= (TypedPosition)fPartitions.removeFirst();
if (document != null && partition != null) { if (document != null && partition != null) {
Map options = getPreferences();
try { try {
final TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_COMPILATION_UNIT, final TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_COMPILATION_UNIT,

View file

@ -1,5 +1,5 @@
/********************************************************************** /**********************************************************************
* Copyright (c) 2004, 2005 Intel Corporation and others. * Copyright (c) 2004, 2006 Intel Corporation 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
@ -15,17 +15,18 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.ui.ICHelpBook;
import org.eclipse.cdt.ui.ICHelpProvider;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.SafeRunner;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.eclipse.cdt.ui.ICHelpBook;
import org.eclipse.cdt.ui.ICHelpProvider;
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
/** /**
* This class represents the CHelpProvider settings * This class represents the CHelpProvider settings
* *
@ -55,7 +56,6 @@ public class CHelpProviderDescriptor {
if(parentElement == null) if(parentElement == null)
return; return;
NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROVIDER);
Element projectElement = getDescriptorElement(parentElement); Element projectElement = getDescriptorElement(parentElement);
if(projectElement == null) if(projectElement == null)
@ -108,7 +108,7 @@ public class CHelpProviderDescriptor {
public void handleException(Throwable exception) { public void handleException(Throwable exception) {
} }
}; };
Platform.run(runnable); SafeRunner.run(runnable);
} }
return provider; return provider;
} }

View file

@ -61,7 +61,7 @@ public class CPartitionScanner extends RuleBasedPartitionScanner implements ICPa
private IToken fSuccessToken; private IToken fSuccessToken;
/** /**
* Constructor for EmptyCommentRule. * Constructor for EmptyCommentRule.
* @param defaultToken * @param successToken
*/ */
public EmptyCommentRule(IToken successToken) { public EmptyCommentRule(IToken successToken) {
super(new EmptyCommentDetector()); super(new EmptyCommentDetector());
@ -94,13 +94,8 @@ public class CPartitionScanner extends RuleBasedPartitionScanner implements ICPa
IToken single_comment= new Token(C_SINGLE_LINE_COMMENT); IToken single_comment= new Token(C_SINGLE_LINE_COMMENT);
IToken string= new Token(C_STRING); IToken string= new Token(C_STRING);
IToken character = new Token(C_CHARACTER); IToken character = new Token(C_CHARACTER);
IToken skip= new Token(SKIP);
List rules= new ArrayList(); List rules= new ArrayList();
// Minimize the number of rules, since we have duplicate rules // Minimize the number of rules, since we have duplicate rules
// in the CCodeScanner... // in the CCodeScanner...

View file

@ -38,9 +38,9 @@ public class CReconcilingStrategy implements IReconcilingStrategy {
fEditor= editor; fEditor= editor;
fManager= CUIPlugin.getDefault().getWorkingCopyManager(); fManager= CUIPlugin.getDefault().getWorkingCopyManager();
} }
/** /*
* @see IReconcilingStrategy#reconcile(document) * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
*/ */
public void setDocument(IDocument document) { public void setDocument(IDocument document) {
} }
@ -53,16 +53,16 @@ public class CReconcilingStrategy implements IReconcilingStrategy {
fProgressMonitor= monitor; fProgressMonitor= monitor;
} }
/** /*
* @see IReconcilingStrategy#reconcile(region) * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
*/ */
public void reconcile(IRegion region) { public void reconcile(IRegion region) {
reconcile(); reconcile();
} }
/** /*
* @see IReconcilingStrategy#reconcile(dirtyRegion, reion) * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
*/ */
public void reconcile(DirtyRegion dirtyRegion, IRegion region) { public void reconcile(DirtyRegion dirtyRegion, IRegion region) {
// consistent data needs not further checks ! // consistent data needs not further checks !

View file

@ -255,22 +255,6 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$ return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$
} }
/**
* @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
*/
public String getDefaultPrefix(ISourceViewer sourceViewer, String contentType) {
if(IDocument.DEFAULT_CONTENT_TYPE.equals(contentType))
return "//"; //$NON-NLS-1$
if(ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
return "//"; //$NON-NLS-1$
}
if(ICPartitions.C_MULTILINE_COMMENT.equals(contentType)) {
return "//"; //$NON-NLS-1$
}
return null;
}
/* /*
* @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String) * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
*/ */

View file

@ -215,10 +215,6 @@ public class CWordFinder {
* @return * @return
* <code>true</code> if there is no function body around offset * <code>true</code> if there is no function body around offset
* <code>false</code> otherwise * <code>false</code> otherwise
*
* @param document
* @param offset
* @return
*/ */
public static boolean isGlobal(IDocument document, int offset) { public static boolean isGlobal(IDocument document, int offset) {
try { try {
@ -237,7 +233,7 @@ public class CWordFinder {
do { do {
c = document.getChar(pos--); c = document.getChar(pos--);
if (c == BRACE_R) return false; if (c == BRACE_R) return false;
} while (Character.isSpace(c)); } while (Character.isWhitespace(c));
// container block seems to be not a function or statement body // container block seems to be not a function or statement body
pos++; // step back one symbol pos++; // step back one symbol
bracketcount = 0; // let's search for upper block bracketcount = 0; // let's search for upper block

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QNX Software System * QNX Software System
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.text; package org.eclipse.cdt.internal.ui.text;
@ -15,17 +16,18 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.rules.IRule; import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token; import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.rules.WordRule; import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
/** /**
* A C code scanner. * A C code scanner.
@ -68,13 +70,7 @@ public final class CppCodeScanner extends AbstractCScanner {
protected List createRules() { protected List createRules() {
List rules= new ArrayList(); List rules= new ArrayList();
Token token;
// Add rule for strings
Token token= getToken(ICColorConstants.C_STRING);
// Add rule for strings and character constants.
rules.add(new SingleLineRule("'", "'", token, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
// Add generic whitespace rule. // Add generic whitespace rule.
//rules.add(new WhitespaceRule(new CWhitespaceDetector())); //rules.add(new WhitespaceRule(new CWhitespaceDetector()));

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -24,7 +24,7 @@ import org.eclipse.swt.graphics.RGB;
* This interface may be implemented by clients. * This interface may be implemented by clients.
* </p> * </p>
* *
* @see IJavaColorConstants * @see ICColorConstants
*/ */
public interface IColorManager { public interface IColorManager {

View file

@ -11,11 +11,10 @@
package org.eclipse.cdt.internal.ui.text; package org.eclipse.cdt.internal.ui.text;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
/** /**
@ -43,7 +42,7 @@ public class PreferencesAdapter implements IPreferenceStore {
} }
/** Listeners on the adapter */ /** Listeners on the adapter */
private ListenerList fListeners= new ListenerList(); private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
/** Listener on the adapted Preferences */ /** Listener on the adapted Preferences */
private PropertyChangeListener fListener= new PropertyChangeListener(); private PropertyChangeListener fListener= new PropertyChangeListener();

View file

@ -35,7 +35,7 @@ public class PreprocessorRule extends WordRule implements IRule {
* *
* @param detector the word detector to be used by this rule, may not be <code>null</code> * @param detector the word detector to be used by this rule, may not be <code>null</code>
* *
* @see #addWord * @see WordRule#addWord
*/ */
public PreprocessorRule(IWordDetector detector) { public PreprocessorRule(IWordDetector detector) {
this(detector, Token.UNDEFINED); this(detector, Token.UNDEFINED);
@ -50,7 +50,7 @@ public class PreprocessorRule extends WordRule implements IRule {
* @param defaultToken the default token to be returned on success * @param defaultToken the default token to be returned on success
* if nothing else is specified, may not be <code>null</code> * if nothing else is specified, may not be <code>null</code>
* *
* @see #addWord * @see WordRule#addWord
*/ */
public PreprocessorRule(IWordDetector detector, IToken defaultToken) { public PreprocessorRule(IWordDetector detector, IToken defaultToken) {
super(detector, defaultToken); super(detector, defaultToken);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -18,7 +18,7 @@ import java.io.Reader;
public abstract class SingleCharReader extends Reader { public abstract class SingleCharReader extends Reader {
/** /**
* @see Reader#read(char) * @see Reader#read()
*/ */
public abstract int read() throws IOException; public abstract int read() throws IOException;

View file

@ -11,12 +11,6 @@
package org.eclipse.cdt.internal.ui.text.c.hover; package org.eclipse.cdt.internal.ui.text.c.hover;
import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IInformationControlCreator;
@ -28,33 +22,24 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.commands.ICommand;
import org.eclipse.ui.commands.IKeySequenceBinding; import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
import org.eclipse.ui.keys.KeySequence;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
/** /**
* AbstractCEditorTextHover Abstract class for providing hover information for C * AbstractCEditorTextHover Abstract class for providing hover information for C
* elements. * elements.
* *
*/ */
public class AbstractCEditorTextHover implements ICEditorTextHover, public abstract class AbstractCEditorTextHover implements ICEditorTextHover,
ITextHoverExtension { ITextHoverExtension {
private IEditorPart fEditor; private IEditorPart fEditor;
private ICommand fCommand;
// {
// ICommandManager commandManager=
// PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
// fCommand=
// commandManager.getCommand(ICEditorActionDefinitionIds.SHOW_JAVADOC);
// if (!fCommand.isDefined())
// fCommand= null;
// }
/* /*
* @see IJavaEditorTextHover#setEditor(IEditorPart) * @see ICEditorTextHover#setEditor(IEditorPart)
*/ */
public void setEditor(IEditorPart editor) { public void setEditor(IEditorPart editor) {
fEditor = editor; fEditor = editor;
@ -85,63 +70,10 @@ public class AbstractCEditorTextHover implements ICEditorTextHover,
return null; return null;
} }
// protected ICodeAssist getCodeAssist() {
// if (fEditor != null) {
// IEditorInput input= fEditor.getEditorInput();
// if (input instanceof IClassFileEditorInput) {
// IClassFileEditorInput cfeInput= (IClassFileEditorInput) input;
// return cfeInput.getClassFile();
// }
//
// IWorkingCopyManager manager=
// CUIPlugin.getDefault().getWorkingCopyManager();
// return manager.getWorkingCopy(input);
// }
//
// return null;
// }
/* /*
* @see ITextHover#getHoverInfo(ITextViewer, IRegion) * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
*/ */
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { public abstract String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion);
// ICodeAssist resolve= getCodeAssist();
// if (resolve != null) {
// try {
// ICElement[] result= null;
//
// synchronized (resolve) {
// result= resolve.codeSelect(hoverRegion.getOffset(),
// hoverRegion.getLength());
// }
//
// if (result == null)
// return null;
//
// int nResults= result.length;
// if (nResults == 0)
// return null;
//
// return getHoverInfo(result);
//
// } catch (CModelException x) {
// CUIPlugin.log(x.getStatus());
// }
// }
return null;
}
/**
* Provides hover information for the given C elements.
*
* @param cElements
* the C elements for which to provide hover information
* @return the hover information string
*/
protected String getHoverInfo(ICElement[] cElements) {
return null;
}
/* /*
* @see ITextHoverExtension#getHoverControlCreator() * @see ITextHoverExtension#getHoverControlCreator()
@ -165,41 +97,8 @@ public class AbstractCEditorTextHover implements ICEditorTextHover,
* @since 3.0 * @since 3.0
*/ */
protected String getTooltipAffordanceString() { protected String getTooltipAffordanceString() {
// if //TLETODO [hover] provide affordance string
// (!CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)) // @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover
// return null;
//
// KeySequence[] sequences= getKeySequences();
// if (sequences == null)
// return null;
//
// String keySequence= sequences[0].format();
// return
// CHoverMessages.getFormattedString("JavaTextHover.makeStickyHint",
// keySequence); //$NON-NLS-1$
return null;
}
/**
* Returns the array of valid key sequence bindings for the show tool tip
* description command.
*
* @return the array with the {@link KeySequence}s
*
* @since 3.0
*/
private KeySequence[] getKeySequences() {
if (fCommand != null) {
List list = fCommand.getKeySequenceBindings();
if (!list.isEmpty()) {
KeySequence[] keySequences = new KeySequence[list.size()];
for (int i = 0; i < keySequences.length; i++) {
keySequences[i] = ((IKeySequenceBinding) list.get(i))
.getKeySequence();
}
return keySequences;
}
}
return null; return null;
} }

View file

@ -93,7 +93,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
} }
/** /**
* Creates a new Java Editor text hover descriptor from the given configuration element. * Creates a new C Editor text hover descriptor from the given configuration element.
*/ */
private CEditorTextHoverDescriptor(IConfigurationElement element) { private CEditorTextHoverDescriptor(IConfigurationElement element) {
Assert.isNotNull(element); Assert.isNotNull(element);
@ -101,10 +101,10 @@ public class CEditorTextHoverDescriptor implements Comparable {
} }
/** /**
* Creates the Java editor text hover. * Creates the C editor text hover.
*/ */
public ICEditorTextHover createTextHover() { public ICEditorTextHover createTextHover() {
String pluginId = fElement.getDeclaringExtension().getNamespace(); String pluginId = fElement.getDeclaringExtension().getContributor().getName();
boolean isHoversPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE; boolean isHoversPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
if (isHoversPlugInActivated || canActivatePlugIn()) { if (isHoversPlugInActivated || canActivatePlugIn()) {
try { try {

View file

@ -209,25 +209,21 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
if (fTextViewer != null && string != null) { if (fTextViewer != null && string != null) {
int index= string.indexOf("()"); //$NON-NLS-1$ int index= string.indexOf("()"); //$NON-NLS-1$
if (index != -1 && index + 1 == fCursorPosition) { if (index != -1 && index + 1 == fCursorPosition) {
IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore(); int newOffset= fReplacementOffset + fCursorPosition;
// if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACKETS)) {
if(true){ LinkedPositionGroup group= new LinkedPositionGroup();
int newOffset= fReplacementOffset + fCursorPosition; group.addPosition(new LinkedPosition(document, newOffset, 0, LinkedPositionGroup.NO_STOP));
LinkedPositionGroup group= new LinkedPositionGroup(); LinkedModeModel model= new LinkedModeModel();
group.addPosition(new LinkedPosition(document, newOffset, 0, LinkedPositionGroup.NO_STOP)); model.addGroup(group);
model.forceInstall();
LinkedModeModel model= new LinkedModeModel();
model.addGroup(group); LinkedModeUI ui= new EditorLinkedModeUI(model, fTextViewer);
model.forceInstall(); ui.setSimpleMode(true);
ui.setExitPolicy(new ExitPolicy(')'));
LinkedModeUI ui= new EditorLinkedModeUI(model, fTextViewer); ui.setExitPosition(fTextViewer, newOffset + 1, 0, Integer.MAX_VALUE);
ui.setSimpleMode(true); ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
ui.setExitPolicy(new ExitPolicy(')')); ui.enter();
ui.setExitPosition(fTextViewer, newOffset + 1, 0, Integer.MAX_VALUE);
ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
ui.enter();
}
} }
} }
@ -663,19 +659,14 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
return null; return null;
} }
/**
* {@inheritDoc}
*/
public void updateReplacementOffset(int newOffset) { public void updateReplacementOffset(int newOffset) {
setReplacementOffset(newOffset); setReplacementOffset(newOffset);
} }
/**
* {@inheritDoc}
*/
public void updateReplacementLength(int length) { public void updateReplacementLength(int length) {
setReplacementLength(length); setReplacementLength(length);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Object#hashCode() * @see java.lang.Object#hashCode()
*/ */

View file

@ -51,17 +51,17 @@ public final class CFoldingStructureProviderDescriptor {
*/ */
CFoldingStructureProviderDescriptor(IConfigurationElement element) { CFoldingStructureProviderDescriptor(IConfigurationElement element) {
fElement= element; fElement= element;
fId= element.getAttributeAsIs(ID); fId= element.getAttribute(ID);
Assert.isLegal(fId != null); Assert.isLegal(fId != null);
fName= element.getAttribute(NAME); fName= element.getAttribute(NAME);
if (fName == null) if (fName == null)
fName= fId; fName= fId;
fClass= element.getAttributeAsIs(CLASS); fClass= element.getAttribute(CLASS);
Assert.isLegal(fClass != null); Assert.isLegal(fClass != null);
if (element.getAttributeAsIs(PREFERENCES_CLASS) == null) if (element.getAttribute(PREFERENCES_CLASS) == null)
fHasPreferences= false; fHasPreferences= false;
else else
fHasPreferences= true; fHasPreferences= true;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -14,18 +14,6 @@ package org.eclipse.cdt.internal.ui.text.template;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.corext.template.c.CContextType;
import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContext;
import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.IInformationControlCreator;
@ -42,6 +30,20 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.ui.text.contentassist.ICompletionContributor;
import org.eclipse.cdt.internal.corext.template.c.CContextType;
import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContext;
import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
public class TemplateEngine implements ICompletionContributor { public class TemplateEngine implements ICompletionContributor {
private TemplateContextType fContextType; private TemplateContextType fContextType;
@ -98,9 +100,6 @@ public class TemplateEngine implements ICompletionContributor {
/** /**
* Empties the collector. * Empties the collector.
*
* @param viewer the text viewer
* @param unit the compilation unit (may be <code>null</code>)
*/ */
public void reset() { public void reset() {
fProposals.clear(); fProposals.clear();
@ -119,7 +118,7 @@ public class TemplateEngine implements ICompletionContributor {
* and feeds the collector with proposals. * and feeds the collector with proposals.
* @param viewer the text viewer * @param viewer the text viewer
* @param completionPosition the context position in the document of the text viewer * @param completionPosition the context position in the document of the text viewer
* @param compilationUnit the compilation unit (may be <code>null</code>) * @param translationUnit the translation unit (may be <code>null</code>)
*/ */
public void complete(ITextViewer viewer, int completionPosition, ITranslationUnit translationUnit) public void complete(ITextViewer viewer, int completionPosition, ITranslationUnit translationUnit)
{ {
@ -130,14 +129,6 @@ public class TemplateEngine implements ICompletionContributor {
Point selection= viewer.getSelectedRange(); Point selection= viewer.getSelectedRange();
// remember selected text
String selectedText= null;
if (selection.y != 0) {
try {
selectedText= document.get(selection.x, selection.y);
} catch (BadLocationException e) {}
}
((TranslationUnitContextType) fContextType).setContextParameters(document.get(), completionPosition, translationUnit); ((TranslationUnitContextType) fContextType).setContextParameters(document.get(), completionPosition, translationUnit);
TranslationUnitContext context= ((TranslationUnitContextType) fContextType).createContext(document, completionPosition, selection.y, translationUnit); TranslationUnitContext context= ((TranslationUnitContextType) fContextType).createContext(document, completionPosition, selection.y, translationUnit);
int start= context.getStart(); int start= context.getStart();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000 2005 IBM Corporation and others. * Copyright (c) 2000, 2006 IBM Corporation 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
@ -18,16 +18,16 @@ import org.eclipse.jface.text.rules.IWordDetector;
* A C aware word detector. * A C aware word detector.
*/ */
public class CWordDetector implements IWordDetector { public class CWordDetector implements IWordDetector {
/** /*
* @see IWordDetector#isWordIdentifierStart * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
*/ */
public boolean isWordStart(char c) { public boolean isWordStart(char c) {
return Character.isJavaIdentifierStart(c); return Character.isJavaIdentifierStart(c);
} }
/** /*
* @see IWordDetector#isWordIdentifierPart * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
*/ */
public boolean isWordPart(char c) { public boolean isWordPart(char c) {
return Character.isJavaIdentifierPart(c); return Character.isJavaIdentifierPart(c);