* org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion,
* boolean)
*/
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
final PHPStructuredEditor editor = org.eclipse.php.internal.ui.util.EditorUtility
.getPHPEditor(textViewer);
if (editor == null) {
return null;
}
if (region == null) {
return null;
}
IModelElement input = EditorUtility.getEditorInputModelElement(editor,
false);
if (input == null) {
return null;
}
PHPVersion phpVersion = ProjectOptions.getPhpVersion(input
.getScriptProject().getProject());
boolean namespacesSupported = phpVersion.isGreaterThan(PHPVersion.PHP5); // PHP
// 5.3
// and
// greater
IDocument document = textViewer.getDocument();
int offset = region.getOffset();
try {
IRegion wordRegion = findWord(document, offset, namespacesSupported);
if (wordRegion == null)
return null;
try {
String text = document.get(wordRegion.getOffset(),
wordRegion.getLength());
if (text.equals(NEW)) {
return null;
}
} catch (BadLocationException e) {
}
IModelElement[] elements = null;
elements = ((ICodeAssist) input).codeSelect(wordRegion.getOffset(),
wordRegion.getLength());
if ((elements == null || elements.length == 0)
&& input instanceof ISourceModule) {
elements = PHPModelUtils.getTypeInString((ISourceModule) input,
wordRegion);
}
if (elements != null && elements.length > 0) {
final IHyperlink link;
if (elements.length == 1) {
link = new ModelElementHyperlink(wordRegion, elements[0],
new OpenAction(editor));
} else {
link = new ModelElementHyperlink(wordRegion,
new ModelElementArray(elements), new OpenAction(
editor) {
public void selectAndOpen(
IModelElement[] elements) {
if (elements == null
|| elements.length == 0) {
IEditorStatusLine statusLine = null;
if (editor != null)
statusLine = (IEditorStatusLine) editor
.getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine
.setMessage(
true,