From: khartlage Date: Wed, 13 Nov 2002 20:41:55 +0000 (+0000) Subject: first PHP parser version (doesn't work actually) X-Git-Url: http://secure.phpeclipse.com?hp=c6ec36f03b47fc0ec56f491cc703ddc5d715b8c8 first PHP parser version (doesn't work actually) --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 20ede98..5e95d2e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -43,7 +43,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin { public static final String APACHE_START_PREF = "_apache_start"; public static final String APACHE_STOP_PREF = "_apache_stop"; public static final String APACHE_RESTART_PREF = "_apache_restart"; - + public static final String SHOW_OUTPUT_IN_CONSOLE = "_sho_output_in_console"; /** * The id of the PHP plugin (value "net.sourceforge.phpeclipse"). */ @@ -222,6 +222,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin { store.setDefault(LOCALHOST_PREF, "http://localhost"); store.setDefault(USE_EXTERNAL_BROWSER_PREF, "false"); + store.setDefault(SHOW_OUTPUT_IN_CONSOLE, "true"); if (jvm == WINDOWS_9x) { store.setDefault(EXTERNAL_BROWSER_PREF, "command.com /c start iexplore {0}"); } else if (jvm == WINDOWS_NT) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java index f375331..a349d15 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPEclipseShowAction.java @@ -18,6 +18,7 @@ import java.text.MessageFormat; import java.util.Iterator; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.views.PHPConsole; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; @@ -28,7 +29,6 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; @@ -111,13 +111,16 @@ public class PHPEclipseShowAction implements IObjectActionDelegate { MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF)); Runtime runtime = Runtime.getRuntime(); - runtime.exec(form.format(arguments)); + String command = form.format(arguments); + PHPConsole.write("External Browser command: "+command+"\n"); + runtime.exec(command); // runtime.exec(store.getString(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF) + " " + fileName); // runtime.exec("command.com /c start iexplore " + fileName); } else { // MessageDialog.openInformation(shell, "localhostURL", "localhostURL: " + localhostURL); // this doesn't work under win98 ? // Program.launch(localhostURL); + PHPConsole.write("Internal Browser URL: "+localhostURL+"\n"); open(new URL(localhostURL), shell, localhostURL); } } catch (MalformedURLException e) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java index a5c461e..f67a3ca 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPRestartApacheAction.java @@ -26,6 +26,6 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; public class PHPRestartApacheAction extends PHPStartApacheAction { public void run(IAction action) { final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - execute(store.getString(PHPeclipsePlugin.APACHE_RESTART_PREF)); + execute(store.getString(PHPeclipsePlugin.APACHE_RESTART_PREF), "Restart Apache: "); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java index 7f69883..8a6b5e2 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartApacheAction.java @@ -11,52 +11,78 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.actions; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; +import java.io.InputStream; import java.text.MessageFormat; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.views.PHPConsole; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import sun.security.krb5.internal.crypto.e; public class PHPStartApacheAction implements IWorkbenchWindowActionDelegate { - protected IWorkbenchWindow activeWindow = null; - - public void run(IAction action) { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); - // replace backslash with slash in the DocumentRoot under Windows - documentRoot = documentRoot.replace('\\', '/'); - String[] arguments = { documentRoot }; - MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF)); - execute(form.format(arguments)); - } - - public void execute(String command) { -// MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); - try { - Runtime runtime = Runtime.getRuntime(); - // Process process = runtime.exec(new String[] { "c:\\apache\\apache.exe" }); - Process process = runtime.exec(command); - } catch (IOException e) { - MessageDialog.openInformation(activeWindow.getShell(), "IOException: ", e.getMessage()); - } - } - - public void selectionChanged(IAction action, ISelection selection) { - - } - - public void init(IWorkbenchWindow window) { - this.activeWindow = window; - } - - public void dispose() { - - } + protected IWorkbenchWindow activeWindow = null; + + public void run(IAction action) { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + // replace backslash with slash in the DocumentRoot under Windows + documentRoot = documentRoot.replace('\\', '/'); + String[] arguments = { documentRoot }; + MessageFormat form = new MessageFormat(store.getString(PHPeclipsePlugin.APACHE_START_PREF)); + execute(form.format(arguments), "Start Apache: "); + } + + public void execute(String command, String consoleMessage) { + // MessageDialog.openInformation(activeWindow.getShell(), "Exec command: ", command); + try { + PHPConsole.write(consoleMessage+command+"\n"); + Runtime runtime = Runtime.getRuntime(); + + // runs the command + Process p = runtime.exec(command); + + // gets the input stream to have the post-compile-time information + InputStream stream = p.getInputStream(); + + // and get the string from it + String compilerOutput = PHPConsole.getStringFromStream(stream); + + // prints out the information + PHPConsole.write(compilerOutput); + + // parse the buffer to find the errors and create markers + // createMarkers(compilerOutput, fileToCompile); + + } catch (IOException e) { + // @todo should throw the exception again + System.err.println("Problem"); + e.printStackTrace(); +// } catch (CoreException e) { +// e.printStackTrace(); +// // @todo do something here ! + } + } + + public void selectionChanged(IAction action, ISelection selection) { + + } + + public void init(IWorkbenchWindow window) { + this.activeWindow = window; + } + + public void dispose() { + + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java index 31c5586..f6e64d3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStartMySQLAction.java @@ -26,6 +26,6 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; public class PHPStartMySQLAction extends PHPStartApacheAction { public void run(IAction action) { final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - execute(store.getString(PHPeclipsePlugin.MYSQL_PREF)); + execute(store.getString(PHPeclipsePlugin.MYSQL_PREF), "Start MySQL: "); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java index 3711fcd..560069f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/actions/PHPStopApacheAction.java @@ -26,6 +26,6 @@ import org.eclipse.ui.IWorkbenchWindowActionDelegate; public class PHPStopApacheAction extends PHPStartApacheAction { public void run(IAction action) { final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - execute(store.getString(PHPeclipsePlugin.APACHE_STOP_PREF)); + execute(store.getString(PHPeclipsePlugin.APACHE_STOP_PREF), "Stop Apache: "); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java index 1fbefe5..54a3038 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java @@ -30,68 +30,74 @@ import org.eclipse.ui.texteditor.TextEditorAction; */ public class PHPActionContributor extends TextEditorActionContributor { - protected RetargetTextEditorAction fContentAssistProposal; - protected RetargetTextEditorAction fContentAssistTip; - protected TextEditorAction fTogglePresentation; - - /** - * Default constructor. - */ - public PHPActionContributor() { - super(); - fContentAssistProposal= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$ - fContentAssistTip= new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$ - fTogglePresentation= new PresentationAction(); - } - - /* - * @see IEditorActionBarContributor#init(IActionBars) - */ - public void init(IActionBars bars) { - super.init(bars); - - IMenuManager menuManager= bars.getMenuManager(); - IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); - if (editMenu != null) { - editMenu.add(new Separator()); - editMenu.add(fContentAssistProposal); - editMenu.add(fContentAssistTip); - } - - IToolBarManager toolBarManager= bars.getToolBarManager(); - if (toolBarManager != null) { - toolBarManager.add(new Separator()); - toolBarManager.add(fTogglePresentation); - } - } - - private void doSetActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - - ITextEditor editor= null; - if (part instanceof ITextEditor) - editor= (ITextEditor) part; - - fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$ - fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$ - - fTogglePresentation.setEditor(editor); - fTogglePresentation.update(); - } - - /* - * @see IEditorActionBarContributor#setActiveEditor(IEditorPart) - */ - public void setActiveEditor(IEditorPart part) { - super.setActiveEditor(part); - doSetActiveEditor(part); - } - - /* - * @see IEditorActionBarContributor#dispose() - */ - public void dispose() { - doSetActiveEditor(null); - super.dispose(); - } + protected RetargetTextEditorAction fContentAssistProposal; + protected RetargetTextEditorAction fContentAssistTip; + protected TextEditorAction fTogglePresentation; + protected PHPParserAction parserAction; + + /** + * Default constructor. + */ + public PHPActionContributor() { + super(); + fContentAssistProposal = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistProposal."); //$NON-NLS-1$ + fContentAssistTip = new RetargetTextEditorAction(PHPEditorMessages.getResourceBundle(), "ContentAssistTip."); //$NON-NLS-1$ + fTogglePresentation = new PresentationAction(); + parserAction = PHPParserAction.getInstance(); + } + + /* + * @see IEditorActionBarContributor#init(IActionBars) + */ + public void init(IActionBars bars) { + super.init(bars); + + IMenuManager menuManager = bars.getMenuManager(); + IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); + if (editMenu != null) { + editMenu.add(new Separator()); + editMenu.add(fContentAssistProposal); + editMenu.add(fContentAssistTip); + } + + IToolBarManager toolBarManager = bars.getToolBarManager(); + if (toolBarManager != null) { + toolBarManager.add(new Separator()); + toolBarManager.add(fTogglePresentation); + } + } + + private void doSetActiveEditor(IEditorPart part) { + super.setActiveEditor(part); + + ITextEditor editor = null; + if (part instanceof ITextEditor) + editor = (ITextEditor) part; + + fContentAssistProposal.setAction(getAction(editor, "ContentAssistProposal")); //$NON-NLS-1$ + fContentAssistTip.setAction(getAction(editor, "ContentAssistTip")); //$NON-NLS-1$ + + fTogglePresentation.setEditor(editor); + fTogglePresentation.update(); + + parserAction.setEditor(editor); + parserAction.update(); + } + + /* + * @see IEditorActionBarContributor#setActiveEditor(IEditorPart) + */ + public void setActiveEditor(IEditorPart part) { + super.setActiveEditor(part); + doSetActiveEditor(part); + + } + + /* + * @see IEditorActionBarContributor#dispose() + */ + public void dispose() { + doSetActiveEditor(null); + super.dispose(); + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java index 1bf4dbe..86b9977 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -41,7 +41,8 @@ import org.eclipse.ui.views.contentoutline.ContentOutlinePage; * connected PHPEditor. */ public class PHPContentOutlinePage extends ContentOutlinePage { - + private static final String ERROR = "error"; //$NON-NLS-1$ + private static final String WARNING = "warning"; //$NON-NLS-1$ /** * A segment element. */ @@ -58,10 +59,10 @@ public class PHPContentOutlinePage extends ContentOutlinePage { return name; } }; - + protected static class SegmentComparator implements Comparator { public int compare(Object o1, Object o2) { - return ((Segment)o1).name.compareToIgnoreCase(((Segment)o2).name); + return ((Segment) o1).name.compareToIgnoreCase(((Segment) o2).name); } } @@ -82,9 +83,9 @@ public class PHPContentOutlinePage extends ContentOutlinePage { StringBuffer identifier = new StringBuffer(); while (i < textLength) { c = text.charAt(i++); - if (Character.isJavaIdentifierPart(c) || (c=='$')) { + if (Character.isJavaIdentifierPart(c) || (c == '$')) { identifier.append(c); - } else if ( (i==firstIndex+1) && (c=='$')) { + } else if ((i == firstIndex + 1) && (c == '$')) { identifier.append(c); } else { return identifier.toString(); @@ -178,10 +179,10 @@ public class PHPContentOutlinePage extends ContentOutlinePage { if (functionMode && Character.isJavaIdentifierPart((char) c)) { functionMode = false; - lastIndex = i-1; + lastIndex = i - 1; identifier = getIdentifier(text, lastIndex); try { - i += identifier.length()-1; + i += identifier.length() - 1; Position p = new Position(lastIndex, i - lastIndex); document.addPosition(SEGMENTS, p); fContent.add(new Segment(text.substring(lastIndex, i), p)); @@ -195,12 +196,12 @@ public class PHPContentOutlinePage extends ContentOutlinePage { identifier = getIdentifier(text, i - 1); if (identifier.equals("function")) { functionMode = true; - i+=8; + i += 8; } } else if (c == '$') { // get the variable name identifier = getIdentifier(text, i - 1); - fVariables.add( identifier ); + fVariables.add(identifier); } } @@ -265,7 +266,7 @@ public class PHPContentOutlinePage extends ContentOutlinePage { fContent.clear(); fContent = null; } - if (fVariables != null) { + if (fVariables != null) { fVariables.clear(); fVariables = null; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index 2608187..11cf34f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -29,12 +29,12 @@ import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; - +import org.eclipse.jface.action.IAction; /** * Java specific text editor. */ public class PHPEditor extends TextEditor { - + /** The outline page */ private PHPContentOutlinePage fOutlinePage; @@ -94,6 +94,10 @@ public class PHPEditor extends TextEditor { */ public void doSave(IProgressMonitor monitor) { super.doSave(monitor); + // compile or not, according to the user preferences + IAction a = PHPParserAction.getInstance(); + if (a != null) + a.run(); if (fOutlinePage != null) fOutlinePage.update(); } @@ -166,7 +170,7 @@ public class PHPEditor extends TextEditor { // showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$ } } - + private String getFunctionName(IDocument doc, int pos) { Point word = PHPWordExtractor.findWord(doc, pos); if (word != null) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties index 0ad7081..05b94a6 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditorMessages.properties @@ -31,3 +31,8 @@ CompletionProcessor.ContextInfo.display.pattern=proposal {0} at position {1} CompletionProcessor.ContextInfo.value.pattern=proposal {0} valid from {1} to {2} CompletionProcessor.Proposal.ContextInfo.pattern={0} valid 5 characters around insertion point CompletionProcessor.Proposal.hoverinfo.pattern=Java keyword: {0} + +ParserAction.label=Parse the PHP file +ParserAction.tooltip=Parse the current PHP file +ParserAction.image=java.gif +ParserAction.description=Parse the current PHP file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java index 071cb9f..f4e6582 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java @@ -11,6 +11,10 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor; +import java.util.HashMap; + +import net.sourceforge.phpeclipse.phpeditor.php.PHPFunctionDescription; +import net.sourceforge.phpeclipse.phpeditor.php.PHPFunctionNames; import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; @@ -24,6 +28,8 @@ import org.eclipse.swt.graphics.Point; * which hovers over PHP code. */ public class PHPTextHover implements ITextHover { + public static HashMap functionDescriptions = null; + private static PHPWordExtractor phpWordDetector = new PHPWordExtractor(); /* (non-Javadoc) * Method declared on ITextHover @@ -32,7 +38,14 @@ public class PHPTextHover implements ITextHover { if (hoverRegion != null) { try { if (hoverRegion.getLength() > -1) { - return textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); + String word = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); + if (functionDescriptions==null) { + functionDescriptions = new HashMap(997); + for (int i=0; i 0) { - // try { - // char character = document.getChar(documentOffset - 1); - // if (character=='$') { - // - // } - // result = new ICompletionProposal[fgProposals.length]; - // for (int i = 0; i < fgProposals.length; i++) { - // IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ - // result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ - // } - // } catch (BadLocationException e) { - // } - // - // } else { + ArrayList arrList = new ArrayList(5); + IDocument document = viewer.getDocument(); + if (documentOffset > 0) { + try { + ICompletionProposal[] result; + char character = document.getChar(documentOffset - 1); + if (character == '$') { +//viewer. .getActivePage().getActiveEditor(); + result = new ICompletionProposal[fgProposals.length]; + for (int i = 0; i < fgProposals.length; i++) { + IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + result[i] = new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length(), null, fgProposals[i], info, MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ + } + return result; + } + } catch (BadLocationException e) { + return new ICompletionProposal[0]; + } + } + ICompletionProposal[] result = new ICompletionProposal[fgProposals.length]; for (int i = 0; i < fgProposals.length; i++) { IContextInformation info = new ContextInformation(fgProposals[i], MessageFormat.format(PHPEditorMessages.getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$ diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java index 839c350..059f56a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLWordDetector.java @@ -1,3 +1,5 @@ +package net.sourceforge.phpeclipse.phpeditor.util; + /********************************************************************** Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials @@ -9,7 +11,6 @@ Contributors: IBM Corporation - Initial implementation Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -package net.sourceforge.phpeclipse.phpeditor.util; import org.eclipse.jface.text.rules.IWordDetector;