From: khartlage Date: Mon, 23 Dec 2002 21:20:09 +0000 (+0000) Subject: ContextHelp now in new module net.sourceforge.phpeclipse.phphelp X-Git-Url: http://secure.phpeclipse.com?hp=cb2985fe5b2dcd9c2cab530d4c18760085c3465d ContextHelp now in new module net.sourceforge.phpeclipse.phphelp --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java index e73e00d..8c0d37a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java @@ -13,15 +13,12 @@ package net.sourceforge.phpeclipse.phpeditor.php; import java.util.ArrayList; import java.util.List; -import java.util.Vector; import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr; import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; import net.sourceforge.phpeclipse.phpeditor.util.PHPWhitespaceDetector; import net.sourceforge.phpeclipse.phpeditor.util.PHPWordDetector; - import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.TextAttribute; @@ -137,33 +134,35 @@ public class PHPCodeScanner extends RuleBasedScanner implements IPreferenceConst // Add word rule for keywords, types, and constants. PHPWordRule wordRule = new PHPWordRule(new PHPWordDetector(), other); - //choochter--> - for (int i = 0; i < PHPKeywords.PHP_KEYWORS.length; i++) - wordRule.addWord(PHPKeywords.PHP_KEYWORS[i], keyword); - - /*Read in the keywords from the XML file*/ - PHPSyntaxRdr syntaxRdr = new PHPSyntaxRdr(); - syntaxRdr.readFromFile( - "C:\\eclipse\\workspace\\net.sourceforge.phpeclipse\\src\\net\\sourceforge\\phpeclipse\\phpeditor" - + java.io.File.separator - + "syntax.xml"); - { - Vector Vbuffer = syntaxRdr.getKeywords(); - String VString = null; - //Read keywords - while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { - wordRule.addWord(VString, keyword); - } - //Read functions - to be tested - Vbuffer = syntaxRdr.getFunctions(); - while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { - wordRule.addWord(VString, functionName); - } - } - - //for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) - // wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); - //<--choochter +// //choochter--> +// for (int i = 0; i < PHPKeywords.PHP_KEYWORS.length; i++) +// wordRule.addWord(PHPKeywords.PHP_KEYWORS[i], keyword); +// +// /*Read in the keywords from the XML file*/ +// PHPSyntaxRdr syntaxRdr = new PHPSyntaxRdr(); +// syntaxRdr.readFromFile( +// "C:\\eclipse\\workspace\\net.sourceforge.phpeclipse\\src\\net\\sourceforge\\phpeclipse\\phpeditor" +// + java.io.File.separator +// + "syntax.xml"); +// { +// Vector Vbuffer = syntaxRdr.getKeywords(); +// String VString = null; +// //Read keywords +// while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { +// wordRule.addWord(VString, keyword); +// } +// //Read functions - to be tested +// Vbuffer = syntaxRdr.getFunctions(); +// while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { +// wordRule.addWord(VString, functionName); +// } +// } +// +// //for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) +// // wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); +// //<--choochter + for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) + wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); for (int i = 0; i < fgConstants.length; i++) wordRule.addWord(fgConstants[i], functionName); rules.add(wordRule); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPClassDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPClassDeclaration.java new file mode 100644 index 0000000..2f13dfb --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPClassDeclaration.java @@ -0,0 +1,57 @@ +package net.sourceforge.phpeclipse.phpeditor.phpparser; + +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import org.eclipse.jface.resource.ImageDescriptor; +/** + * + * @author khartlage + */ +public class PHPClassDeclaration extends PHPSegment { + ArrayList fFunctions; + + public PHPClassDeclaration(Object parent, String name, int index) { + super(parent, name, index); + fFunctions = new ArrayList(); + } + + public List getList( ) { + return fFunctions; + } + /** + * Appends the specified function declaration + * + * @param o function declaration to be appended to this list. + * @return true (as per the general contract of Collection.add). + */ + public boolean add(PHPSegment o) { + return fFunctions.add(o); + } + + /** + * Returns the function declaration at the specified position in this list. + * + * @param index index of function declaration to return. + * @return the function declaration at the specified position in this list. + * @throws IndexOutOfBoundsException if index is out of range (index + * < 0 || index >= size()). + */ + public PHPSegment get(int index) { + return (PHPSegment) fFunctions.get(index); + } + + /** + * Returns the number of declarations in this list. + * + * @return the number of declarations in this list. + */ + public int size() { + return fFunctions.size(); + } + + public ImageDescriptor getImage() { + return PHPUiImages.DESC_CLASS; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPFunctionDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPFunctionDeclaration.java new file mode 100644 index 0000000..ca6114d --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPFunctionDeclaration.java @@ -0,0 +1,20 @@ +package net.sourceforge.phpeclipse.phpeditor.phpparser; + +import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * + * @author khartlage + */ +public class PHPFunctionDeclaration extends PHPSegment { + + + public PHPFunctionDeclaration(Object parent, String name, int index) { + super(parent, name, index); + } + + public ImageDescriptor getImage() { + return PHPUiImages.DESC_FUN; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPOutlineInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPOutlineInfo.java new file mode 100644 index 0000000..b46f68a --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPOutlineInfo.java @@ -0,0 +1,34 @@ +package net.sourceforge.phpeclipse.phpeditor.phpparser; + +import java.util.TreeMap; +import java.util.TreeSet; + +/** + * + * @author khartlage + */ +public class PHPOutlineInfo { + TreeSet fVariables; + PHPClassDeclaration fDeclarations; + + public PHPOutlineInfo(Object parent) { + fVariables = new TreeSet(); + fDeclarations = new PHPClassDeclaration(parent, "_root", 1); + } + + public TreeSet getVariables() { + return fVariables; + } + + public PHPClassDeclaration getDeclarations() { + return fDeclarations; + } + + public boolean add(PHPFunctionDeclaration o) { + return fDeclarations.add(o); + } + + public boolean addVariable(String variable) { + return fVariables.add(variable); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegment.java new file mode 100644 index 0000000..9e387f4 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegment.java @@ -0,0 +1,34 @@ +package net.sourceforge.phpeclipse.phpeditor.phpparser; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; + +/** + * + * @author khartlage + */ +public abstract class PHPSegment { + private String name; + private Position position; + private Object parent; + + public PHPSegment(Object parent, String name, int index) { + this.parent = parent; + this.name = name; + this.position = new Position(index, name.length()); + } + + public String toString() { + return name; + } + + public Position getPosition() { + return position; + } + + public Object getParent() { + return parent; + } + + public abstract ImageDescriptor getImage(); +}; \ No newline at end of file