aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2013-03-11 04:15:13 (EDT)
committerzzhongwei2013-03-11 04:15:13 (EDT)
commitdbcee7c1adf7f3dc97662a0c8719f96ce0f8933c (patch)
tree7c1242ca300ad818dff74f13646da83f1955b7e2
parentb915e9c9ba779aa1005ef3b8c0bfd56edfc0f8c6 (diff)
downloadorg.eclipse.pdt-dbcee7c1adf7f3dc97662a0c8719f96ce0f8933c.zip
org.eclipse.pdt-dbcee7c1adf7f3dc97662a0c8719f96ce0f8933c.tar.gz
org.eclipse.pdt-dbcee7c1adf7f3dc97662a0c8719f96ce0f8933c.tar.bz2
402232: Template variables ${project_name}, ${file_name} are not
resolved https://bugs.eclipse.org/bugs/show_bug.cgi?id=402232
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/AddDescriptionAction.java10
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/corext/codemanipulation/StubUtility.java19
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java5
3 files changed, 28 insertions, 6 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/AddDescriptionAction.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/AddDescriptionAction.java
index 0ca63ac..6654650 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/AddDescriptionAction.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/AddDescriptionAction.java
@@ -237,8 +237,7 @@ public class AddDescriptionAction extends Action implements
String lineDelim) {
String delimPlusIndent = lineDelim + indentation;
String indentedPattern = originalPattern.replaceAll(lineDelim,
- delimPlusIndent)
- + delimPlusIndent;
+ delimPlusIndent) + delimPlusIndent;
return indentedPattern;
}
@@ -251,8 +250,8 @@ public class AddDescriptionAction extends Action implements
private String createTypeComment(IType type, String lineDelimiter)
throws CoreException {
- return CodeGeneration.getTypeComment(type.getScriptProject(), type
- .getTypeQualifiedName(), /* typeParameterNames */null,
+ return CodeGeneration.getTypeComment(type.getScriptProject(),
+ type.getTypeQualifiedName(), /* typeParameterNames */null,
lineDelimiter);
}
@@ -399,8 +398,7 @@ public class AddDescriptionAction extends Action implements
&& region.getType() == PHPRegionContext.PHP_CONTENT) {
phpScriptRegion = (IPhpScriptRegion) region;
try {
- docBlock = CodeGeneration.getFileComment(data
- .getScriptProject(), null);
+ docBlock = CodeGeneration.getFileComment(data, null);
} catch (CoreException e) {
Logger.logException(
"Generating default phpdoc comment", e);
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/corext/codemanipulation/StubUtility.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/corext/codemanipulation/StubUtility.java
index 3f40272..ed2f9f6 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/corext/codemanipulation/StubUtility.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/corext/codemanipulation/StubUtility.java
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.dltk.core.IMethod;
import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.internal.corext.util.Strings;
import org.eclipse.dltk.internal.ui.DLTKUIStatus;
@@ -191,6 +192,24 @@ public class StubUtility {
* @see org.eclipse.jdt.ui.CodeGeneration#getFileComment(ICompilationUnit,
* String)
*/
+ public static String getFileComment(ISourceModule sm, String lineDelimiter)
+ throws CoreException {
+ Template template = getCodeTemplate(
+ CodeTemplateContextType.FILECOMMENT_ID, sm.getScriptProject());
+ if (template == null) {
+ return null;
+ }
+
+ CodeTemplateContext context = new CodeTemplateContext(
+ template.getContextTypeId(), sm.getScriptProject(),
+ lineDelimiter);
+ context.setVariable(CodeTemplateContextType.FILENAME,
+ sm.getElementName());
+ context.setVariable(CodeTemplateContextType.PROJECTNAME, sm
+ .getScriptProject().getElementName());
+ return evaluateTemplate(context, template);
+ }
+
public static String getFileComment(IScriptProject sp, String lineDelimiter)
throws CoreException {
Template template = getCodeTemplate(
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java
index f49e0e7..936b6bf 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/ui/CodeGeneration.java
@@ -161,6 +161,11 @@ public class CodeGeneration {
* Thrown when the evaluation of the code template fails.
* @since 3.1
*/
+ public static String getFileComment(ISourceModule sm, String lineDelimiter)
+ throws CoreException {
+ return StubUtility.getFileComment(sm, lineDelimiter);
+ }
+
public static String getFileComment(IScriptProject sp, String lineDelimiter)
throws CoreException {
return StubUtility.getFileComment(sp, lineDelimiter);