From 50b90a0dd6ab53f560526ba05a6e8fc0f0bb7bc2 Mon Sep 17 00:00:00 2001 From: khartlage Date: Wed, 15 Oct 2003 20:08:25 +0000 Subject: [PATCH] Deleted tooltips "empty selection" behaviour --- .../phpdt/core/compiler/ITerminalSymbols.java | 1 + .../phpdt/internal/compiler/parser/Parser.java | 85 +++++++++++++------- .../phpeclipse/phpeditor/PHPTextHover.java | 4 +- .../phpeclipse/wizards/PHPFileWizard.java | 2 +- 4 files changed, 60 insertions(+), 32 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java index 86883a8..4c77716 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/compiler/ITerminalSymbols.java @@ -23,6 +23,7 @@ public interface ITerminalSymbols { public final static String[] PHP_TYPES = { + "array", "string", "object", "bool", diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 6cb4c91..901eb1e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -939,7 +939,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { private void statementList() throws CoreException { do { - statement(); + statement(TokenNameEOF); if ((token == TokenNameRBRACE) || (token == TokenNamecase) || (token == TokenNamedefault) @@ -974,33 +974,42 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } } - private void statement() throws CoreException { + private void statement(int previousToken) throws CoreException { // if (token > TokenNameKEYWORD && token != TokenNamelist && token != TokenNamenew) { // char[] ident = scanner.getCurrentIdentifierSource(); // String keyword = new String(ident); if (token == TokenNameinclude || token == TokenNameinclude_once) { getNextToken(); - expression(); - if (token == TokenNameSEMICOLON) { - getNextToken(); - } else { - if (token != TokenNameStopPHP) { - throwSyntaxError("';' character after 'include' or 'include_once' expected."); + if (token == TokenNameLPAREN) { + expression(); + if (token == TokenNameSEMICOLON) { + getNextToken(); + } else { + if (previousToken != TokenNameAT && token != TokenNameStopPHP) { + throwSyntaxError("';' expected after 'include' or 'include_once'."); + } + // getNextToken(); } - getNextToken(); + } else { + concatenationExpression(); } + return; } else if (token == TokenNamerequire || token == TokenNamerequire_once) { getNextToken(); //constant(); - expression(); - if (token == TokenNameSEMICOLON) { - getNextToken(); - } else { - if (token != TokenNameStopPHP) { - throwSyntaxError("';' character after 'require' or 'require_once' expected."); + if (token == TokenNameLPAREN) { + expression(); + if (token == TokenNameSEMICOLON) { + getNextToken(); + } else { + if (previousToken != TokenNameAT && token != TokenNameStopPHP) { + throwSyntaxError("';' expected after 'require' or 'require_once'."); + } + // getNextToken(); } - getNextToken(); + } else { + concatenationExpression(); } return; } else if (token == TokenNameif) { @@ -1611,7 +1620,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { getNextToken(); } else { // statement [else-statement] - statement(); + statement(TokenNameEOF); if (token == TokenNameelseif) { getNextToken(); if (token == TokenNameLPAREN) { @@ -1628,7 +1637,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { ifStatement(); } else if (token == TokenNameelse) { getNextToken(); - statement(); + statement(TokenNameEOF); } } } @@ -1723,7 +1732,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } getNextToken(); } else { - statement(); + statement(TokenNameEOF); } } @@ -1741,7 +1750,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } getNextToken(); } else { - statement(); + statement(TokenNameEOF); } } @@ -1758,7 +1767,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } getNextToken(); } else { - statement(); + statement(TokenNameEOF); } } @@ -1813,6 +1822,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { // String ident; char[] ident; boolean castFlag = false; + boolean arrayFlag = false; switch (token) { case TokenNamenew : getNextToken(); @@ -1837,6 +1847,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { break; case TokenNameLPAREN : getNextToken(); + if (token == TokenNameIdentifier) { // check if identifier is a type: // ident = identifier; @@ -1845,20 +1856,34 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { for (int i = 0; i < PHP_TYPES.length; i++) { if (PHP_TYPES[i].equals(str)) { castFlag = true; + if (PHP_TYPES[i].equals("array")) { + arrayFlag = true; + } break; } } - if (castFlag) { + } + + if (castFlag) { + getNextToken(); + if (arrayFlag && token == TokenNameLPAREN) { getNextToken(); - if (token != TokenNameRPAREN) { - throwSyntaxError(") expected after cast-type '" + str + "'."); + if (token == TokenNameRPAREN) { + getNextToken(); + } else { + expression(); + if (token != TokenNameRPAREN) { + throwSyntaxError(") expected after 'array('."); + } } - getNextToken(); - expression(); - break; } - } - if (!castFlag) { + if (token != TokenNameRPAREN) { + throwSyntaxError(") expected after cast-type '" + str + "'."); + } + getNextToken(); + expression(); + break; + } else { expression(); } if (token != TokenNameRPAREN) { @@ -2114,7 +2139,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { || token == TokenNameinclude_once || token == TokenNamerequire || token == TokenNamerequire_once) { - statement(); + statement(TokenNameAT); } else { postfixExpression(); // castExpression(); } 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 02a3c70..32d7e9b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java @@ -104,7 +104,9 @@ public class PHPTextHover implements ITextHover { } catch (Exception x) { } } - return "empty selection"; + return null; + // don't show this annoying text +// return "empty selection"; } /* (non-Javadoc) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/PHPFileWizard.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/PHPFileWizard.java index 992f064..572bf4c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/PHPFileWizard.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/PHPFileWizard.java @@ -153,7 +153,7 @@ public class PHPFileWizard extends Wizard implements INewWizard { final int precLastDot = fileName.lastIndexOf('.',lastDot-1); if (precLastDot == -1) return null; if (!fileName.substring(precLastDot+1,lastDot).toUpperCase().equals("CLASS")) return null; - return fileName.substring(0,precLastDot-1); + return fileName.substring(0,precLastDot); } /** -- 1.7.1