code-template needs new context type
authorjsurfer <jsurfer>
Sat, 25 Sep 2004 22:39:28 +0000 (22:39 +0000)
committerjsurfer <jsurfer>
Sat, 25 Sep 2004 22:39:28 +0000 (22:39 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContextType.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/util/PHPFileUtil.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/wizards/PHPFileWizard.java
net.sourceforge.phpeclipse/templates/default-codetemplates.xml

index 57796de..1452f68 100644 (file)
@@ -32,19 +32,19 @@ import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility;
 public class CodeTemplateContextType extends TemplateContextType {
        
        /* context types */
-       public static final String CATCHBLOCK_CONTEXTTYPE= "catchblock_context"; //$NON-NLS-1$
-       public static final String METHODBODY_CONTEXTTYPE= "methodbody_context"; //$NON-NLS-1$
-       public static final String CONSTRUCTORBODY_CONTEXTTYPE= "constructorbody_context"; //$NON-NLS-1$
-       public static final String GETTERBODY_CONTEXTTYPE= "getterbody_context"; //$NON-NLS-1$
-       public static final String SETTERBODY_CONTEXTTYPE= "setterbody_context"; //$NON-NLS-1$
-       public static final String NEWTYPE_CONTEXTTYPE= "newtype_context"; //$NON-NLS-1$
-       public static final String TYPECOMMENT_CONTEXTTYPE= "typecomment_context"; //$NON-NLS-1$
-       public static final String FIELDCOMMENT_CONTEXTTYPE= "fieldcomment_context"; //$NON-NLS-1$
-       public static final String METHODCOMMENT_CONTEXTTYPE= "methodcomment_context"; //$NON-NLS-1$
-       public static final String CONSTRUCTORCOMMENT_CONTEXTTYPE= "constructorcomment_context"; //$NON-NLS-1$
-       public static final String OVERRIDECOMMENT_CONTEXTTYPE= "overridecomment_context"; //$NON-NLS-1$
-       public static final String GETTERCOMMENT_CONTEXTTYPE= "gettercomment_context"; //$NON-NLS-1$
-       public static final String SETTERCOMMENT_CONTEXTTYPE= "settercomment_context"; //$NON-NLS-1$
+       public static final String CATCHBLOCK_CONTEXTTYPE= "php_catchblock_context"; //$NON-NLS-1$
+       public static final String METHODBODY_CONTEXTTYPE= "php_methodbody_context"; //$NON-NLS-1$
+       public static final String CONSTRUCTORBODY_CONTEXTTYPE= "php_constructorbody_context"; //$NON-NLS-1$
+       public static final String GETTERBODY_CONTEXTTYPE= "php_getterbody_context"; //$NON-NLS-1$
+       public static final String SETTERBODY_CONTEXTTYPE= "php_setterbody_context"; //$NON-NLS-1$
+       public static final String NEWTYPE_CONTEXTTYPE= "php_newtype_context"; //$NON-NLS-1$
+       public static final String TYPECOMMENT_CONTEXTTYPE= "php_typecomment_context"; //$NON-NLS-1$
+       public static final String FIELDCOMMENT_CONTEXTTYPE= "php_fieldcomment_context"; //$NON-NLS-1$
+       public static final String METHODCOMMENT_CONTEXTTYPE= "php_methodcomment_context"; //$NON-NLS-1$
+       public static final String CONSTRUCTORCOMMENT_CONTEXTTYPE= "php_constructorcomment_context"; //$NON-NLS-1$
+       public static final String OVERRIDECOMMENT_CONTEXTTYPE= "php_overridecomment_context"; //$NON-NLS-1$
+       public static final String GETTERCOMMENT_CONTEXTTYPE= "php_gettercomment_context"; //$NON-NLS-1$
+       public static final String SETTERCOMMENT_CONTEXTTYPE= "php_settercomment_context"; //$NON-NLS-1$
 
        /* templates */
        public static final String COMMENT_SUFFIX= "comment"; //$NON-NLS-1$
@@ -234,10 +234,10 @@ public class CodeTemplateContextType extends TemplateContextType {
        protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
                ArrayList required=  new ArrayList(5);
                String contextName= getId();
-               if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
-                       required.add(PACKAGE_DECLARATION);
-                       required.add(TYPE_DECLARATION);
-               }
+//             if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
+//                     required.add(PACKAGE_DECLARATION);
+//                     required.add(TYPE_DECLARATION);
+//             }
                for (int i= 0; i < variables.length; i++) {
                        String type= variables[i].getType();
                        if (getResolver(type) == null) {
index fc5d895..e9de7c4 100644 (file)
@@ -24,11 +24,11 @@ public class PHPFileUtil {
       "inc",
       "class"
   };
-  public final static String[] HTML_EXTENSIONS = {
-      "html",
-      "htm",
-      "xhtml"
-  };
+//  public final static String[] HTML_EXTENSIONS = {
+//      "html",
+//      "htm",
+//      "xhtml"
+//  };
   public final static String[] SMARTY_EXTENSIONS = {
       "tpl"
   };
index ea1a3fb..9f4a0e6 100644 (file)
@@ -192,8 +192,6 @@ public class PHPFileWizard extends Wizard implements INewWizard {
        String lineDelimiter = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
        CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), null, lineDelimiter);
 //     context.setCompilationUnitVariables(cu);
-
-
     return new ByteArrayInputStream(StubUtility.evaluateTemplate(context, template).getBytes());
   } catch (CoreException e) {
     e.printStackTrace();
index 45d2b09..1bfbcc9 100644 (file)
 -->
 
 <templates>
-<template name="gettercomment" id="net.sourceforge.phpdt.ui.text.codetemplates.gettercomment" description="%CodeTemplates.gettercomment" context="gettercomment_context" enabled="true">/**
+<template name="gettercomment" id="net.sourceforge.phpdt.ui.text.codetemplates.gettercomment" description="%CodeTemplates.gettercomment" context="php_gettercomment_context" enabled="true">/**
  * @return %CodeTemplates.gettercomment.returntagcontent
  */</template>
 
-<template name="settercomment" id="net.sourceforge.phpdt.ui.text.codetemplates.settercomment" description="%CodeTemplates.settercomment" context="settercomment_context" enabled="true">/**
+<template name="settercomment" id="net.sourceforge.phpdt.ui.text.codetemplates.settercomment" description="%CodeTemplates.settercomment" context="php_settercomment_context" enabled="true">/**
  * @param ${param} %CodeTemplates.settercomment.paramtagcontent
  */</template>
 
-<template name="constructorcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.constructorcomment" description="%CodeTemplates.constructorcomment" context="constructorcomment_context" enabled="true">/**
+<template name="constructorcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.constructorcomment" description="%CodeTemplates.constructorcomment" context="php_constructorcomment_context" enabled="true">/**
  * ${tags}
  */</template>
 
-<template name="typecomment" id="net.sourceforge.phpdt.ui.text.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="typecomment_context" enabled="true">/**
+<template name="typecomment" id="net.sourceforge.phpdt.ui.text.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="php_typecomment_context" enabled="true">/**
  * @author ${user}
  *
  * ${todo} %CodeTemplates.typecomment.content1
  * %CodeTemplates.typecomment.content2
  */</template>
  
-<template name="fieldcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.fieldcomment" description="%CodeTemplates.fieldcomment" context="fieldcomment_context" enabled="true">/**
+<template name="fieldcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.fieldcomment" description="%CodeTemplates.fieldcomment" context="php_fieldcomment_context" enabled="true">/**
  * %CodeTemplates.fieldcomment.content
  */</template>
  
-<template name="methodcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.methodcomment" description="%CodeTemplates.nonoverridingcomment" context="methodcomment_context" enabled="true">/**
+<template name="methodcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.methodcomment" description="%CodeTemplates.nonoverridingcomment" context="php_methodcomment_context" enabled="true">/**
  * ${tags}
  */</template>
 
-<template name="overridecomment" id="net.sourceforge.phpdt.ui.text.codetemplates.overridecomment" description="%CodeTemplates.overridecomment" context="overridecomment_context" enabled="true">/* %CodeTemplates.overridecomment.nonjd
+<template name="overridecomment" id="net.sourceforge.phpdt.ui.text.codetemplates.overridecomment" description="%CodeTemplates.overridecomment" context="php_overridecomment_context" enabled="true">/* %CodeTemplates.overridecomment.nonjd
  * ${see_to_overridden}
  */</template>
 
-<template name="newtype" id="net.sourceforge.phpdt.ui.text.codetemplates.newtype" description="%CodeTemplates.newfile" context="newtype_context" enabled="true">&lt;?php
+<template name="newtype" id="net.sourceforge.phpdt.ui.text.codetemplates.newtype" description="%CodeTemplates.newfile" context="php_newtype_context" enabled="true">&lt;?php
 /*
  * %CodeTemplates.newfile.content1
  *
 ?&gt;
 </template>
 
-<template name="catchblock" id="net.sourceforge.phpdt.ui.text.codetemplates.catchblock" description="%CodeTemplates.catchblock" context="catchblock_context" enabled="true">// ${todo} %CodeTemplates.catchblock.tododesc
+<template name="catchblock" id="net.sourceforge.phpdt.ui.text.codetemplates.catchblock" description="%CodeTemplates.catchblock" context="php_catchblock_context" enabled="true">// ${todo} %CodeTemplates.catchblock.tododesc
 ${exception_var}.printStackTrace();</template>
 
-<template name="methodbody" id="net.sourceforge.phpdt.ui.text.codetemplates.methodbody" description="%CodeTemplates.methodstub" context="methodbody_context" enabled="true">// ${todo} %CodeTemplates.methodstub.tododesc
+<template name="methodbody" id="net.sourceforge.phpdt.ui.text.codetemplates.methodbody" description="%CodeTemplates.methodstub" context="php_methodbody_context" enabled="true">// ${todo} %CodeTemplates.methodstub.tododesc
 ${body_statement}</template>
 
 <template name="constructorbody" id="net.sourceforge.phpdt.ui.text.codetemplates.constructorbody" description="%CodeTemplates.constructorstub" context="constructorbody_context" enabled="true">${body_statement}
 // ${todo} %CodeTemplates.constructorstub.tododesc</template>
  
-<template name="getterbody" id="net.sourceforge.phpdt.ui.text.codetemplates.getterbody" description="%CodeTemplates.getterstub" context="getterbody_context" enabled="true">return ${field};</template>
+<template name="getterbody" id="net.sourceforge.phpdt.ui.text.codetemplates.getterbody" description="%CodeTemplates.getterstub" context="php_getterbody_context" enabled="true">return ${field};</template>
 
-<template name="setterbody" id="net.sourceforge.phpdt.ui.text.codetemplates.setterbody" description="%CodeTemplates.setterstub" context="setterbody_context" enabled="true">${field} = ${param};</template>
+<template name="setterbody" id="net.sourceforge.phpdt.ui.text.codetemplates.setterbody" description="%CodeTemplates.setterstub" context="php_setterbody_context" enabled="true">${field} = ${param};</template>
 
 </templates>
\ No newline at end of file