* but in switch-case it's recommended to avoid
* accidental fall-through later when editing the code
*/
- problemReporter.unreachableCode(new String(scanner
- .getCurrentIdentifierSource()),
- statement.sourceStart, statement.sourceEnd,
- referenceContext,
- compilationUnit.compilationResult);
+ problemReporter
+ .unreachableCode(
+ new String(scanner
+ .getCurrentIdentifierSource()),
+ statement.sourceStart,
+ statement.sourceEnd, referenceContext,
+ compilationUnit.compilationResult);
}
}
if ((token == TokenNameRBRACE) || (token == TokenNamecase)
getNextToken();
}
return statement;
- } else if(token == TokenNameconst){
+ } else if (token == TokenNameconst) {
+ // TODO make sure you clean this hack up ed_mann.
getNextToken();
- if(token == TokenNameIdentifier){
+ if (token == TokenNameIdentifier) {
getNextToken();
- if(token == TokenNameEQUAL){
+ if (token == TokenNameEQUAL) {
getNextToken();
}
- //throwSyntaxError("'Ed i know your here");
}
} else if (token == TokenNamestatic) {
getNextToken();
// | '$' '{' expr '}'
if (token == TokenNameVariable) {
if (fMethodVariables != null) {
- VariableInfo info = new VariableInfo(scanner
- .getCurrentTokenStartPosition(),
+ VariableInfo info = new VariableInfo(
+ scanner.getCurrentTokenStartPosition(),
VariableInfo.LEVEL_GLOBAL_VAR);
- fMethodVariables.put(new String(scanner
- .getCurrentIdentifierSource()), info);
+ fMethodVariables.put(
+ new String(scanner.getCurrentIdentifierSource()), info);
}
addVariableSet(set);
getNextToken();
while (true) {
if (token == TokenNameVariable) {
if (fMethodVariables != null) {
- VariableInfo info = new VariableInfo(scanner
- .getCurrentTokenStartPosition(),
+ VariableInfo info = new VariableInfo(
+ scanner.getCurrentTokenStartPosition(),
VariableInfo.LEVEL_STATIC_VAR);
- fMethodVariables.put(new String(scanner
- .getCurrentIdentifierSource()), info);
+ fMethodVariables.put(
+ new String(scanner.getCurrentIdentifierSource()),
+ info);
}
addVariableSet(set);
getNextToken();
if (token == TokenNameIdentifier || token > TokenNameKEYWORD) {
typeDecl.name = scanner.getCurrentIdentifierSource();
if (token > TokenNameKEYWORD) {
- problemReporter.phpKeywordWarning(new String[] { scanner
- .toStringAction(token) }, scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition(), referenceContext,
- compilationUnit.compilationResult);
+ problemReporter
+ .phpKeywordWarning(new String[] { scanner
+ .toStringAction(token) }, scanner
+ .getCurrentTokenStartPosition(), scanner
+ .getCurrentTokenEndPosition(),
+ referenceContext,
+ compilationUnit.compilationResult);
// throwSyntaxError("Don't use a keyword for interface
// declaration ["
// + scanner.toStringAction(token) + "].",
if (token == TokenNameIdentifier || token > TokenNameKEYWORD) {
typeDecl.name = scanner.getCurrentIdentifierSource();
if (token > TokenNameKEYWORD) {
- problemReporter.phpKeywordWarning(new String[] { scanner
- .toStringAction(token) }, scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition(), referenceContext,
- compilationUnit.compilationResult);
+ problemReporter
+ .phpKeywordWarning(new String[] { scanner
+ .toStringAction(token) }, scanner
+ .getCurrentTokenStartPosition(), scanner
+ .getCurrentTokenEndPosition(),
+ referenceContext,
+ compilationUnit.compilationResult);
// throwSyntaxError("Don't use a keyword for class
// declaration [" +
// scanner.toStringAction(token) + "].",
if (token == TokenNamevar) {
checkAndSetModifiers(AccPublic);
- problemReporter.phpVarDeprecatedWarning(scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition(), referenceContext,
+ problemReporter.phpVarDeprecatedWarning(
+ scanner.getCurrentTokenStartPosition(),
+ scanner.getCurrentTokenEndPosition(), referenceContext,
compilationUnit.compilationResult);
getNextToken();
class_variable_declaration(declarationSourceStart, list);
if (token != TokenNameIdentifier) {
throwSyntaxError("Identifier expected in class const declaration.");
}
- FieldDeclaration fieldDeclaration = new FieldDeclaration(scanner
- .getCurrentIdentifierSource(), scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition());
+ FieldDeclaration fieldDeclaration = new FieldDeclaration(
+ scanner.getCurrentIdentifierSource(),
+ scanner.getCurrentTokenStartPosition(),
+ scanner.getCurrentTokenEndPosition());
fieldDeclaration.modifiers = this.modifiers;
fieldDeclaration.declarationSourceStart = declarationSourceStart;
fieldDeclaration.declarationSourceEnd = scanner
fieldDeclaration.modifiersSourceStart = declarationSourceStart;
list.add(fieldDeclaration);
if (fTypeVariables != null) {
- VariableInfo info = new VariableInfo(scanner
- .getCurrentTokenStartPosition(),
+ VariableInfo info = new VariableInfo(
+ scanner.getCurrentTokenStartPosition(),
VariableInfo.LEVEL_CLASS_UNIT);
- fTypeVariables.put(new String(scanner
- .getCurrentIdentifierSource()), info);
+ fTypeVariables.put(
+ new String(scanner.getCurrentIdentifierSource()),
+ info);
}
getNextToken();
if (token == TokenNameEQUAL) {
typeDecl.methods = new AbstractMethodDeclaration[] { methodDecl };
} else {
AbstractMethodDeclaration[] newMethods;
- System
- .arraycopy(
- typeDecl.methods,
- 0,
- newMethods = new AbstractMethodDeclaration[typeDecl.methods.length + 1],
- 0, typeDecl.methods.length);
+ System.arraycopy(
+ typeDecl.methods,
+ 0,
+ newMethods = new AbstractMethodDeclaration[typeDecl.methods.length + 1],
+ 0, typeDecl.methods.length);
newMethods[typeDecl.methods.length] = methodDecl;
typeDecl.methods = newMethods;
}
if (Scanner.isIdentifierOrKeyword(token)) {
methodDecl.selector = scanner.getCurrentIdentifierSource();
if (token > TokenNameKEYWORD) {
- problemReporter.phpKeywordWarning(new String[] { scanner
- .toStringAction(token) }, scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition(), referenceContext,
+ problemReporter.phpKeywordWarning(
+ new String[] { scanner.toStringAction(token) },
+ scanner.getCurrentTokenStartPosition(),
+ scanner.getCurrentTokenEndPosition(), referenceContext,
compilationUnit.compilationResult);
}
getNextToken();
if (fMethodVariables != null) {
VariableInfo info;
if (methodDecl.type == MethodDeclaration.FUNCTION_DEFINITION) {
- info = new VariableInfo(scanner
- .getCurrentTokenStartPosition(),
+ info = new VariableInfo(
+ scanner.getCurrentTokenStartPosition(),
VariableInfo.LEVEL_FUNCTION_DEFINITION);
} else {
- info = new VariableInfo(scanner
- .getCurrentTokenStartPosition(),
+ info = new VariableInfo(
+ scanner.getCurrentTokenStartPosition(),
VariableInfo.LEVEL_METHOD_DEFINITION);
}
info.typeIdentifier = typeIdentifier;
- fMethodVariables.put(new String(scanner
- .getCurrentIdentifierSource()), info);
+ fMethodVariables
+ .put(new String(scanner
+ .getCurrentIdentifierSource()), info);
}
addVariableSet(set);
getNextToken();
case TokenNameconst:
internal_functions_in_yacc();
break;
- // | '(' expr ')'
case TokenNameLPAREN:
getNextToken();
expr();
// }
// break;
case TokenNameStringDoubleQuote:
- expression = new StringLiteralDQ(scanner
- .getCurrentStringLiteralSource(), scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition());
+ expression = new StringLiteralDQ(
+ scanner.getCurrentStringLiteralSource(),
+ scanner.getCurrentTokenStartPosition(),
+ scanner.getCurrentTokenEndPosition());
common_scalar();
break;
case TokenNameStringSingleQuote:
- expression = new StringLiteralSQ(scanner
- .getCurrentStringLiteralSource(), scanner
- .getCurrentTokenStartPosition(), scanner
- .getCurrentTokenEndPosition());
+ expression = new StringLiteralSQ(
+ scanner.getCurrentStringLiteralSource(),
+ scanner.getCurrentTokenStartPosition(),
+ scanner.getCurrentTokenEndPosition());
common_scalar();
break;
case TokenNameIntegerLiteral:
int pos = scanner.currentPosition;
getNextToken();
if (token == TokenNamePAAMAYIM_NEKUDOTAYIM) {
- // Not terminated by T_STRING, reduce to dynamic_class_name_reference
+ // Not terminated by T_STRING, reduce to
+ // dynamic_class_name_reference
scanner.currentPosition = pos;
token = TokenNameIdentifier;
ref = null;
addVariableSet();
}
}
- FieldReference ref = new FieldReference(scanner
- .getCurrentIdentifierSource(), scanner
- .getCurrentTokenStartPosition());
+ FieldReference ref = new FieldReference(
+ scanner.getCurrentIdentifierSource(),
+ scanner.getCurrentTokenStartPosition());
getNextToken();
return ref;
} else {
break;
}
}
-
+
/**
* parse and check the namespace name
+ *
* @since 1.2.3
* @param namespaceToken
*/
- private void checkNameSpaceName(){
+ private void checkNameSpaceName() {
getNextToken();
- while (true) {
- if (token == TokenNameSEMICOLON) {
- break;
- }
+ while (true) {
+ if (token == TokenNameForwardSlash || token == TokenNameIdentifier) {
getNextToken();
+ } else {
+ break;
}
-
+ }
+ if (token != TokenNameSEMICOLON) {
+ throwSyntaxError("';' expected after keyword '"
+ + scanner.toStringAction(TokenNameNamespace) + "'");
+ }
+
}
+
/**
* Parse and check the include file name
*
StringLiteral literal = (StringLiteral) expression;
char[] includeName = literal.source();
if (includeName.length == 0) {
- reportSyntaxError("Empty filename after keyword '"
- + scanner.toStringAction(includeToken) + "'",
+ reportSyntaxError(
+ "Empty filename after keyword '"
+ + scanner.toStringAction(includeToken) + "'",
literal.sourceStart, literal.sourceStart + 1);
}
String includeNameString = new String(includeName);
IFile f = PHPFileUtil.createFile(path, project);
- impt.tokens = CharOperation.splitOn('/', filePath
- .toCharArray(), 0, filePath.length()
- - fileExtensionLength);
+ impt.tokens = CharOperation.splitOn('/',
+ filePath.toCharArray(), 0,
+ filePath.length() - fileExtensionLength);
impt.setFile(f);
} catch (Exception e) {
// the file is outside of the workspace
// create a package name similar to java package names
String projectPath = ProjectPrefUtil.getDocumentRoot(file.getProject())
.toString();
- String filePath = file.getFullPath().toString();
-
- String ext = file.getFileExtension();
- int fileExtensionLength = ext == null ? 0 : ext.length() + 1;
- ImportReference impt;
- char[][] tokens;
+ String filePath = file.getFullPath().toString();
+
+ String ext = file.getFileExtension();
+ int fileExtensionLength = ext == null ? 0 : ext.length() + 1;
+ ImportReference impt;
+ char[][] tokens;
if (filePath.startsWith(projectPath)) {
tokens = CharOperation.splitOn('/', filePath.toCharArray(),
projectPath.length() + 1, filePath.length()