X-Git-Url: http://secure.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 af63ccb..8dce333 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,12 +1,16 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import java.util.List; + import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Position; -import java.util.List; -import java.util.ArrayList; +import test.PHPParserSuperclass; /** * A GlobalStatement statement in php. @@ -64,29 +68,43 @@ public class GlobalStatement extends Statement implements Outlineable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(variables.length); + public void getOutsideVariable(final List list) { for (int i = 0; i < variables.length; i++) { - list.addAll(variables[i].getUsedVariable()); + variables[i].getUsedVariable(list); } - return list; } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { + } + + /** + * 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); + } + } + } } }