X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java index d50bafe..bb09275 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java @@ -1,13 +1,17 @@ package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; -import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage; import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Position; +import org.eclipse.core.runtime.CoreException; import java.util.List; import java.util.ArrayList; +import java.util.Arrays; + +import test.PHPParserSuperclass; /** * A GlobalStatement statement in php. @@ -16,14 +20,14 @@ import java.util.ArrayList; public class GlobalStatement extends Statement implements Outlineable { /** An array of the variables called by this global statement. */ - public String[] variables; + public AbstractVariable[] variables; private Object parent; private Position position; public GlobalStatement(final Object parent, - final String[] variables, + final AbstractVariable[] variables, final int sourceStart, final int sourceEnd) { super(sourceStart, sourceEnd); @@ -38,7 +42,7 @@ public class GlobalStatement extends Statement implements Outlineable { if (i != 0) { buff.append(", ");//$NON-NLS-1$ } - buff.append(variables[i]); + buff.append(variables[i].toStringExpression()); } return buff.toString(); } @@ -70,7 +74,7 @@ public class GlobalStatement extends Statement implements Outlineable { public List getOutsideVariable() { final ArrayList list = new ArrayList(variables.length); for (int i = 0; i < variables.length; i++) { - list.add(new VariableUsage(variables[i],sourceStart)); + list.addAll(variables[i].getUsedVariable()); } return list; } @@ -80,7 +84,7 @@ public class GlobalStatement extends Statement implements Outlineable { * @return the variables modified */ public List getModifiedVariable() { - return new ArrayList(); + return new ArrayList(1); } /** @@ -88,6 +92,27 @@ public class GlobalStatement extends Statement implements Outlineable { * @return the variables used */ public List getUsedVariable() { - return new ArrayList(); + return new ArrayList(1); + } + + /** + * We will analyse the code. + * if we have in globals a special variable it will be reported as a warning. + * @see Variable#SPECIAL_VARS + */ + public void analyzeCode() { + for (int i = 0; i < variables.length; i++) { + if (arrayContains(Variable.SPECIAL_VARS, variables[i].getName())) { + try { + PHPParserSuperclass.setMarker("warning, you shouldn't request " + variables[i].getName() + " as global", + variables[i].sourceStart, + variables[i].sourceEnd, + PHPParserSuperclass.WARNING, + ""); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + } } }