From: Matthieu C. <kp...@us...> - 2006-03-06 15:49:52
|
Update of /cvsroot/jedit/plugins/PHPParser/src/net/sourceforge/phpdt/internal/compiler/ast In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29458 Modified Files: MethodHeader.java Log Message: better modifiers parsing Index: MethodHeader.java =================================================================== RCS file: /cvsroot/jedit/plugins/PHPParser/src/net/sourceforge/phpdt/internal/compiler/ast/MethodHeader.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- MethodHeader.java 17 May 2005 21:52:17 -0000 1.7 +++ MethodHeader.java 6 Mar 2006 15:49:49 -0000 1.8 @@ -1,6 +1,5 @@ package net.sourceforge.phpdt.internal.compiler.ast; -import gatchan.phpparser.parser.PHPParserConstants; import gatchan.phpparser.parser.PHPParser; import gatchan.phpparser.project.itemfinder.PHPItem; import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage; @@ -11,172 +10,190 @@ import java.util.List; /** @author Matthieu Casanova */ -public class MethodHeader extends Statement implements PHPItem, Serializable { - /** The path of the file containing this class. */ - private String path; - - /** The name of the method. */ - private String name; +public class MethodHeader extends Statement implements PHPItem, Serializable +{ + private List modifiers; + /** The path of the file containing this class. */ + private String path; - /** Indicate if the method returns a reference. */ - private boolean reference; + /** The name of the method. */ + private String name; - /** The arguments. */ - private List arguments; + /** Indicate if the method returns a reference. */ + private boolean reference; - private String cachedToString; + /** The arguments. */ + private List arguments; - private transient Icon icon; + private String cachedToString; - private int visibility = PHPParserConstants.PUBLIC; - private String nameLowerCase; + private transient Icon icon; - public MethodHeader() { - } + private String nameLowerCase; - public MethodHeader(String path, - String name, - boolean reference, - List arguments, - int sourceStart, - int sourceEnd, - int beginLine, - int endLine, - int beginColumn, - int endColumn) { - this(PHPParserConstants.PUBLIC, - path, - name, - reference, - arguments, - sourceStart, - sourceEnd, - beginLine, - endLine, - beginColumn, - endColumn); - } + public MethodHeader() + { + } - public MethodHeader(int visibility, - String path, - String name, - boolean reference, - List arguments, - int sourceStart, - int sourceEnd, - int beginLine, - int endLine, - int beginColumn, - int endColumn) { - super(sourceStart, sourceEnd, beginLine, endLine, beginColumn, endColumn); - this.visibility = visibility; - this.path = path; - this.name = name; - this.reference = reference; - this.arguments = arguments; - } + public MethodHeader(String path, + String name, + boolean reference, + List arguments, + int sourceStart, + int sourceEnd, + int beginLine, + int endLine, + int beginColumn, + int endColumn) + { + this(path, + null, + name, + reference, + arguments, + sourceStart, + sourceEnd, + beginLine, + endLine, + beginColumn, + endColumn); + } - public String getName() { - return name; - } + public MethodHeader(String path, + List modifiers, + String name, + boolean reference, + List arguments, + int sourceStart, + int sourceEnd, + int beginLine, + int endLine, + int beginColumn, + int endColumn) + { + super(sourceStart, sourceEnd, beginLine, endLine, beginColumn, endColumn); + this.modifiers = modifiers; + this.path = path; + this.name = name; + this.reference = reference; + this.arguments = arguments; + } - public String getNameLowerCase() { - if (nameLowerCase == null) { - nameLowerCase = name.toLowerCase(); + public String getName() + { + return name; } - return nameLowerCase; - } - public String toString() { - if (cachedToString == null) { - StringBuffer buff = new StringBuffer(100); - if (reference) buff.append('&'); - buff.append(name); - buff.append('('); - if (arguments != null) { - for (int i = 0; i < arguments.size(); i++) { - FormalParameter o = (FormalParameter) arguments.get(i); - buff.append(o.toStringExpression()); - if (i != (arguments.size() - 1)) { - buff.append(", "); - } + public String getNameLowerCase() + { + if (nameLowerCase == null) + { + nameLowerCase = name.toLowerCase(); } - } - buff.append(')'); - cachedToString = buff.toString(); + return nameLowerCase; } - return cachedToString; - } - public String toString(int tab) { - return tabString(tab) + toString(); - } + public String toString() + { + if (cachedToString == null) + { + StringBuffer buff = new StringBuffer(100); + if (reference) buff.append('&'); + buff.append(name); + buff.append('('); + if (arguments != null) + { + for (int i = 0; i < arguments.size(); i++) + { + FormalParameter o = (FormalParameter) arguments.get(i); + buff.append(o.toStringExpression()); + if (i != (arguments.size() - 1)) + { + buff.append(", "); + } + } + } + buff.append(')'); + cachedToString = buff.toString(); + } + return cachedToString; + } - public void getOutsideVariable(List list) { - } + public String toString(int tab) + { + return tabString(tab) + toString(); + } - public void getModifiedVariable(List list) { - } + public void getOutsideVariable(List list) + { + } - public void getUsedVariable(List list) { - } + public void getModifiedVariable(List list) + { + } - public int getArgumentsCount() { - return arguments.size(); - } + public void getUsedVariable(List list) + { + } - public void getParameters(List list) { - if (arguments != null) { - for (int i = 0; i < arguments.size(); i++) { - FormalParameter variable = (FormalParameter) arguments.get(i); - VariableUsage variableUsage = new VariableUsage(Type.UNKNOWN, - variable.getName(), - variable.getSourceStart(), - variable.getSourceEnd(), - variable.getBeginLine(), - variable.getEndLine(), - variable.getBeginColumn(), - variable.getEndColumn()); - list.add(variableUsage); - } + public int getArgumentsCount() + { + return arguments.size(); } - } - public String getPath() { - return path; - } + public void getParameters(List list) + { + if (arguments != null) + { + for (int i = 0; i < arguments.size(); i++) + { + FormalParameter variable = (FormalParameter) arguments.get(i); + VariableUsage variableUsage = new VariableUsage(Type.UNKNOWN, + variable.getName(), + variable.getSourceStart(), + variable.getSourceEnd(), + variable.getBeginLine(), + variable.getEndLine(), + variable.getBeginColumn(), + variable.getEndColumn()); + list.add(variableUsage); + } + } + } - public int getItemType() { - return METHOD; - } + public String getPath() + { + return path; + } - public Icon getIcon() { - if (icon == null) { - icon = GUIUtilities.loadIcon(MethodHeader.class.getResource("/gatchan/phpparser/icons/method.png").toString()); + public int getItemType() + { + return METHOD; } - return icon; - } - /** - * Returns the visibility of the method. - * - * @return the visibility ({@link PHPParserConstants#PUBLIC}, {@link PHPParserConstants#PROTECTED} or {@link - * PHPParserConstants#PRIVATE}) - */ - public int getVisibility() { - return visibility; - } + public Icon getIcon() + { + if (icon == null) + { + icon = GUIUtilities.loadIcon(MethodHeader.class.getResource("/gatchan/phpparser/icons/method.png").toString()); + } + return icon; + } - public Expression expressionAt(int line, int column) { - if (arguments != null) { - for (int i = 0; i < arguments.size(); i++) { - FormalParameter formalParameter = (FormalParameter) arguments.get(i); - if (formalParameter.isAt(line, column)) return formalParameter; - } + public Expression expressionAt(int line, int column) + { + if (arguments != null) + { + for (int i = 0; i < arguments.size(); i++) + { + FormalParameter formalParameter = (FormalParameter) arguments.get(i); + if (formalParameter.isAt(line, column)) return formalParameter; + } + } + return null; } - return null; - } - public void analyzeCode(PHPParser parser) { - } + public void analyzeCode(PHPParser parser) + { + } } |