Fixed Bug<a href="http://sourceforge.net/tracker/?func=detail&atid=484801&aid=1145683...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / template / php / CodeTemplateContext.java
index 6d3d3a6..196da16 100644 (file)
@@ -1,10 +1,10 @@
 /*******************************************************************************
  * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
+ * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/cpl-v10.html
- * 
+ *
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
@@ -28,7 +28,7 @@ import org.eclipse.jface.text.templates.TemplateTranslator;
 import org.eclipse.jface.text.templates.TemplateVariableResolver;
 
 public class CodeTemplateContext extends TemplateContext {
-       
+
        private String fLineDelimiter;
        private IJavaProject fProject;
 
@@ -57,16 +57,16 @@ public class CodeTemplateContext extends TemplateContext {
 
                if (!canEvaluate(template))
                        return null;
-                       
+
                String pattern= changeLineDelimiter(template.getPattern(), fLineDelimiter);
-               
+
                TemplateTranslator translator= new TemplateTranslator();
                TemplateBuffer buffer= translator.translate(pattern);
                getContextType().resolve(buffer, this);
 
                return buffer;
        }
-       
+
        private static String changeLineDelimiter(String code, String lineDelim) {
                try {
                        ILineTracker tracker= new DefaultLineTracker();
@@ -75,7 +75,7 @@ public class CodeTemplateContext extends TemplateContext {
                        if (nLines == 1) {
                                return code;
                        }
-                       
+
                        StringBuffer buf= new StringBuffer();
                        for (int i= 0; i < nLines; i++) {
                                if (i != 0) {
@@ -90,7 +90,7 @@ public class CodeTemplateContext extends TemplateContext {
                        // can not happen
                        return code;
                }
-       }               
+       }
 
        /* (non-Javadoc)
         * @see net.sourceforge.phpdt.internal.corext.template.TemplateContext#canEvaluate(net.sourceforge.phpdt.internal.corext.template.Template)
@@ -98,14 +98,15 @@ public class CodeTemplateContext extends TemplateContext {
        public boolean canEvaluate(Template template) {
                return true;
        }
-       
+
        public void setCompilationUnitVariables(ICompilationUnit cu) {
                setVariable(CodeTemplateContextType.FILENAME, cu.getElementName());
                setVariable(CodeTemplateContextType.PACKAGENAME, cu.getParent().getElementName());
                setVariable(CodeTemplateContextType.PROJECTNAME, cu.getJavaProject().getElementName());
        }
 
-       public void setFileNameVariable(String filename) {
+       public void setFileNameVariable(String filename, String projectname) {
                setVariable(CodeTemplateContextType.FILENAME, filename);
+               setVariable(CodeTemplateContextType.PROJECTNAME, projectname);
        }
 }