import net.sourceforge.phpdt.core.compiler.InvalidInputException;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError;
-import net.sourceforge.phpdt.internal.core.CompilationUnit;
import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
import net.sourceforge.phpdt.internal.ui.actions.FoldingActionGroup;
import net.sourceforge.phpdt.internal.ui.actions.SelectionConverter;
import net.sourceforge.phpdt.internal.ui.text.JavaWordIterator;
import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
-import net.sourceforge.phpdt.internal.ui.text.java.JavaExpandHover;
+import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaExpandHover;
import net.sourceforge.phpdt.internal.ui.viewsupport.ISelectionListenerWithAST;
import net.sourceforge.phpdt.internal.ui.viewsupport.IViewPartInputProvider;
import net.sourceforge.phpdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension3;
import org.eclipse.jface.text.ITextViewerExtension4;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.ISourceViewerExtension2;
import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.jface.text.source.OverviewRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.text.source.projection.ProjectionSupport;
try {
int widgetLocation = styledText.getOffsetAtLocation(new Point(x, y));
- if (textViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension = (ITextViewerExtension3) textViewer;
+ if (textViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
return extension.widgetOffset2ModelOffset(widgetLocation);
} else {
IRegion visibleRegion = textViewer.getVisibleRegion();
doSelectionChanged(event);
}
}
+
/**
* The internal shell activation listener for updating occurrences.
+ *
* @since 3.0
*/
- private ActivationListener fActivationListener= new ActivationListener();
+ private ActivationListener fActivationListener = new ActivationListener();
+
private ISelectionListenerWithAST fPostSelectionListenerWithAST;
+
private OccurrencesFinderJob fOccurrencesFinderJob;
+
/** The occurrences finder job canceler */
private OccurrencesFinderJobCanceler fOccurrencesFinderJobCanceler;
+
/**
* Holds the current occurrence annotations.
*
// setSourceViewerConfiguration(new
// JavaSourceViewerConfiguration(textTools.getColorManager(), store,
// this, IJavaPartitions.JAVA_PARTITIONING));
- fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
- fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
-// fMarkTypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES);
-// fMarkMethodOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES);
-// fMarkConstantOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES);
-// fMarkFieldOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES);
-// fMarkLocalVariableypeOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES);
-// fMarkExceptions= store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES);
-// fMarkImplementors= store.getBoolean(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS);
-// fMarkMethodExitPoints= store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS);
+ fMarkOccurrenceAnnotations = store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+ fStickyOccurrenceAnnotations = store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
+ // fMarkTypeOccurrences=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES);
+ // fMarkMethodOccurrences=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES);
+ // fMarkConstantOccurrences=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES);
+ // fMarkFieldOccurrences=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES);
+ // fMarkLocalVariableypeOccurrences=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES);
+ // fMarkExceptions=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES);
+ // fMarkImplementors=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_IMPLEMENTORS);
+ // fMarkMethodExitPoints=
+ // store.getBoolean(PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS);
}
* <code>true</code> if search direction is forward,
* <code>false</code> if backward
*/
- public void gotoAnnotation(boolean forward) {
+ public Annotation gotoAnnotation(boolean forward) {
ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
Position position = new Position(0, 0);
+ Annotation annotation=null;
if (false /* delayed - see bug 18316 */) {
- getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
+ annotation=getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
selectAndReveal(position.getOffset(), position.getLength());
} else /* no delay - see bug 18316 */{
- Annotation annotation = getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
+ annotation = getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
setStatusLineMessage(annotation.getText());
}
}
+ return annotation;
}
/**
if (isBrowserLikeLinks())
disableBrowserLikeLinks();
-// cancel possible running computation
- fMarkOccurrenceAnnotations= false;
+ // cancel possible running computation
+ fMarkOccurrenceAnnotations = false;
uninstallOccurrencesFinder();
uninstallOverrideIndicator();
if (fActivationListener != null) {
PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
- fActivationListener= null;
+ fActivationListener = null;
}
if (fEncodingSupport != null) {
return;
}
- boolean newBooleanValue= false;
- Object newValue= event.getNewValue();
+ boolean newBooleanValue = false;
+ Object newValue = event.getNewValue();
if (newValue != null)
- newBooleanValue= Boolean.valueOf(newValue.toString()).booleanValue();
+ newBooleanValue = Boolean.valueOf(newValue.toString()).booleanValue();
if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
if (newBooleanValue)
if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
if (newBooleanValue != fMarkOccurrenceAnnotations) {
- fMarkOccurrenceAnnotations= newBooleanValue;
+ fMarkOccurrenceAnnotations = newBooleanValue;
if (!fMarkOccurrenceAnnotations)
uninstallOccurrencesFinder();
else
}
if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
- fStickyOccurrenceAnnotations= newBooleanValue;
+ fStickyOccurrenceAnnotations = newBooleanValue;
return;
}
// }
// if (stickyOccurrenceAnnotations != fStickyOccurrenceAnnotations)
// {
-
((PHPSourceViewerConfiguration) getSourceViewerConfiguration()).handlePropertyChangeEvent(event);
// if (affectsOverrideIndicatorAnnotations(event)) {
int targetOffset = (PHPPairMatcher.RIGHT == anchor) ? offset : offset + length - 1;
boolean visible = false;
- if (sourceViewer instanceof ITextViewerExtension3) {
- ITextViewerExtension3 extension = (ITextViewerExtension3) sourceViewer;
+ if (sourceViewer instanceof ITextViewerExtension5) {
+ ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
} else {
IRegion visibleRegion = sourceViewer.getVisibleRegion();
* otherwise
* @since 3.0
*/
- private boolean isNavigationTarget(Annotation annotation) {
+ protected boolean isNavigationTarget(Annotation annotation) {
Preferences preferences = EditorsUI.getPluginPreferences();
AnnotationPreference preference = getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
// See bug 41689
List segmentation = new ArrayList();
for (int i = 0; i < linePartitioning.length; i++) {
- if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i].getType()))
+ if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i].getType())) {
segmentation.add(linePartitioning[i]);
+ } else if (IPHPPartitions.PHP_STRING_HEREDOC.equals(linePartitioning[i].getType())) {
+ segmentation.add(linePartitioning[i]);
+ }
}
if (segmentation.size() == 0)
/*
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createCompositeRuler()
*/
- protected CompositeRuler createCompositeRuler() {
+// protected CompositeRuler createCompositeRuler() {
+// if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
+// return super.createCompositeRuler();
+//
+// CompositeRuler ruler = new CompositeRuler();
+// AnnotationRulerColumn column = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
+// column.setHover(new JavaExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() {
+//
+// public void doubleClick(DoubleClickEvent event) {
+// // for now: just invoke ruler double click action
+// triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
+// }
+//
+// private void triggerAction(String actionID) {
+// IAction action = getAction(actionID);
+// if (action != null) {
+// if (action instanceof IUpdate)
+// ((IUpdate) action).update();
+// // hack to propagate line change
+// if (action instanceof ISelectionListener) {
+// ((ISelectionListener) action).selectionChanged(null, null);
+// }
+// if (action.isEnabled())
+// action.run();
+// }
+// }
+//
+// }));
+// ruler.addDecorator(0, column);
+//
+// if (isLineNumberRulerVisible())
+// ruler.addDecorator(1, createLineNumberRulerColumn());
+// else if (isPrefQuickDiffAlwaysOn())
+// ruler.addDecorator(1, createChangeRulerColumn());
+//
+// return ruler;
+// }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createAnnotationRulerColumn(org.eclipse.jface.text.source.CompositeRuler)
+ * @since 3.2
+ */
+ protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) {
if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
- return super.createCompositeRuler();
+ return super.createAnnotationRulerColumn(ruler);
- CompositeRuler ruler = new CompositeRuler();
- AnnotationRulerColumn column = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
+ AnnotationRulerColumn column= new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess());
column.setHover(new JavaExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
}
private void triggerAction(String actionID) {
- IAction action = getAction(actionID);
+ IAction action= getAction(actionID);
if (action != null) {
if (action instanceof IUpdate)
((IUpdate) action).update();
// hack to propagate line change
if (action instanceof ISelectionListener) {
- ((ISelectionListener) action).selectionChanged(null, null);
+ ((ISelectionListener)action).selectionChanged(null, null);
}
if (action.isEnabled())
action.run();
}
}));
- ruler.addDecorator(0, column);
-
- if (isLineNumberRulerVisible())
- ruler.addDecorator(1, createLineNumberRulerColumn());
- else if (isPrefQuickDiffAlwaysOn())
- ruler.addDecorator(1, createChangeRulerColumn());
-
- return ruler;
+
+ return column;
}
-
/**
* Returns the folding action group, or <code>null</code> if there is none.
*
* the compilation unit AST
* @since 3.0
*/
- protected void updateOccurrenceAnnotations(ITextSelection selection) {//, CompilationUnit astRoot) {
+ protected void updateOccurrenceAnnotations(ITextSelection selection) {// ,
+ // CompilationUnit
+ // astRoot)
+ // {
if (fOccurrencesFinderJob != null)
fOccurrencesFinderJob.cancel();
if (!fMarkOccurrenceAnnotations)
return;
-// if (astRoot == null || selection == null)
+ // if (astRoot == null || selection == null)
if (selection == null)
return;
if (document == null)
return;
+ fMarkOccurrenceTargetRegion = null;
if (document instanceof IDocumentExtension4) {
int offset = selection.getOffset();
long currentModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
fMarkOccurrenceModificationStamp = currentModificationStamp;
}
+ if (fMarkOccurrenceTargetRegion == null || fMarkOccurrenceTargetRegion.getLength() == 0) {
+ return;
+ }
+
List matches = null;
if (matches == null) {
Scanner fScanner = new Scanner();
fScanner.setSource(document.get().toCharArray());
fScanner.setPHPMode(false);
+ String wordStr;
char[] word;
- word = document.get(fMarkOccurrenceTargetRegion.getOffset(), fMarkOccurrenceTargetRegion.getLength()).toCharArray();
-
- int fToken = ITerminalSymbols.TokenNameEOF;
- try {
- fToken = fScanner.getNextToken();
- while (fToken != ITerminalSymbols.TokenNameEOF) { // && fToken !=
- // TokenNameERROR) {
- if (fToken == ITerminalSymbols.TokenNameVariable || fToken == ITerminalSymbols.TokenNameIdentifier) {
- // global variable
- if (fScanner.equalsCurrentTokenSource(word)) {
- matches.add(new Region(fScanner.getCurrentTokenStartPosition(), fScanner.getCurrentTokenEndPosition()
- - fScanner.getCurrentTokenStartPosition()+1));
+ wordStr = document.get(fMarkOccurrenceTargetRegion.getOffset(), fMarkOccurrenceTargetRegion.getLength());
+ if (wordStr != null) {
+ word = wordStr.toCharArray();
+ int fToken = ITerminalSymbols.TokenNameEOF;
+ try {
+ fToken = fScanner.getNextToken();
+ while (fToken != ITerminalSymbols.TokenNameEOF) { // && fToken !=
+ // TokenNameERROR) {
+ if (fToken == ITerminalSymbols.TokenNameVariable || fToken == ITerminalSymbols.TokenNameIdentifier) {
+ // global variable
+ if (fScanner.equalsCurrentTokenSource(word)) {
+ matches.add(new Region(fScanner.getCurrentTokenStartPosition(), fScanner.getCurrentTokenEndPosition()
+ - fScanner.getCurrentTokenStartPosition() + 1));
+ }
}
+ fToken = fScanner.getNextToken();
}
- fToken = fScanner.getNextToken();
+ } catch (InvalidInputException e) {
+ // ignore errors
+ } catch (SyntaxError e) {
+ // ignore errors
}
- } catch (InvalidInputException e) {
- // ignore errors
- } catch (SyntaxError e) {
- // ignore errors
}
-
} catch (BadLocationException e1) {
// ignore errors
+ } catch (Exception e) {
+ e.printStackTrace();
+ // ignore errors
}
}
fMarkOccurrenceAnnotations = true;
fPostSelectionListenerWithAST = new ISelectionListenerWithAST() {
- public void selectionChanged(IEditorPart part, ITextSelection selection) { //, CompilationUnit astRoot) {
- updateOccurrenceAnnotations(selection);//, astRoot);
+ public void selectionChanged(IEditorPart part, ITextSelection selection) { // ,
+ // CompilationUnit
+ // astRoot)
+ // {
+ updateOccurrenceAnnotations(selection);// , astRoot);
}
};
SelectionListenerWithASTManager.getDefault().addListener(this, fPostSelectionListenerWithAST);