aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-08-01 23:21:06 (EDT)
committerzzhongwei2012-08-01 23:21:06 (EDT)
commitdeb47f8a127b7e2f67826430e3f830cc96c2e478 (patch)
treefad1b91c8f15cfdde161836acb96c839ca1f556d
parentf7cedec17db0d507e95bd13bb766c70245435dd8 (diff)
downloadorg.eclipse.pdt-deb47f8a127b7e2f67826430e3f830cc96c2e478.zip
org.eclipse.pdt-deb47f8a127b7e2f67826430e3f830cc96c2e478.tar.gz
org.eclipse.pdt-deb47f8a127b7e2f67826430e3f830cc96c2e478.tar.bz2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=372638 - [PHP 5.4] trait
template to be added to PHP templates
-rw-r--r--plugins/org.eclipse.php.ui/plugin.properties5
-rw-r--r--plugins/org.eclipse.php.ui/plugin.xml3
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/PHPUiPlugin.java1
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java7
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateContextType.java3
-rw-r--r--plugins/org.eclipse.php.ui/templates/phpdefault-templates.properties2
-rw-r--r--plugins/org.eclipse.php.ui/templates/phpdefault-templates.xml140
7 files changed, 156 insertions, 5 deletions
diff --git a/plugins/org.eclipse.php.ui/plugin.properties b/plugins/org.eclipse.php.ui/plugin.properties
index c4190a1..7ed6216 100644
--- a/plugins/org.eclipse.php.ui/plugin.properties
+++ b/plugins/org.eclipse.php.ui/plugin.properties
@@ -806,10 +806,11 @@ JavadocView= Javadoc
#--- templates
templates.php.contextType.name=php
templates.php1.contextType.name=php statements
-templates.php2.contextType.name=php class members
+templates.php2.contextType.name=php type members
templates.php3.contextType.name=php global members
-templates.php4.contextType.name=php class method statements
+templates.php4.contextType.name=php type method statements
templates.newphp.contextType.name=newPhp
+templates.php5.contextType.name=php class members(only for class)
templates.phpcomment.contextType.name=phpcomment
#--- folding
diff --git a/plugins/org.eclipse.php.ui/plugin.xml b/plugins/org.eclipse.php.ui/plugin.xml
index 2d77039..ce24736 100644
--- a/plugins/org.eclipse.php.ui/plugin.xml
+++ b/plugins/org.eclipse.php.ui/plugin.xml
@@ -388,6 +388,9 @@
<contextType name="%templates.php4.contextType.name"
class="org.eclipse.php.internal.ui.editor.templates.PhpTemplateContextType"
id="php-type-method-statements" />
+ <contextType name="%templates.php5.contextType.name"
+ class="org.eclipse.php.internal.ui.editor.templates.PhpTemplateContextType"
+ id="php-class-members" />
<contextType name="%templates.phpcomment.contextType.name"
class="org.eclipse.php.internal.ui.editor.templates.PhpCommentTemplateContextType"
id="phpcomment" />
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/PHPUiPlugin.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/PHPUiPlugin.java
index d87c1f4..8f0d080 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/PHPUiPlugin.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/PHPUiPlugin.java
@@ -392,6 +392,7 @@ public class PHPUiPlugin extends AbstractUIPlugin {
registry.addContextType(PhpTemplateContextType.PHP_TYPE_MEMBERS_CONTEXT_TYPE_ID);
registry.addContextType(PhpTemplateContextType.PHP_GLOBAL_MEMBERS_CONTEXT_TYPE_ID);
registry.addContextType(PhpTemplateContextType.PHP_TYPE_METHOD_STATEMENTS_CONTEXT_TYPE_ID);
+ registry.addContextType(PhpTemplateContextType.PHP_CLASS_MEMBERS_CONTEXT_TYPE_ID);
registry.addContextType(PhpCommentTemplateContextType.PHP_COMMENT_CONTEXT_TYPE_ID);
fContextTypeRegistry = registry;
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java
index df27c5c..a4a8a96 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateCompletionProcessor.java
@@ -104,8 +104,7 @@ public class PhpTemplateCompletionProcessor extends
// find the most outer enclosing type if exists
while (enclosingElement != null
- && !(enclosingElement instanceof IType && enclosingElement
- .getParent() instanceof ISourceModule)) {
+ && !(enclosingElement instanceof IType)) {
enclosingElement = enclosingElement.getParent();
}
enclosingType = (IType) enclosingElement;
@@ -119,6 +118,10 @@ public class PhpTemplateCompletionProcessor extends
if (!PHPFlags.isNamespace(enclosingType.getFlags())) {
contextIds
.add(PhpTemplateContextType.PHP_TYPE_MEMBERS_CONTEXT_TYPE_ID);
+ if (PHPFlags.isClass(enclosingType.getFlags())) {
+ contextIds
+ .add(PhpTemplateContextType.PHP_CLASS_MEMBERS_CONTEXT_TYPE_ID);
+ }
} else {
contextIds
.add(PhpTemplateContextType.PHP_STATEMENTS_CONTEXT_TYPE_ID);
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateContextType.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateContextType.java
index fa467c8..438c3a7 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateContextType.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/templates/PhpTemplateContextType.java
@@ -35,6 +35,9 @@ public class PhpTemplateContextType extends ScriptTemplateContextType {
// for statements out of function and class
public static final String PHP_GLOBAL_MEMBERS_CONTEXT_TYPE_ID = "php-global-members"; //$NON-NLS-1$
+ // public static final String PHP_TRAIT_STATEMENT_CONTEXT_TYPE_ID = "php-trait-statement"; //$NON-NLS-1$
+ public static final String PHP_CLASS_MEMBERS_CONTEXT_TYPE_ID = "php-class-members"; //$NON-NLS-1$
+
public ScriptTemplateContext createContext(IDocument document, int offset,
int length, ISourceModule sourceModule) {
return new PhpTemplateContext(this, document, offset, length,
diff --git a/plugins/org.eclipse.php.ui/templates/phpdefault-templates.properties b/plugins/org.eclipse.php.ui/templates/phpdefault-templates.properties
index a4d2a3d..8ff097f 100644
--- a/plugins/org.eclipse.php.ui/templates/phpdefault-templates.properties
+++ b/plugins/org.eclipse.php.ui/templates/phpdefault-templates.properties
@@ -28,6 +28,7 @@ description.php.foreach=foreach statement
description.php.foreachkey=foreach with key statement
description.php.switch=switch statement
description.php.class=class statement
+description.php.trait=trait statement
description.php.if=if statement
description.php.else=else statement
description.php.elif=elseif statement
@@ -45,6 +46,7 @@ description.php.use=use statement
description.php.ns=namespace statement
description.newphp.simple=Simple php file
description.newphp.html.frameset=html 4.01 frameset
+description.php.usetrait=use trait statement
Templates.for_array=iterate over array
Templates.for_temp=iterate over array with temporary variable
diff --git a/plugins/org.eclipse.php.ui/templates/phpdefault-templates.xml b/plugins/org.eclipse.php.ui/templates/phpdefault-templates.xml
index 1719dce..6bd14af 100644
--- a/plugins/org.eclipse.php.ui/templates/phpdefault-templates.xml
+++ b/plugins/org.eclipse.php.ui/templates/phpdefault-templates.xml
@@ -13,7 +13,107 @@
<templates>
<!-- Code templates : -->
-<template name="gettercomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.gettercomment" description="%CodeTemplates.gettercomment" context="php_gettercomment_context" enabled="true">/** * @return %CodeTemplates.gettercomment.returntagcontent */</template> <template name="settercomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.settercomment" description="%CodeTemplates.settercomment" context="php_settercomment_context" enabled="true">/** * @param %CodeTemplates.settercomment.paramtagcontent */</template> <template name="constructorcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.constructorcomment" description="%CodeTemplates.constructorcomment" context="php_constructorcomment_context" enabled="true">/** * ${tags} */</template> <template name="filecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.filecomment" description="%CodeTemplates.filecomment" context="php_filecomment_context" enabled="true">/** * */ </template> <template name="typecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="php_typecomment_context" enabled="true">/** * @author ${user} * * ${tags} */</template> <template name="fieldcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.fieldcomment" description="%CodeTemplates.fieldcomment" context="php_fieldcomment_context" enabled="true">/** * @var ${field_type} */</template> <template name="varcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.varcomment" description="%CodeTemplates.varcomment" context="php_varcomment_context" enabled="true">/* @var ${field} ${field_type} */</template> <template name="methodcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.methodcomment" description="%CodeTemplates.nonoverridingcomment" context="php_methodcomment_context" enabled="true">/** * ${tags} */</template> <template name="overridecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.overridecomment" description="%CodeTemplates.overridecomment" context="php_overridecomment_context" enabled="true">/* %CodeTemplates.overridecomment.nonjd * ${see_to_overridden} */</template> <template name="delegatecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.delegatecomment" description="%CodeTemplates.delegatecomment" context="php_delegatecomment_context" enabled="true">/** * ${tags} * ${see_to_target} */</template> <template name="newtype" id="org.eclipse.php.ui.editor.templates.php.codetemplates.newtype" description="%CodeTemplates.newfile" context="php_newtype_context" enabled="true">${filecomment} ${package_declaration} ${typecomment} ${type_declaration}</template> <template name="classbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.classbody" description="%CodeTemplates.classbody" context="php_classbody_context" enabled="true" autoinsert="false"> </template> <template name="interfacebody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.interfacebody" description="%CodeTemplates.interfacebody" context="php_interfacebody_context" enabled="true" autoinsert="false"> </template> <template name="catchblock" id="org.eclipse.php.ui.editor.templates.php.codetemplates.catchblock" description="%CodeTemplates.catchblock" context="php_catchblock_context" enabled="true">// ${TODO} %CodeTemplates.catchblock.tododesc ${exception_var}.printStackTrace();</template> <template name="methodbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.methodbody" description="%CodeTemplates.methodstub" context="php_methodbody_context" enabled="true">// ${TODO} %CodeTemplates.methodstub.tododesc ${body_statement}</template> <template name="constructorbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.constructorbody" description="%CodeTemplates.constructorstub" context="php_constructorbody_context" enabled="true">${body_statement} // ${TODO} %CodeTemplates.constructorstub.tododesc</template> <template name="getterbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.getterbody" description="%CodeTemplates.getterstub" context="php_getterbody_context" enabled="true">return ${field};</template> <template name="setterbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.setterbody" description="%CodeTemplates.setterstub" context="php_setterbody_context" enabled="true">${field} = ${param};</template> <!-- new PHP templates --> <template name="New simple PHP file" description="%description.newphp.simple" id="org.eclipse.php.ui.editor.templates.php.author" context="php_new_file_context" enabled="true">&lt;?php ${cursor}</template> <template name="New PHP file - HTML frameset" description="%description.newphp.html.frameset" id="org.eclipse.php.ui.editor.templates.php.html.frameset" context="php_new_file_context" enabled="true">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=${encoding}"&gt; &lt;title&gt;Insert title here&lt;/title&gt; &lt;/head&gt; &lt;frameset&gt; &lt;frame&gt; &lt;frame&gt; &lt;noframes&gt; &lt;body&gt; &lt;p&gt;This page uses frames. The current browser you are using does not support frames.&lt;/p&gt; &lt;?php ${cursor} ?&gt; &lt;/body&gt; &lt;/noframes&gt; &lt;/frameset&gt; &lt;/html&gt;</template>
+<template name="gettercomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.gettercomment" description="%CodeTemplates.gettercomment" context="php_gettercomment_context" enabled="true">/**
+ * @return %CodeTemplates.gettercomment.returntagcontent
+ */</template>
+
+<template name="settercomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.settercomment" description="%CodeTemplates.settercomment" context="php_settercomment_context" enabled="true">/**
+ * @param %CodeTemplates.settercomment.paramtagcontent
+ */</template>
+
+<template name="constructorcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.constructorcomment" description="%CodeTemplates.constructorcomment" context="php_constructorcomment_context" enabled="true">/**
+ * ${tags}
+ */</template>
+
+<template name="filecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.filecomment" description="%CodeTemplates.filecomment" context="php_filecomment_context" enabled="true">/**
+ *
+ */
+</template>
+
+<template name="typecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="php_typecomment_context" enabled="true">/**
+ * @author ${user}
+ *
+ * ${tags}
+ */</template>
+
+<template name="fieldcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.fieldcomment" description="%CodeTemplates.fieldcomment" context="php_fieldcomment_context" enabled="true">/**
+ * @var ${field_type}
+ */</template>
+
+<template name="varcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.varcomment" description="%CodeTemplates.varcomment" context="php_varcomment_context" enabled="true">/* @var ${field} ${field_type} */</template>
+
+<template name="methodcomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.methodcomment" description="%CodeTemplates.nonoverridingcomment" context="php_methodcomment_context" enabled="true">/**
+ * ${tags}
+ */</template>
+
+<template name="overridecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.overridecomment" description="%CodeTemplates.overridecomment" context="php_overridecomment_context" enabled="true">/* %CodeTemplates.overridecomment.nonjd
+ * ${see_to_overridden}
+ */</template>
+
+<template name="delegatecomment" id="org.eclipse.php.ui.editor.templates.php.codetemplates.delegatecomment" description="%CodeTemplates.delegatecomment" context="php_delegatecomment_context" enabled="true">/**
+ * ${tags}
+ * ${see_to_target}
+ */</template>
+
+<template name="newtype" id="org.eclipse.php.ui.editor.templates.php.codetemplates.newtype" description="%CodeTemplates.newfile" context="php_newtype_context" enabled="true">${filecomment}
+${package_declaration}
+
+${typecomment}
+${type_declaration}</template>
+
+<template name="classbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.classbody" description="%CodeTemplates.classbody" context="php_classbody_context" enabled="true" autoinsert="false">
+</template>
+
+<template name="interfacebody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.interfacebody" description="%CodeTemplates.interfacebody" context="php_interfacebody_context" enabled="true" autoinsert="false">
+</template>
+
+<template name="catchblock" id="org.eclipse.php.ui.editor.templates.php.codetemplates.catchblock" description="%CodeTemplates.catchblock" context="php_catchblock_context" enabled="true">// ${TODO} %CodeTemplates.catchblock.tododesc
+${exception_var}.printStackTrace();</template>
+
+<template name="methodbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.methodbody" description="%CodeTemplates.methodstub" context="php_methodbody_context" enabled="true">// ${TODO} %CodeTemplates.methodstub.tododesc
+${body_statement}</template>
+
+<template name="constructorbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.constructorbody" description="%CodeTemplates.constructorstub" context="php_constructorbody_context" enabled="true">${body_statement}
+// ${TODO} %CodeTemplates.constructorstub.tododesc</template>
+
+<template name="getterbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.getterbody" description="%CodeTemplates.getterstub" context="php_getterbody_context" enabled="true">return ${field};</template>
+
+<template name="setterbody" id="org.eclipse.php.ui.editor.templates.php.codetemplates.setterbody" description="%CodeTemplates.setterstub" context="php_setterbody_context" enabled="true">${field} = ${param};</template>
+
+
+<!-- new PHP templates -->
+<template
+ name="New simple PHP file"
+ description="%description.newphp.simple"
+ id="org.eclipse.php.ui.editor.templates.php.author"
+ context="php_new_file_context"
+ enabled="true">&lt;?php
+${cursor}</template>
+
+<template
+ name="New PHP file - HTML frameset"
+ description="%description.newphp.html.frameset"
+ id="org.eclipse.php.ui.editor.templates.php.html.frameset"
+ context="php_new_file_context"
+ enabled="true">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;meta http-equiv="Content-Type" content="text/html; charset=${encoding}"&gt;
+&lt;title&gt;Insert title here&lt;/title&gt;
+&lt;/head&gt;
+&lt;frameset&gt;
+ &lt;frame&gt;
+ &lt;frame&gt;
+ &lt;noframes&gt;
+ &lt;body&gt;
+ &lt;p&gt;This page uses frames. The current browser you are using does not support frames.&lt;/p&gt;
+ &lt;?php
+${cursor}
+ ?&gt;
+ &lt;/body&gt;
+ &lt;/noframes&gt;
+&lt;/frameset&gt;
+&lt;/html&gt;</template>
<!-- php templates -->
@@ -267,6 +367,44 @@ ${cursor}</template>
</template>
<template
+ name="trt"
+ description="%description.php.trait"
+ id="org.eclipse.php.ui.editor.templates.php.trt"
+ context="php-global-members"
+ enabled="true"
+ autoinsert="false">trait ${trait_name} {
+ function ${function_name}() {
+ ${cursor};
+ }
+}
+</template>
+
+<template
+ name="trait"
+ description="%description.php.trait"
+ id="org.eclipse.php.ui.editor.templates.php.trait"
+ context="php-global-members"
+ enabled="true"
+ autoinsert="false">trait ${trait_name} {
+ function ${function_name}() {
+ ${cursor};
+ }
+}
+</template>
+<template
+ name="usetrait"
+ description="%description.php.usetrait"
+ id="org.eclipse.php.ui.editor.templates.php.usetrait"
+ context="php-class-members"
+ enabled="true"
+ autoinsert="false">use ${trait_name1}, ${trait_name2} {
+ ${trait_name1}::${function_name1} insteadof ${trait_name2};
+ ${trait_name1}::${function_name2} as static ${function_name3};
+ ${trait_name1}::${function_name4} as ${function_name5};
+ }
+</template>
+
+<template
name="if"
description="%description.php.if"
id="org.eclipse.php.ui.editor.templates.php.if"