From 194d4162f1423bcae7bece57227ff3d3e51f2ea4 Mon Sep 17 00:00:00 2001 From: kpouer Date: Mon, 11 Aug 2003 22:26:02 +0000 Subject: [PATCH] detection of globals on superglobals (and some warnings ...) --- .../internal/compiler/ast/GlobalStatement.java | 26 ++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) 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..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 @@ -2,11 +2,16 @@ package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; 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. @@ -89,4 +94,25 @@ public class GlobalStatement extends Statement implements Outlineable { public List getUsedVariable() { 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); + } + } + } + } } -- 1.7.1