Syntax highlighting is changeable.
authorjsurfer <jsurfer>
Sat, 11 Sep 2004 12:57:14 +0000 (12:57 +0000)
committerjsurfer <jsurfer>
Sat, 11 Sep 2004 12:57:14 +0000 (12:57 +0000)
Eclipse 3.0 template mechanism
Code indentation after {

127 files changed:
net.sourceforge.phpeclipse.ui/templates/default-templates.xml
net.sourceforge.phpeclipse/plugin.properties
net.sourceforge.phpeclipse/plugin.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/formatter/CodeFormatter.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ASTVisitor.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/SourceElementParser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/ExceptionHandlingFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/FinallyFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/FlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/InitializationFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/InsideSubRoutineFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/LabelFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/LoopingFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/SwitchFlowContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/flow/UnconditionalFlowInfo.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/BlockScope.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/MethodScope.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/RecoveredElement.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/UnitParser.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/problem/ProblemReporter.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextType.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextTypeRegistry.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/DocumentTemplateContext.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ITemplateEditor.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/SimpleTemplateVariable.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/Template.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateBuffer.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateContext.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateMessages.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplatePosition.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateSet.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateTranslator.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateVariable.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/Templates.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContext.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContextType.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplates.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CompilationUnitCompletion.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CompilationUnitContext.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CompilationUnitContextType.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/GlobalVariables.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLContextType.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaContext.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaContextType.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaDocContext.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPDocContext.java with 56% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaDocContextType.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaTemplateMessages.java [copied from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.java with 58% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaTemplateMessages.properties [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPContextType.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPDocContextType.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.properties [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/TemplateSet.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/Templates.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/AbortFormatting.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/OptimizedReplaceEdit.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/align/AlignmentException.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/EditTemplateDialog.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaEditorPreferencePage.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaTemplatePreferencePage.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/PreferencesMessages.properties
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplateEditorSourceViewerConfiguration.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaHeuristicScanner.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/Symbols.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/phpdoc/PHPDocCompletionProcessor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/DeclarationProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/IdentifierEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/IdentifierProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/SQLProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateContentProvider.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateEngine.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateLabelProvider.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateProposal.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/InclusivePositionUpdater.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/MultiVariable.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/MultiVariableGuess.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/PositionBasedCompletionProposal.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateContentAssistMessages.java [copied from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.java with 53% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateContentAssistMessages.properties [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateEngine.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateInformationControlCreator.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateProposal.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/VariablePosition.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/preferences/TemplatePreferencesMessages.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.java with 53% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/preferences/TemplatePreferencesMessages.properties [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/preferences/TemplateVariableProcessor.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateVariableProcessor.java with 72% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/preferences/TemplateVariableProposal.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateVariableProposal.java with 62% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/util/SWTUtil.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/ListDialogField.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/PHPSourceViewerConfiguration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ASTNode.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/AstNode.java with 98% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/AbstractMethodDeclaration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/BranchStatement.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/Break.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/CompilationUnitDeclaration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ConstructorDeclaration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/Continue.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ExplicitConstructorCall.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ImportReference.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/LabeledStatement.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ReturnStatement.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/Statement.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/EditorHighlightingSynchronizer.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLCompletionProcessor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCodeScanner.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java
net.sourceforge.phpeclipse/templates/default-codetemplates.xml [new file with mode: 0644]
net.sourceforge.phpeclipse/templates/default-templates.properties [new file with mode: 0644]
net.sourceforge.phpeclipse/templates/default-templates.xml [new file with mode: 0644]

index 43746d5..924ed00 100644 (file)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <templates>
-<template name="for" description="for array" id="net.sf.wdte.ui.templates.for_array" context="javascript" enabled="true">for (var ${index} = 0; ${index} &lt; ${array}.length; ${index}++) {
+<template name="for" description="for array" id="net.sourceforge.phpdt.html.for_array" context="javascript" enabled="true">for (var ${index} = 0; ${index} &lt; ${array}.length; ${index}++) {
        ${line_selection}${cursor}
 }</template>
   <template name="xml" description="html page with head,title,body" 
-  id="net.sf.wdte.ui.xml.templates.xml" context="xml" enabled="true">
+  id="net.sourceforge.phpdt.xml.templates.xml" context="xml" enabled="true">
 &lt;?xml ?&gt;</template> 
 
   <template name="&lt;html" description="html page with head,title,body" 
-  id="net.sf.wdte.ui.templates.html" context="html" enabled="true">
+  id="net.sourceforge.phpdt.html.html" context="html" enabled="true">
 &lt;html&gt;
 &lt;head&gt;
 &lt;meta http-equiv="Content-Language" content="en" /&gt;
@@ -21,11 +21,11 @@ ${cursor}
 &lt;/body&gt;
 &lt;/html&gt;
   </template>  
-  <template name="&lt;title" description="title" id="net.sf.wdte.ui.templates.title" context="html" enabled="true">
+  <template name="&lt;title" description="title" id="net.sourceforge.phpdt.html.title" context="html" enabled="true">
   &lt;title&gt;${cursor}&lt;/title&gt;
   </template> 
   
-  <template name="&lt;table" description="3x3 table" id="net.sf.wdte.ui.templates.table" context="html" enabled="true">
+  <template name="&lt;table" description="3x3 table" id="net.sourceforge.phpdt.html.table" context="html" enabled="true">
   &lt;table&gt;
     &lt;tr&gt;
       &lt;td&gt;${t00}&lt;/td&gt;&lt;td&gt;${t01}&lt;/td&gt;&lt;td&gt;${t02}&lt;/td&gt;
@@ -39,7 +39,7 @@ ${cursor}
   &lt;/table&gt;
   ${cursor}
   </template>
-  <template name="&lt;table" description="3x3 table with header" id="net.sf.wdte.ui.templates.table_header" context="html" enabled="true">
+  <template name="&lt;table" description="3x3 table with header" id="net.sourceforge.phpdt.html.table_header" context="html" enabled="true">
   &lt;table&gt;
     &lt;tr&gt;
       &lt;th&gt;${header0}&lt;/th&gt;&lt;th&gt;${header1}&lt;/th&gt;&lt;th&gt;${header2}&lt;/th&gt;
@@ -57,54 +57,54 @@ ${cursor}
   ${cursor}
   </template>
   
-  <template name="&lt;a" description="hyperlink (href)" id="net.sf.wdte.ui.templates.a" context="html" enabled="true">
+  <template name="&lt;a" description="hyperlink (href)" id="net.sourceforge.phpdt.html.a" context="html" enabled="true">
   &lt;a href="${link}"&gt;${description}&lt;/a&gt; ${cursor}
   </template>  
-  <template name="&lt;a" description="hyperlink image" id="net.sf.wdte.ui.templates.a_image" context="html" enabled="true">
+  <template name="&lt;a" description="hyperlink image" id="net.sourceforge.phpdt.html.a_image" context="html" enabled="true">
   &lt;a href="${link}"&gt;&lt;img src="${image}"&gt;&lt;/a&gt; ${cursor}
   </template> 
-  <template name="&lt;a" description="hyperlink fragment identifier (name)" id="net.sf.wdte.ui.templates.a_anchor" context="html" enabled="true">
+  <template name="&lt;a" description="hyperlink fragment identifier (name)" id="net.sourceforge.phpdt.html.a_anchor" context="html" enabled="true">
   &lt;a name="${anchor}"&gt;${description}&lt;/a&gt; ${cursor}
   </template> 
-  <template name="&lt;p" description="paragraph" id="net.sf.wdte.ui.templates.p" context="html" enabled="true">
+  <template name="&lt;p" description="paragraph" id="net.sourceforge.phpdt.html.p" context="html" enabled="true">
   &lt;p&gt;${cursor}&lt;/p&gt;
   </template>
-  <template name="&lt;h1" description="heading 1" id="net.sf.wdte.ui.templates.h1" context="html" enabled="true">
+  <template name="&lt;h1" description="heading 1" id="net.sourceforge.phpdt.html.h1" context="html" enabled="true">
   &lt;h1&gt;${cursor}&lt;/h1&gt;
   </template>
-  <template name="&lt;h2" description="heading 2" id="net.sf.wdte.ui.templates.h2" context="html" enabled="true">
+  <template name="&lt;h2" description="heading 2" id="net.sourceforge.phpdt.html.h2" context="html" enabled="true">
   &lt;h2&gt;${cursor}&lt;/h2&gt;
   </template>
-  <template name="&lt;h3" description="heading 3" id="net.sf.wdte.ui.templates.h3" context="html" enabled="true">
+  <template name="&lt;h3" description="heading 3" id="net.sourceforge.phpdt.html.h3" context="html" enabled="true">
   &lt;h3&gt;${cursor}&lt;/h3&gt;
   </template>
-  <template name="&lt;h4" description="heading 4" id="net.sf.wdte.ui.templates.h4" context="html" enabled="true">
+  <template name="&lt;h4" description="heading 4" id="net.sourceforge.phpdt.html.h4" context="html" enabled="true">
   &lt;h4&gt;${cursor}&lt;/h4&gt;
   </template>
-  <template name="&lt;h5" description="heading 5" id="net.sf.wdte.ui.templates.h5" context="html" enabled="true">
+  <template name="&lt;h5" description="heading 5" id="net.sourceforge.phpdt.html.h5" context="html" enabled="true">
   &lt;h5&gt;${cursor}&lt;/h5&gt;
   </template>
-  <template name="&lt;h6" description="heading 6" id="net.sf.wdte.ui.templates.h6" context="html" enabled="true">
+  <template name="&lt;h6" description="heading 6" id="net.sourceforge.phpdt.html.h6" context="html" enabled="true">
   &lt;h6&gt;${cursor}&lt;/h6&gt;
   </template>
-  <template name="&lt;address" description="address" id="net.sf.wdte.ui.templates.address" context="html" enabled="true">
+  <template name="&lt;address" description="address" id="net.sourceforge.phpdt.html.address" context="html" enabled="true">
   &lt;address&gt;${cursor}&lt;/address&gt;
   </template>
-  <template name="&lt;pre" description="preformat" id="net.sf.wdte.ui.templates.pre" context="html" enabled="true">
+  <template name="&lt;pre" description="preformat" id="net.sourceforge.phpdt.html.pre" context="html" enabled="true">
   &lt;pre&gt;${cursor}&lt;/pre&gt;
   </template>
-  <template name="&lt;code" description="code block" id="net.sf.wdte.ui.templates.code" context="html" enabled="true">
+  <template name="&lt;code" description="code block" id="net.sourceforge.phpdt.html.code" context="html" enabled="true">
   &lt;code&gt;${cursor}&lt;/code&gt;
   </template>
-  <template name="&lt;blockquote" description="blockquote" id="net.sf.wdte.ui.templates.blockquote" context="html" enabled="true">
+  <template name="&lt;blockquote" description="blockquote" id="net.sourceforge.phpdt.html.blockquote" context="html" enabled="true">
   &lt;blockquote&gt;${cursor}&lt;br/&gt;
   &lt;/blockquote&gt;
   </template>
-  <template name="&lt;hr" description="horizontal line" id="net.sf.wdte.ui.templates.hr" context="html" enabled="true">
+  <template name="&lt;hr" description="horizontal line" id="net.sourceforge.phpdt.html.hr" context="html" enabled="true">
   &lt;hr width="100%" size="2"&gt;
   ${cursor}
   </template>
-  <template name="&lt;ul" description="bulleted list" id="net.sf.wdte.ui.templates.ul" context="html" enabled="true">
+  <template name="&lt;ul" description="bulleted list" id="net.sourceforge.phpdt.html.ul" context="html" enabled="true">
   &lt;ul&gt;
     &lt;li&gt;${item1}&lt;br/&gt;
     &lt;/li&gt;
@@ -112,7 +112,7 @@ ${cursor}
     &lt;/li&gt;
   &lt;/ul&gt;
   </template>
-  <template name="&lt;ol" description="numbered list" id="net.sf.wdte.ui.templates.ol" context="html" enabled="true">
+  <template name="&lt;ol" description="numbered list" id="net.sourceforge.phpdt.html.ol" context="html" enabled="true">
   &lt;ol&gt;
     &lt;li&gt;${item1}&lt;br/&gt;
     &lt;/li&gt;
@@ -120,7 +120,7 @@ ${cursor}
     &lt;/li&gt;
   &lt;/ol&gt;
   </template>
-  <template name="&lt;dl" description="term list" id="net.sf.wdte.ui.templates.dl_term" context="html" enabled="true">
+  <template name="&lt;dl" description="term list" id="net.sourceforge.phpdt.html.dl_term" context="html" enabled="true">
   &lt;dl&gt;
     &lt;dt&gt;${item1}&lt;br/&gt;
     &lt;/dt&gt;
@@ -128,7 +128,7 @@ ${cursor}
     &lt;/dt&gt;
   &lt;/dl&gt;
   </template>
-  <template name="&lt;dl" description="definition list" id="net.sf.wdte.ui.templates.dl_list" context="html" enabled="true">
+  <template name="&lt;dl" description="definition list" id="net.sourceforge.phpdt.html.dl_list" context="html" enabled="true">
   &lt;dl&gt;
     &lt;dd&gt;${item1}&lt;br/&gt;
     &lt;/dd&gt;
@@ -136,17 +136,17 @@ ${cursor}
     &lt;/dd&gt;
   &lt;/dl&gt;
   </template>
-  <template name="&lt;form" description="form get" id="net.sf.wdte.ui.templates.form_get" context="html" enabled="true">
+  <template name="&lt;form" description="form get" id="net.sourceforge.phpdt.html.form_get" context="html" enabled="true">
   &lt;form action="${link}" method="${get}"&gt;
   ${cursor}
   &lt;/form&gt;
   </template>
-  <template name="&lt;form" description="form post" id="net.sf.wdte.ui.templates.form_post" context="html" enabled="true">
+  <template name="&lt;form" description="form post" id="net.sourceforge.phpdt.html.form_post" context="html" enabled="true">
   &lt;form action="${link}" method="${post}" enctype="text/plain"&gt;
   ${cursor}
   &lt;/form&gt;
   </template>
-  <template name="&lt;form" description="form upload file" id="net.sf.wdte.ui.templates.form_upload" context="html" enabled="true">
+  <template name="&lt;form" description="form upload file" id="net.sourceforge.phpdt.html.form_upload" context="html" enabled="true">
   &lt;form action="${link}" method="${post}" enctype="multipart/form-data"&gt;
   &lt;p&gt;${text}&lt;/p&gt;
   &lt;input type="file" name="${name}" size="50" maxlength="100000" accept="text/*"/&gt;&lt;br/&gt;
@@ -154,315 +154,315 @@ ${cursor}
   ${cursor}
   &lt;/form&gt;
   </template>
-  <template name="&lt;input" description="input type=text (form)" id="net.sf.wdte.ui.templates.form_input_text" context="html" enabled="true">
+  <template name="&lt;input" description="input type=text (form)" id="net.sourceforge.phpdt.html.form_input_text" context="html" enabled="true">
   &lt;input type="text" name="${name}" value="${value}" size="40" maxlength="40"/&gt;
   ${cursor}
   </template>
-  <template name="&lt;input" description="input type=password (form)" id="net.sf.wdte.ui.templates.form_input_password" context="html" enabled="true">
+  <template name="&lt;input" description="input type=password (form)" id="net.sourceforge.phpdt.html.form_input_password" context="html" enabled="true">
   &lt;input type="password" name="${name}" size="40" maxlength="40"/&gt;
   ${cursor}
   </template>  
-  <template name="&lt;input" description="input type=radio (form)" id="net.sf.wdte.ui.templates.form_input_radio" context="html" enabled="true">
+  <template name="&lt;input" description="input type=radio (form)" id="net.sourceforge.phpdt.html.form_input_radio" context="html" enabled="true">
   &lt;input type="radio" name="${name}" value="${value}"/&gt;
   ${cursor}
   </template>
-  <template name="&lt;input" description="input type=checkbox (form)" id="net.sf.wdte.ui.templates.form_input_checkbox" context="html" enabled="true">
+  <template name="&lt;input" description="input type=checkbox (form)" id="net.sourceforge.phpdt.html.form_input_checkbox" context="html" enabled="true">
   &lt;input type="checkbox" name="${name}" value="${value}"/&gt;
   ${cursor}
   </template>
-  <template name="&lt;input" description="input type=button (form button)" id="net.sf.wdte.ui.templates.form_input_button" context="html" enabled="true">
+  <template name="&lt;input" description="input type=button (form button)" id="net.sourceforge.phpdt.html.form_input_button" context="html" enabled="true">
   &lt;input type="button" name="${name}" value="${value}"/&gt;
   ${cursor}
   </template>
-  <template name="&lt;input" description="input type=submit (form button)" id="net.sf.wdte.ui.templates.form_input_submit" context="html" enabled="true">
+  <template name="&lt;input" description="input type=submit (form button)" id="net.sourceforge.phpdt.html.form_input_submit" context="html" enabled="true">
   &lt;input type="submit" name="${name}" value="${value}"/&gt;
   ${cursor}
   </template>
-  <template name="&lt;input" description="input type=reset (form button)" id="net.sf.wdte.ui.templates.form_input_reset" context="html" enabled="true">
+  <template name="&lt;input" description="input type=reset (form button)" id="net.sourceforge.phpdt.html.form_input_reset" context="html" enabled="true">
   &lt;input type="reset" name="${name}" value="${value}"/&gt;
   ${cursor}
   </template>
-  <template name="&lt;textarea" description="textarea (form)" id="net.sf.wdte.ui.templates.form_input_textarea" context="html" enabled="true">
+  <template name="&lt;textarea" description="textarea (form)" id="net.sourceforge.phpdt.html.form_input_textarea" context="html" enabled="true">
   &lt;textarea name="${name}" rows="10" cols="50" wrap="off"&gt;
   ${text}
   &lt;/textarea&gt;
   ${cursor}
   </template>
-  <template name="&lt;select" description="select option (form)" id="net.sf.wdte.ui.templates.form_input_select" context="html" enabled="true">
+  <template name="&lt;select" description="select option (form)" id="net.sourceforge.phpdt.html.form_input_select" context="html" enabled="true">
   &lt;select name="${name}" size="3"&gt;
     &lt;option value="${value1}"&gt;${option1}&lt;/option&gt;
     &lt;option value="${value2}"&gt;${option2}&lt;/option&gt;
     &lt;option value="${value3}"&gt;${option3}&lt;/option&gt;
   &lt;/select&gt;
   </template>
-  <template name="&lt;xml" description="xml version=1.0" id="net.sf.wdte.ui.templates.xml" context="html" enabled="true">
+  <template name="&lt;xml" description="xml version=1.0" id="net.sourceforge.phpdt.html.xml" context="html" enabled="true">
   &lt;?xml version="1.0"?&gt;
   ${cursor}
   </template>
-  <template name="&lt;xml" description="xml-stylesheet type=text/xsl" id="net.sf.wdte.ui.templates.xml_stylesheet" context="html" enabled="true">
+  <template name="&lt;xml" description="xml-stylesheet type=text/xsl" id="net.sourceforge.phpdt.html.xml_stylesheet" context="html" enabled="true">
   &lt;?xml-stylesheet type="text/xsl" href="${url}"&gt;
   ${cursor}
   </template>
-  <template name="&lt;script" description="JavaScript inline" id="net.sf.wdte.ui.templates.javascript_inline" context="html" enabled="true">&lt;script language="JavaScript" type="text/javascript"&gt;
+  <template name="&lt;script" description="JavaScript inline" id="net.sourceforge.phpdt.html.javascript_inline" context="html" enabled="true">&lt;script language="JavaScript" type="text/javascript"&gt;
   ${cursor}
 &lt;/script&gt;
   </template>
-  <template name="&lt;script" description="JavaScript file" id="net.sf.wdte.ui.templates.javascript_file" context="html" enabled="true">&lt;script language="JavaScript" type="text/javascript" src="${jsfile}.js"&gt;&lt;/script&gt;${cursor}
+  <template name="&lt;script" description="JavaScript file" id="net.sourceforge.phpdt.html.javascript_file" context="html" enabled="true">&lt;script language="JavaScript" type="text/javascript" src="${jsfile}.js"&gt;&lt;/script&gt;${cursor}
   </template>
-  <template name="&lt;style" description="style text/css" id="net.sf.wdte.ui.templates.css" context="html" enabled="true">&lt;/style type="text/css"&gt;
+  <template name="&lt;style" description="style text/css" id="net.sourceforge.phpdt.html.css" context="html" enabled="true">&lt;/style type="text/css"&gt;
 <!--
   ${cursor}
 -->
 &lt;/style&gt;
   </template>
-  <template name="&amp;quot" description="quot" id="net.sf.wdte.ui.templates.quot" context="html" enabled="true">&amp;quot;</template>
-  <template name="&amp;amp" description="ampersand" id="net.sf.wdte.ui.templates.ampersand" context="html" enabled="true">&amp;amp;</template>
-  <template name="&amp;lt" description="less than" id="net.sf.wdte.ui.templates.less_than" context="html" enabled="true">&amp;lt;</template>
-  <template name="&amp;gt" description="greater than" id="net.sf.wdte.ui.templates.greater" context="html" enabled="true">&amp;gt;</template>
+  <template name="&amp;quot" description="quot" id="net.sourceforge.phpdt.html.quot" context="html" enabled="true">&amp;quot;</template>
+  <template name="&amp;amp" description="ampersand" id="net.sourceforge.phpdt.html.ampersand" context="html" enabled="true">&amp;amp;</template>
+  <template name="&amp;lt" description="less than" id="net.sourceforge.phpdt.html.less_than" context="html" enabled="true">&amp;lt;</template>
+  <template name="&amp;gt" description="greater than" id="net.sourceforge.phpdt.html.greater" context="html" enabled="true">&amp;gt;</template>
   
-  <template name="&amp;nbsp" description="no-break space" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;nbsp;</template>
-  <template name="&amp;iexcl" description="iexcl" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;iexcl;</template>
-  <template name="&amp;cent" description="cent" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;cent;</template>
-  <template name="&amp;pound" description="pound" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;pound;</template>
-  <template name="&amp;curren" description="curren" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;curren;</template>
-  <template name="&amp;yen" description="yen" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;yen;</template>
-  <template name="&amp;brvbar" description="brvbar" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;brvbar;</template>
-  <template name="&amp;brkbar" description="brkbar" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;brkbar;</template>
-  <template name="&amp;sect" description="sect" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;sect;</template>
-  <template name="&amp;uml" description="uml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;uml;</template>
-  <template name="&amp;die" description="die" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;die;</template>
-  <template name="&amp;copy" description="copy" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;copy;</template>
-  <template name="&amp;ordf" description="ordf" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ordf;</template>
-  <template name="&amp;laquo" description="laquo" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;laquo;</template>
-  <template name="&amp;not" description="not" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;not;</template>
-  <template name="&amp;shy" description="shy" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;shy;</template>
-  <template name="&amp;reg" description="reg" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;reg;</template>
-  <template name="&amp;macr" description="macr" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;macr;</template>
-  <template name="&amp;hibar" description="hibar" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;hibar;</template>
-  <template name="&amp;deg" description="deg" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;deg;</template>
-  <template name="&amp;plusmn" description="plusmn" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;plusmn;</template>
-  <template name="&amp;sup2" description="sup2" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;sup2;</template>
-  <template name="&amp;sup3" description="sup3" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;sup3;</template>
-  <template name="&amp;acute" description="acute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;acute;</template>
-  <template name="&amp;micro" description="micro" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;micro;</template>
-  <template name="&amp;para" description="para" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;para;</template>
-  <template name="&amp;middot" description="middot" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;middot;</template>
-  <template name="&amp;cedil" description="cedil" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;cedil;</template>
-  <template name="&amp;sup1" description="sup1" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;sup1;</template>
-  <template name="&amp;ordm" description="ordm" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ordm;</template>
-  <template name="&amp;raquo" description="raquo" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;raquo;</template>
-  <template name="&amp;frac14" description="frac14" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;frac14;</template>
-  <template name="&amp;frac12" description="frac12" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;frac12;</template>
-  <template name="&amp;frac34" description="frac34" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;frac34;</template>
-  <template name="&amp;iquest" description="iquest" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;iquest;</template>
-  <template name="&amp;Agrave" description="Agrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Agrave;</template>
-  <template name="&amp;Aacute" description="Aacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Aacute;</template>
-  <template name="&amp;Acirc" description="Acirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Acirc;</template>
-  <template name="&amp;Atilde" description="Atilde" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Atilde;</template>
-  <template name="&amp;Auml" description="Auml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Auml;</template>
-  <template name="&amp;Aring" description="Aring" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Aring;</template>
-  <template name="&amp;AElig" description="AElig" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;AElig;</template>
-  <template name="&amp;Ccedil" description="Ccedil" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ccedil;</template>
-  <template name="&amp;Egrave" description="Egrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Egrave;</template>
-  <template name="&amp;Eacute" description="Eacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Eacute;</template>
-  <template name="&amp;Ecirc" description="Ecirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ecirc;</template>
-  <template name="&amp;Euml" description="Euml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Euml;</template>
-  <template name="&amp;lgrave" description="lgrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;lgrave;</template>
-  <template name="&amp;lacute" description="lacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;lacute;</template>
-  <template name="&amp;lcirc" description="lcirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;lcirc;</template>
-  <template name="&amp;luml" description="luml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;luml;</template>
-  <template name="&amp;ETH" description="ETH" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ETH;</template>
-  <template name="&amp;Ntilde" description="Ntilde" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ntilde;</template>
-  <template name="&amp;Ograve" description="Ograve" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ograve;</template>
-  <template name="&amp;Oacute" description="Oacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Oacute;</template>
-  <template name="&amp;Ocirc" description="Ocirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ocirc;</template>
-  <template name="&amp;Otilde" description="Otilde" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Otilde;</template>
-  <template name="&amp;Ouml" description="Ouml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ouml;</template>
-  <template name="&amp;times" description="times" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;times;</template>
-  <template name="&amp;Oslash" description="Oslash" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Oslash;</template>
-  <template name="&amp;Ugrave" description="Ugrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ugrave;</template>
-  <template name="&amp;Uacute" description="Uacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Uacute;</template>
-  <template name="&amp;Ucirc" description="Ucirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Ucirc;</template>
-  <template name="&amp;Uuml" description="Uuml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Uuml;</template>
-  <template name="&amp;Yacute" description="Yacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;Yacute;</template>
-  <template name="&amp;THORN" description="THORN" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;THORN;</template>
-  <template name="&amp;szlig" description="szlig" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;szlig;</template>
-  <template name="&amp;agrave" description="agrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;agrave;</template>
-  <template name="&amp;aacute" description="aacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;aacute;</template>
-  <template name="&amp;acirc" description="acirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;acirc;</template>
-  <template name="&amp;atilde" description="atilde" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;atilde;</template>
-  <template name="&amp;auml" description="auml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;auml;</template>
-  <template name="&amp;aring" description="aring" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;aring;</template>
-  <template name="&amp;aelig" description="aelig" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;aelig;</template>
-  <template name="&amp;ccedil" description="ccedil" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ccedil;</template>
-  <template name="&amp;egrave" description="egrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;egrave;</template>
-  <template name="&amp;eacute" description="eacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;eacute;</template>
-  <template name="&amp;ecirc" description="ecirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ecirc;</template>
-  <template name="&amp;euml" description="euml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;euml;</template>
-  <template name="&amp;igrave" description="igrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;igrave;</template>
-  <template name="&amp;iacute" description="iacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;iacute;</template>
-  <template name="&amp;icirc" description="icirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;icirc;</template>
-  <template name="&amp;iuml" description="iuml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;iuml;</template>
-  <template name="&amp;eth" description="eth" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;eth;</template>
-  <template name="&amp;ntilde" description="ntilde" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ntilde;</template>
-  <template name="&amp;ograve" description="ograve" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ograve;</template>
-  <template name="&amp;oacute" description="oacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;oacute;</template>
-  <template name="&amp;ocirc" description="ocirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ocirc;</template>
-  <template name="&amp;otilde" description="otilde" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;otilde;</template>
-  <template name="&amp;ouml" description="ouml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ouml;</template>
-  <template name="&amp;divide" description="divide" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;divide;</template>
-  <template name="&amp;oslash" description="oslash" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;oslash;</template>
-  <template name="&amp;ugrave" description="ugrave" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ugrave;</template>
-  <template name="&amp;uacute" description="uacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;uacute;</template>
-  <template name="&amp;ucirc" description="ucirc" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;ucirc;</template>
-  <template name="&amp;uuml" description="uuml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;uuml;</template>
-  <template name="&amp;yacute" description="yacute" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;yacute;</template>
-  <template name="&amp;thorn" description="thorn" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;thorn;</template>
-  <template name="&amp;yuml" description="yuml" id="net.sf.wdte.ui.templates." context="html" enabled="true">&amp;yuml;</template>
+  <template name="&amp;nbsp" description="no-break space" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;nbsp;</template>
+  <template name="&amp;iexcl" description="iexcl" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;iexcl;</template>
+  <template name="&amp;cent" description="cent" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;cent;</template>
+  <template name="&amp;pound" description="pound" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;pound;</template>
+  <template name="&amp;curren" description="curren" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;curren;</template>
+  <template name="&amp;yen" description="yen" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;yen;</template>
+  <template name="&amp;brvbar" description="brvbar" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;brvbar;</template>
+  <template name="&amp;brkbar" description="brkbar" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;brkbar;</template>
+  <template name="&amp;sect" description="sect" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;sect;</template>
+  <template name="&amp;uml" description="uml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;uml;</template>
+  <template name="&amp;die" description="die" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;die;</template>
+  <template name="&amp;copy" description="copy" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;copy;</template>
+  <template name="&amp;ordf" description="ordf" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ordf;</template>
+  <template name="&amp;laquo" description="laquo" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;laquo;</template>
+  <template name="&amp;not" description="not" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;not;</template>
+  <template name="&amp;shy" description="shy" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;shy;</template>
+  <template name="&amp;reg" description="reg" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;reg;</template>
+  <template name="&amp;macr" description="macr" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;macr;</template>
+  <template name="&amp;hibar" description="hibar" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;hibar;</template>
+  <template name="&amp;deg" description="deg" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;deg;</template>
+  <template name="&amp;plusmn" description="plusmn" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;plusmn;</template>
+  <template name="&amp;sup2" description="sup2" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;sup2;</template>
+  <template name="&amp;sup3" description="sup3" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;sup3;</template>
+  <template name="&amp;acute" description="acute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;acute;</template>
+  <template name="&amp;micro" description="micro" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;micro;</template>
+  <template name="&amp;para" description="para" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;para;</template>
+  <template name="&amp;middot" description="middot" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;middot;</template>
+  <template name="&amp;cedil" description="cedil" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;cedil;</template>
+  <template name="&amp;sup1" description="sup1" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;sup1;</template>
+  <template name="&amp;ordm" description="ordm" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ordm;</template>
+  <template name="&amp;raquo" description="raquo" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;raquo;</template>
+  <template name="&amp;frac14" description="frac14" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;frac14;</template>
+  <template name="&amp;frac12" description="frac12" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;frac12;</template>
+  <template name="&amp;frac34" description="frac34" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;frac34;</template>
+  <template name="&amp;iquest" description="iquest" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;iquest;</template>
+  <template name="&amp;Agrave" description="Agrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Agrave;</template>
+  <template name="&amp;Aacute" description="Aacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Aacute;</template>
+  <template name="&amp;Acirc" description="Acirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Acirc;</template>
+  <template name="&amp;Atilde" description="Atilde" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Atilde;</template>
+  <template name="&amp;Auml" description="Auml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Auml;</template>
+  <template name="&amp;Aring" description="Aring" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Aring;</template>
+  <template name="&amp;AElig" description="AElig" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;AElig;</template>
+  <template name="&amp;Ccedil" description="Ccedil" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ccedil;</template>
+  <template name="&amp;Egrave" description="Egrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Egrave;</template>
+  <template name="&amp;Eacute" description="Eacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Eacute;</template>
+  <template name="&amp;Ecirc" description="Ecirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ecirc;</template>
+  <template name="&amp;Euml" description="Euml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Euml;</template>
+  <template name="&amp;lgrave" description="lgrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;lgrave;</template>
+  <template name="&amp;lacute" description="lacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;lacute;</template>
+  <template name="&amp;lcirc" description="lcirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;lcirc;</template>
+  <template name="&amp;luml" description="luml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;luml;</template>
+  <template name="&amp;ETH" description="ETH" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ETH;</template>
+  <template name="&amp;Ntilde" description="Ntilde" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ntilde;</template>
+  <template name="&amp;Ograve" description="Ograve" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ograve;</template>
+  <template name="&amp;Oacute" description="Oacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Oacute;</template>
+  <template name="&amp;Ocirc" description="Ocirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ocirc;</template>
+  <template name="&amp;Otilde" description="Otilde" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Otilde;</template>
+  <template name="&amp;Ouml" description="Ouml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ouml;</template>
+  <template name="&amp;times" description="times" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;times;</template>
+  <template name="&amp;Oslash" description="Oslash" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Oslash;</template>
+  <template name="&amp;Ugrave" description="Ugrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ugrave;</template>
+  <template name="&amp;Uacute" description="Uacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Uacute;</template>
+  <template name="&amp;Ucirc" description="Ucirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Ucirc;</template>
+  <template name="&amp;Uuml" description="Uuml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Uuml;</template>
+  <template name="&amp;Yacute" description="Yacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;Yacute;</template>
+  <template name="&amp;THORN" description="THORN" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;THORN;</template>
+  <template name="&amp;szlig" description="szlig" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;szlig;</template>
+  <template name="&amp;agrave" description="agrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;agrave;</template>
+  <template name="&amp;aacute" description="aacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;aacute;</template>
+  <template name="&amp;acirc" description="acirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;acirc;</template>
+  <template name="&amp;atilde" description="atilde" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;atilde;</template>
+  <template name="&amp;auml" description="auml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;auml;</template>
+  <template name="&amp;aring" description="aring" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;aring;</template>
+  <template name="&amp;aelig" description="aelig" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;aelig;</template>
+  <template name="&amp;ccedil" description="ccedil" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ccedil;</template>
+  <template name="&amp;egrave" description="egrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;egrave;</template>
+  <template name="&amp;eacute" description="eacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;eacute;</template>
+  <template name="&amp;ecirc" description="ecirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ecirc;</template>
+  <template name="&amp;euml" description="euml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;euml;</template>
+  <template name="&amp;igrave" description="igrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;igrave;</template>
+  <template name="&amp;iacute" description="iacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;iacute;</template>
+  <template name="&amp;icirc" description="icirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;icirc;</template>
+  <template name="&amp;iuml" description="iuml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;iuml;</template>
+  <template name="&amp;eth" description="eth" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;eth;</template>
+  <template name="&amp;ntilde" description="ntilde" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ntilde;</template>
+  <template name="&amp;ograve" description="ograve" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ograve;</template>
+  <template name="&amp;oacute" description="oacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;oacute;</template>
+  <template name="&amp;ocirc" description="ocirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ocirc;</template>
+  <template name="&amp;otilde" description="otilde" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;otilde;</template>
+  <template name="&amp;ouml" description="ouml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ouml;</template>
+  <template name="&amp;divide" description="divide" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;divide;</template>
+  <template name="&amp;oslash" description="oslash" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;oslash;</template>
+  <template name="&amp;ugrave" description="ugrave" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ugrave;</template>
+  <template name="&amp;uacute" description="uacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;uacute;</template>
+  <template name="&amp;ucirc" description="ucirc" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;ucirc;</template>
+  <template name="&amp;uuml" description="uuml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;uuml;</template>
+  <template name="&amp;yacute" description="yacute" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;yacute;</template>
+  <template name="&amp;thorn" description="thorn" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;thorn;</template>
+  <template name="&amp;yuml" description="yuml" id="net.sourceforge.phpdt.html." context="html" enabled="true">&amp;yuml;</template>
 
-  <template name="#00FFFF" description="Aqua (Color Code)" id="net.sf.wdte.ui.templates.aqua" context="html" enabled="true">#00FFFF</template>
-  <template name="#000000" description="Black (Color Code)" id="net.sf.wdte.ui.templates.black" context="html" enabled="true">#000000</template>
-  <template name="#0000FF" description="Blue (Color Code)" id="net.sf.wdte.ui.templates.blue" context="html" enabled="true">#0000FF</template>
-  <template name="#A52A2A" description="Brown (Color Code)" id="net.sf.wdte.ui.templates.brown" context="html" enabled="true">#A52A2A</template>
-  <template name="#00FFFF" description="Cyan (Color Code)" id="net.sf.wdte.ui.templates.cyan" context="html" enabled="true">#00FFFF</template>
-  <template name="#FF00FF" description="Fuchsia (Color Code)" id="net.sf.wdte.ui.templates.fuchsia" context="html" enabled="true">#FF00FF</template>
-  <template name="#FFD700" description="Gold (Color Code)" id="net.sf.wdte.ui.templates.gold" context="html" enabled="true">#FFD700</template>
-  <template name="#808080" description="Gray (Color Code)" id="net.sf.wdte.ui.templates.gray" context="html" enabled="true">#808080</template>
-  <template name="#008000" description="Green (Color Code)" id="net.sf.wdte.ui.templates.green" context="html" enabled="true">#008000</template>
-  <template name="#00FF00" description="Lime (Color Code)" id="net.sf.wdte.ui.templates.lime" context="html" enabled="true">#00FF00</template>
-  <template name="#FF00FF" description="Magenta (Color Code)" id="net.sf.wdte.ui.templates.magenta" context="html" enabled="true">#FF00FF</template>
-  <template name="#800000" description="Maroon (Color Code)" id="net.sf.wdte.ui.templates.maroon" context="html" enabled="true">#800000</template>
-  <template name="#000080" description="Navy (Color Code)" id="net.sf.wdte.ui.templates.navy" context="html" enabled="true">#000080</template>
-  <template name="#808000" description="Olive (Color Code)" id="net.sf.wdte.ui.templates.olive" context="html" enabled="true">#808000</template>
-  <template name="#FFA500" description="Orange (Color Code)" id="net.sf.wdte.ui.templates.orange" context="html" enabled="true">#FFA500</template>
-  <template name="#FFC0CB" description="Pink (Color Code)" id="net.sf.wdte.ui.templates.pink" context="html" enabled="true">#FFC0CB</template>
-  <template name="#800080" description="Purple (Color Code)" id="net.sf.wdte.ui.templates.purple" context="html" enabled="true">#800080</template>
-  <template name="#FF0000" description="Red (Color Code)" id="net.sf.wdte.ui.templates.red" context="html" enabled="true">#FF0000</template>
-  <template name="#C0C0C0" description="Silver (Color Code)" id="net.sf.wdte.ui.templates.silver" context="html" enabled="true">#C0C0C0</template>
-  <template name="#008080" description="Teal (Color Code)" id="net.sf.wdte.ui.templates.teal" context="html" enabled="true">#008080</template>
-  <template name="#FFFFFF" description="White (Color Code)" id="net.sf.wdte.ui.templates.white" context="html" enabled="true">#FFFFFF</template>
-  <template name="#FFFF00" description="Yellow (Color Code)" id="net.sf.wdte.ui.templates.yellow" context="html" enabled="true">#FFFF00</template>
+  <template name="#00FFFF" description="Aqua (Color Code)" id="net.sourceforge.phpdt.html.aqua" context="html" enabled="true">#00FFFF</template>
+  <template name="#000000" description="Black (Color Code)" id="net.sourceforge.phpdt.html.black" context="html" enabled="true">#000000</template>
+  <template name="#0000FF" description="Blue (Color Code)" id="net.sourceforge.phpdt.html.blue" context="html" enabled="true">#0000FF</template>
+  <template name="#A52A2A" description="Brown (Color Code)" id="net.sourceforge.phpdt.html.brown" context="html" enabled="true">#A52A2A</template>
+  <template name="#00FFFF" description="Cyan (Color Code)" id="net.sourceforge.phpdt.html.cyan" context="html" enabled="true">#00FFFF</template>
+  <template name="#FF00FF" description="Fuchsia (Color Code)" id="net.sourceforge.phpdt.html.fuchsia" context="html" enabled="true">#FF00FF</template>
+  <template name="#FFD700" description="Gold (Color Code)" id="net.sourceforge.phpdt.html.gold" context="html" enabled="true">#FFD700</template>
+  <template name="#808080" description="Gray (Color Code)" id="net.sourceforge.phpdt.html.gray" context="html" enabled="true">#808080</template>
+  <template name="#008000" description="Green (Color Code)" id="net.sourceforge.phpdt.html.green" context="html" enabled="true">#008000</template>
+  <template name="#00FF00" description="Lime (Color Code)" id="net.sourceforge.phpdt.html.lime" context="html" enabled="true">#00FF00</template>
+  <template name="#FF00FF" description="Magenta (Color Code)" id="net.sourceforge.phpdt.html.magenta" context="html" enabled="true">#FF00FF</template>
+  <template name="#800000" description="Maroon (Color Code)" id="net.sourceforge.phpdt.html.maroon" context="html" enabled="true">#800000</template>
+  <template name="#000080" description="Navy (Color Code)" id="net.sourceforge.phpdt.html.navy" context="html" enabled="true">#000080</template>
+  <template name="#808000" description="Olive (Color Code)" id="net.sourceforge.phpdt.html.olive" context="html" enabled="true">#808000</template>
+  <template name="#FFA500" description="Orange (Color Code)" id="net.sourceforge.phpdt.html.orange" context="html" enabled="true">#FFA500</template>
+  <template name="#FFC0CB" description="Pink (Color Code)" id="net.sourceforge.phpdt.html.pink" context="html" enabled="true">#FFC0CB</template>
+  <template name="#800080" description="Purple (Color Code)" id="net.sourceforge.phpdt.html.purple" context="html" enabled="true">#800080</template>
+  <template name="#FF0000" description="Red (Color Code)" id="net.sourceforge.phpdt.html.red" context="html" enabled="true">#FF0000</template>
+  <template name="#C0C0C0" description="Silver (Color Code)" id="net.sourceforge.phpdt.html.silver" context="html" enabled="true">#C0C0C0</template>
+  <template name="#008080" description="Teal (Color Code)" id="net.sourceforge.phpdt.html.teal" context="html" enabled="true">#008080</template>
+  <template name="#FFFFFF" description="White (Color Code)" id="net.sourceforge.phpdt.html.white" context="html" enabled="true">#FFFFFF</template>
+  <template name="#FFFF00" description="Yellow (Color Code)" id="net.sourceforge.phpdt.html.yellow" context="html" enabled="true">#FFFF00</template>
 
-  <template name="Aqua" description="Aqua (Color Code)" id="net.sf.wdte.ui.templates.ccaqua" context="html" enabled="true">#00FFFF</template>
-  <template name="Black" description="Black (Color Code)" id="net.sf.wdte.ui.templates.ccblack" context="html" enabled="true">#000000</template>
-  <template name="Blue" description="Blue (Color Code)" id="net.sf.wdte.ui.templates.ccblue" context="html" enabled="true">#0000FF</template>
-  <template name="Brown" description="Brown (Color Code)" id="net.sf.wdte.ui.templates.ccbrown" context="html" enabled="true">#A52A2A</template>
-  <template name="Cyan" description="Cyan (Color Code)" id="net.sf.wdte.ui.templates.cccyan" context="html" enabled="true">#00FFFF</template>
-  <template name="Fuchsia" description="Fuchsia (Color Code)" id="net.sf.wdte.ui.templates.ccfuchsia" context="html" enabled="true">#FF00FF</template>
-  <template name="Gold" description="Gold (Color Code)" id="net.sf.wdte.ui.templates.ccgold" context="html" enabled="true">#FFD700</template>
-  <template name="Gray" description="Gray (Color Code)" id="net.sf.wdte.ui.templates.ccgray" context="html" enabled="true">#808080</template>
-  <template name="Green" description="Green (Color Code)" id="net.sf.wdte.ui.templates.ccgreen" context="html" enabled="true">#008000</template>
-  <template name="Lime" description="Lime (Color Code)" id="net.sf.wdte.ui.templates.cclime" context="html" enabled="true">#00FF00</template>
-  <template name="Magenta" description="Magenta (Color Code)" id="net.sf.wdte.ui.templates.ccmagenta" context="html" enabled="true">#FF00FF</template>
-  <template name="Maroon" description="Maroon (Color Code)" id="net.sf.wdte.ui.templates.ccmaroon" context="html" enabled="true">#800000</template>
-  <template name="Navy" description="Mavy (Color Code)" id="net.sf.wdte.ui.templates.ccnavy" context="html" enabled="true">#000080</template>
-  <template name="Olive" description="Olive (Color Code)" id="net.sf.wdte.ui.templates.ccolive" context="html" enabled="true">#808000</template>
-  <template name="Orange" description="Orange (Color Code)" id="net.sf.wdte.ui.templates.ccorange" context="html" enabled="true">#FFA500</template>
-  <template name="Pink" description="Pink (Color Code)" id="net.sf.wdte.ui.templates.ccpink" context="html" enabled="true">#FFC0CB</template>
-  <template name="Purple" description="Purple (Color Code)" id="net.sf.wdte.ui.templates.ccpurple" context="html" enabled="true">#800080</template>
-  <template name="Red" description="Red (Color Code)" id="net.sf.wdte.ui.templates.ccred" context="html" enabled="true">#FF0000</template>
-  <template name="Silver" description="Silver (Color Code)" id="net.sf.wdte.ui.templates.ccsilver" context="html" enabled="true">#C0C0C0</template>
-  <template name="Teal" description="Teal (Color Code)" id="net.sf.wdte.ui.templates.ccteal" context="html" enabled="true">#008080</template>
-  <template name="White" description="White (Color Code)" id="net.sf.wdte.ui.templates.ccwhite" context="html" enabled="true">#FFFFFF</template>
-  <template name="Yellow" description="Yellow (Color Code)" id="net.sf.wdte.ui.templates.ccyellow" context="html" enabled="true">#FFFF00</template>
-  <template name="&lt;br&gt;" description="&lt;br&gt;" id="net.sf.wdte.ui.templates.br" context="html" enabled="true">&lt;br/&gt;${cursor}</template>
-  <template name="&lt;div&gt;" description="div block with id" id="net.sf.wdte.ui.templates.div" context="html" enabled="true">&lt;div id=&quot;${id}&quot;&gt;${cursor}&lt;/div&gt;</template>
-  <template name="&lt;strong&gt;" description="&lt;strong&gt;" id="net.sf.wdte.ui.templates.strong" context="html" enabled="true">&lt;strong&gt;${cursor}&lt;/strong&gt;</template>
-  <template name="{" description="{* *} (Smarty comment)" id="net.sf.wdte.ui.templates.smarty_comment" context="html" enabled="true">{* ${cursor} *}</template>
-  <template name="{assign" description="{assign var= value= } (Smarty)" id="net.sf.wdte.ui.templates.smarty_assign" context="html" enabled="true">{assign var=&quot;${name}&quot; values=&quot;${value}&quot;}</template>
-  <template name="{capture" description="{capture }{/capture} (Smarty)" id="net.sf.wdte.ui.templates.smarty_capture" context="html" enabled="true">{capture name=${name}}
+  <template name="Aqua" description="Aqua (Color Code)" id="net.sourceforge.phpdt.html.ccaqua" context="html" enabled="true">#00FFFF</template>
+  <template name="Black" description="Black (Color Code)" id="net.sourceforge.phpdt.html.ccblack" context="html" enabled="true">#000000</template>
+  <template name="Blue" description="Blue (Color Code)" id="net.sourceforge.phpdt.html.ccblue" context="html" enabled="true">#0000FF</template>
+  <template name="Brown" description="Brown (Color Code)" id="net.sourceforge.phpdt.html.ccbrown" context="html" enabled="true">#A52A2A</template>
+  <template name="Cyan" description="Cyan (Color Code)" id="net.sourceforge.phpdt.html.cccyan" context="html" enabled="true">#00FFFF</template>
+  <template name="Fuchsia" description="Fuchsia (Color Code)" id="net.sourceforge.phpdt.html.ccfuchsia" context="html" enabled="true">#FF00FF</template>
+  <template name="Gold" description="Gold (Color Code)" id="net.sourceforge.phpdt.html.ccgold" context="html" enabled="true">#FFD700</template>
+  <template name="Gray" description="Gray (Color Code)" id="net.sourceforge.phpdt.html.ccgray" context="html" enabled="true">#808080</template>
+  <template name="Green" description="Green (Color Code)" id="net.sourceforge.phpdt.html.ccgreen" context="html" enabled="true">#008000</template>
+  <template name="Lime" description="Lime (Color Code)" id="net.sourceforge.phpdt.html.cclime" context="html" enabled="true">#00FF00</template>
+  <template name="Magenta" description="Magenta (Color Code)" id="net.sourceforge.phpdt.html.ccmagenta" context="html" enabled="true">#FF00FF</template>
+  <template name="Maroon" description="Maroon (Color Code)" id="net.sourceforge.phpdt.html.ccmaroon" context="html" enabled="true">#800000</template>
+  <template name="Navy" description="Mavy (Color Code)" id="net.sourceforge.phpdt.html.ccnavy" context="html" enabled="true">#000080</template>
+  <template name="Olive" description="Olive (Color Code)" id="net.sourceforge.phpdt.html.ccolive" context="html" enabled="true">#808000</template>
+  <template name="Orange" description="Orange (Color Code)" id="net.sourceforge.phpdt.html.ccorange" context="html" enabled="true">#FFA500</template>
+  <template name="Pink" description="Pink (Color Code)" id="net.sourceforge.phpdt.html.ccpink" context="html" enabled="true">#FFC0CB</template>
+  <template name="Purple" description="Purple (Color Code)" id="net.sourceforge.phpdt.html.ccpurple" context="html" enabled="true">#800080</template>
+  <template name="Red" description="Red (Color Code)" id="net.sourceforge.phpdt.html.ccred" context="html" enabled="true">#FF0000</template>
+  <template name="Silver" description="Silver (Color Code)" id="net.sourceforge.phpdt.html.ccsilver" context="html" enabled="true">#C0C0C0</template>
+  <template name="Teal" description="Teal (Color Code)" id="net.sourceforge.phpdt.html.ccteal" context="html" enabled="true">#008080</template>
+  <template name="White" description="White (Color Code)" id="net.sourceforge.phpdt.html.ccwhite" context="html" enabled="true">#FFFFFF</template>
+  <template name="Yellow" description="Yellow (Color Code)" id="net.sourceforge.phpdt.html.ccyellow" context="html" enabled="true">#FFFF00</template>
+  <template name="&lt;br&gt;" description="&lt;br&gt;" id="net.sourceforge.phpdt.html.br" context="html" enabled="true">&lt;br/&gt;${cursor}</template>
+  <template name="&lt;div&gt;" description="div block with id" id="net.sourceforge.phpdt.html.div" context="html" enabled="true">&lt;div id=&quot;${id}&quot;&gt;${cursor}&lt;/div&gt;</template>
+  <template name="&lt;strong&gt;" description="&lt;strong&gt;" id="net.sourceforge.phpdt.html.strong" context="html" enabled="true">&lt;strong&gt;${cursor}&lt;/strong&gt;</template>
+  <template name="{" description="{* *} (Smarty comment)" id="net.sourceforge.phpdt.html.smarty_comment" context="html" enabled="true">{* ${cursor} *}</template>
+  <template name="{assign" description="{assign var= value= } (Smarty)" id="net.sourceforge.phpdt.html.smarty_assign" context="html" enabled="true">{assign var=&quot;${name}&quot; values=&quot;${value}&quot;}</template>
+  <template name="{capture" description="{capture }{/capture} (Smarty)" id="net.sourceforge.phpdt.html.smarty_capture" context="html" enabled="true">{capture name=${name}}
 ${cursor}
 {/capture}</template>
-<template name="{config_load" description="{config_load} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{config_load file=&quot;${file}&quot;}</template>
-<template name="{config_load" description="{config_load} with section (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{config_load file=&quot;${file}&quot; section=&quot;${section}&quot;}</template>
-<template name="{counter" description="{counter start= skip= print= } (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{counter start=${start} skip=${skip} print=false}</template>
-<template name="{counter" description="{counter} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{counter}</template><template name="{cycle" description="{cycle values= } (Smarty)" id="net.sf.wdte.ui.templates." context="html" enabled="true">{cycle values=&quot;${values}&quot;}</template>
-<template name="{eval" description="{eval var=#conf#} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{eval var=#${conf}#}</template>
-<template name="{eval" description="{eval var=$var} (smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{eval var=$$${var}}</template>
-<template name="{fetch" description="{fetch file=} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{fetch file=&quot;${file}&quot;}</template>
-<template name="{foreach" description="{foreach}{/foreach} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{foreach from=$$${from} item=${item}}
+<template name="{config_load" description="{config_load} (Smarty)" id="net.sourceforge.phpdt.html.smarty_config_load1" context="html" enabled="true">{config_load file=&quot;${file}&quot;}</template>
+<template name="{config_load" description="{config_load} with section (Smarty)" id="net.sourceforge.phpdt.html.smarty_config_load2" context="html" enabled="true">{config_load file=&quot;${file}&quot; section=&quot;${section}&quot;}</template>
+<template name="{counter" description="{counter start= skip= print= } (Smarty)" id="net.sourceforge.phpdt.html.smarty_counter1" context="html" enabled="true">{counter start=${start} skip=${skip} print=false}</template>
+<template name="{counter" description="{counter} (Smarty)" id="net.sourceforge.phpdt.html.smarty_counter2" context="html" enabled="true">{counter}</template><template name="{cycle" description="{cycle values= } (Smarty)" id="net.sourceforge.phpdt.html." context="html" enabled="true">{cycle values=&quot;${values}&quot;}</template>
+<template name="{eval" description="{eval var=#conf#} (Smarty)" id="net.sourceforge.phpdt.html.smarty_eval1" context="html" enabled="true">{eval var=#${conf}#}</template>
+<template name="{eval" description="{eval var=$var} (smarty)" id="net.sourceforge.phpdt.html.smarty_eval2" context="html" enabled="true">{eval var=$$${var}}</template>
+<template name="{fetch" description="{fetch file=} (Smarty)" id="net.sourceforge.phpdt.html.smarty_fetch" context="html" enabled="true">{fetch file=&quot;${file}&quot;}</template>
+<template name="{foreach" description="{foreach}{/foreach} (Smarty)" id="net.sourceforge.phpdt.html.smarty_foreach1" context="html" enabled="true">{foreach from=$$${from} item=${item}}
 ${cursor}
 {/foreach}</template>
-<template name="{foreach" description="{foreach}{/foreach} with key (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{foreach from=$$${from} item=${item} key=${key}}
+<template name="{foreach" description="{foreach}{/foreach} with key (Smarty)" id="net.sourceforge.phpdt.html.smarty_foreach2" context="html" enabled="true">{foreach from=$$${from} item=${item} key=${key}}
 ${cursor}
 {/foreach}</template>
-<template name="{foreach" description="{foreach}{/foreach} with name (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{foreach from=$$${from} item=${item} name=${name}}
+<template name="{foreach" description="{foreach}{/foreach} with name (Smarty)" id="net.sourceforge.phpdt.html.smarty_foreach3" context="html" enabled="true">{foreach from=$$${from} item=${item} name=${name}}
 ${cursor}
 {/foreach}</template>
-<template name="{foreach" description="{foreach}{foreachelse}{/foreach} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{foreach from=$$${from} item=${item}}
+<template name="{foreach" description="{foreach}{foreachelse}{/foreach} (Smarty)" id="net.sourceforge.phpdt.html.smarty_foreach4" context="html" enabled="true">{foreach from=$$${from} item=${item}}
 ${cursor}
 {foreachelse}
 ${cursor}
 {/foreach}</template>
-<template name="{foreach" description="{foreach}{foreachelse}{/foreach} with key (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{foreach from=$$${from} item=${item} key=${key}}
+<template name="{foreach" description="{foreach}{foreachelse}{/foreach} with key (Smarty)" id="net.sourceforge.phpdt.html.smarty_foreach5" context="html" enabled="true">{foreach from=$$${from} item=${item} key=${key}}
 ${cursor}
 {foreachelse}
 ${cursor}
 {/foreach}</template>
-<template name="{foreach" description="{foreach}{foreachelse}{/foreach} with name (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{foreach from=$$${from} item=${item} name=${name}}
+<template name="{foreach" description="{foreach}{foreachelse}{/foreach} with name (Smarty)" id="net.sourceforge.phpdt.html.smarty_foreach6" context="html" enabled="true">{foreach from=$$${from} item=${item} name=${name}}
 ${cursor}
 {foreachelse}
 ${cursor}
 {/foreach}</template>
-<template name="{if" description="{if}{/if} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{if $$${var}}${cursor}{/if}</template><template name="{if" description="{if}{elseif}{/if} (Smarty)" id="net.sf.wdte.ui.templates." context="html" enabled="true">{if $$${var}}
+<template name="{if" description="{if}{/if} (Smarty)" id="net.sourceforge.phpdt.html.smarty_if1" context="html" enabled="true">{if $$${var}}${cursor}{/if}</template><template name="{if" description="{if}{elseif}{/if} (Smarty)" id="net.sourceforge.phpdt.html." context="html" enabled="true">{if $$${var}}
 ${cursor}
 {elseif $$${var2}}
 
-{/if}</template><template name="{if" description="{if}{elseif}{else}{/if} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{if $$${var}}
+{/if}</template><template name="{if" description="{if}{elseif}{else}{/if} (Smarty)" id="net.sourceforge.phpdt.html.smarty_if2" context="html" enabled="true">{if $$${var}}
 ${cursor}
 {elseif $$${var2}}
 
 {else}
 
 {/if}</template>
-<template name="{if" description="{if}{else}{/if} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{if $$${var}}
+<template name="{if" description="{if}{else}{/if} (Smarty)" id="net.sourceforge.phpdt.html.smarty_if3" context="html" enabled="true">{if $$${var}}
 ${cursor}
 {else}
 
-{/if}</template><template name="{include" description="{include file=&quot;&quot;} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{include file=&quot;${file}&quot;}</template>
-<template name="{include_php" description="{include_php file=&quot;&quot;} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{include_php file=&quot;${file}&quot;}</template>
-<template name="{ldelim}" description="{ldelim} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{ldelim}</template>
-<template name="{literal" description="{literal}{/literal} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{literal}
+{/if}</template><template name="{include" description="{include file=&quot;&quot;} (Smarty)" id="net.sourceforge.phpdt.html.smarty_include1" context="html" enabled="true">{include file=&quot;${file}&quot;}</template>
+<template name="{include_php" description="{include_php file=&quot;&quot;} (Smarty)" id="net.sourceforge.phpdt.html.smarty_include2" context="html" enabled="true">{include_php file=&quot;${file}&quot;}</template>
+<template name="{ldelim}" description="{ldelim} (Smarty)" id="net.sourceforge.phpdt.html.smarty_ldelim" context="html" enabled="true">{ldelim}</template>
+<template name="{literal" description="{literal}{/literal} (Smarty)" id="net.sourceforge.phpdt.html.smarty_literal" context="html" enabled="true">{literal}
 ${cursor}
 {/literal}</template>
-<template name="{rdelim}" description="{rdelim} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{rdelim}</template>
-<template name="{section" description="{section }{/section} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{section name=${name} loop=$$${loop}}
+<template name="{rdelim}" description="{rdelim} (Smarty)" id="net.sourceforge.phpdt.html.smarty_rdelim" context="html" enabled="true">{rdelim}</template>
+<template name="{section" description="{section }{/section} (Smarty)" id="net.sourceforge.phpdt.html.smarty_section1" context="html" enabled="true">{section name=${name} loop=$$${loop}}
 ${cursor}
-{/section}</template><template name="{section" description="{section}{sectionelse}{/section} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{section name=${name} loop=$$${loop}}
+{/section}</template><template name="{section" description="{section}{sectionelse}{/section} (Smarty)" id="net.sourceforge.phpdt.html.smarty_section2" context="html" enabled="true">{section name=${name} loop=$$${loop}}
 ${cursor}
 {sectionelse}
 
-{/section}</template><template name="{smarty.cookies.var}" description="{$smarty.cookies.var} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.cookies.${var}}</template>
-<template name="{smarty.env.var}" description="{$smarty.env.var} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.env.${var}}</template>
-<template name="{smarty.get.var}" description="{$smarty.get.var} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.get.${var}}</template>
-<template name="{smarty.now|date_format}" description="{$smarty.now|date_format} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.now|date_format:&quot;%Y-%m-%d %H:%M:%S&quot;}</template>
-<template name="{smarty.now}" description="{$smarty.now} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.now}</template>
-<template name="{smarty.post.var}" description="{$smarty.post.var} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.post.${var}}</template>
-<template name="{smarty.request.var}" description="{$smarty.request.var} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.request.${var}}</template>
-<template name="{smarty.server.var}" description="{$smarty.server.var} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$smarty.server.${var}}</template>
-<template name="{strip" description="{strip}{/strip} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{strip}
+{/section}</template><template name="{smarty.cookies.var}" description="{$smarty.cookies.var} (Smarty)" id="net.sourceforge.phpdt.html.smarty_cookies" context="html" enabled="true">{$$smarty.cookies.${var}}</template>
+<template name="{smarty.env.var}" description="{$smarty.env.var} (Smarty)" id="net.sourceforge.phpdt.html.smarty_env" context="html" enabled="true">{$$smarty.env.${var}}</template>
+<template name="{smarty.get.var}" description="{$smarty.get.var} (Smarty)" id="net.sourceforge.phpdt.html.smarty_get" context="html" enabled="true">{$$smarty.get.${var}}</template>
+<template name="{smarty.now|date_format}" description="{$smarty.now|date_format} (Smarty)" id="net.sourceforge.phpdt.html.smarty__now1" context="html" enabled="true">{$$smarty.now|date_format:&quot;%Y-%m-%d %H:%M:%S&quot;}</template>
+<template name="{smarty.now}" description="{$smarty.now} (Smarty)" id="net.sourceforge.phpdt.html.smarty_now2" context="html" enabled="true">{$$smarty.now}</template>
+<template name="{smarty.post.var}" description="{$smarty.post.var} (Smarty)" id="net.sourceforge.phpdt.html.smarty_post" context="html" enabled="true">{$$smarty.post.${var}}</template>
+<template name="{smarty.request.var}" description="{$smarty.request.var} (Smarty)" id="net.sourceforge.phpdt.html.smarty_request" context="html" enabled="true">{$$smarty.request.${var}}</template>
+<template name="{smarty.server.var}" description="{$smarty.server.var} (Smarty)" id="net.sourceforge.phpdt.html.smarty_server" context="html" enabled="true">{$$smarty.server.${var}}</template>
+<template name="{strip" description="{strip}{/strip} (Smarty)" id="net.sourceforge.phpdt.html.smarty_strip" context="html" enabled="true">{strip}
 ${cursor}
 {/strip}</template>
-<template name="{var|capitalize}" description="{$var|capitalize} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|capitalize}</template>
-<template name="{var|count_characters}" description="{$var|count_characters} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|count_characters}</template>
-<template name="{var|count_paragraphs}" description="{$var|count_paragraphs} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|count_paragraphs}</template>
-<template name="{var|count_sentences}" description="{$var|count_sentences} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|count_sentences}</template>
-<template name="{var|count_words}" description="{$var|count_words} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|count_words}</template>
-<template name="{var|date_format}" description="{$var|date_format} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|date_format:&quot;%Y-%m-%d %H:%M:%S&quot;}</template>
-<template name="{var|default}" description="{$var|default} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|default:&quot;${text}&quot;}</template>
-<template name="{var|escape:value}" description="{$var|escape:value} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|escape:&quot;${value}&quot;}</template>
-<template name="{var|escape}" description="{$var|escape} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|escape}</template>
-<template name="{var|indent:nr}" description="{$var|indent:nr} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|indent:${nr}}</template>
-<template name="{var|indent}" description="{$var|indent} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|indent}</template>
-<template name="{var|lower}" description="{$var|lower} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|lower}</template>
-<template name="{var|nl2br}" description="{$var|nl2br} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|nl2br}</template>
-<template name="{var|regex_replace}" description="{$var|regex_replace} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|regex_replace:&quot;${regex}&quot;:&quot;${replace}&quot;}</template>
-<template name="{var|replace}" description="{$var|replace} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|replace:&quot;${find}&quot;:&quot;${replace}&quot;}</template>
-<template name="{var|spacify}" description="{$var|spacify} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|spacify}</template>
-<template name="{var|string_format}" description="{$var|string_format} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|string_format:&quot;%.2f&quot;}</template>
-<template name="{var|strip_tags}" description="{$var|strip_tags} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|strip_tags}</template>
-<template name="{var|strip}" description="{$var|strip} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|strip}</template>
-<template name="{var|truncate}" description="{$var|truncate} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|truncate:${nr}}</template>
-<template name="{var|upper}" description="{$var|upper} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|upper}</template>
-<template name="{var|wordwrap}" description="{$var|wordwrap} (Smarty)" id="net.sf.wdte.ui.templates.smarty_" context="html" enabled="true">{$$${var}|wordwrap:${nr}:&quot;${sign}&quot;}</template>
+<template name="{var|capitalize}" description="{$var|capitalize} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_capitalize" context="html" enabled="true">{$$${var}|capitalize}</template>
+<template name="{var|count_characters}" description="{$var|count_characters} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_count_charcters" context="html" enabled="true">{$$${var}|count_characters}</template>
+<template name="{var|count_paragraphs}" description="{$var|count_paragraphs} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_count_Paragraphs" context="html" enabled="true">{$$${var}|count_paragraphs}</template>
+<template name="{var|count_sentences}" description="{$var|count_sentences} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_count_sentences" context="html" enabled="true">{$$${var}|count_sentences}</template>
+<template name="{var|count_words}" description="{$var|count_words} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_count_words" context="html" enabled="true">{$$${var}|count_words}</template>
+<template name="{var|date_format}" description="{$var|date_format} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_date_format" context="html" enabled="true">{$$${var}|date_format:&quot;%Y-%m-%d %H:%M:%S&quot;}</template>
+<template name="{var|default}" description="{$var|default} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_default" context="html" enabled="true">{$$${var}|default:&quot;${text}&quot;}</template>
+<template name="{var|escape:value}" description="{$var|escape:value} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_escape1" context="html" enabled="true">{$$${var}|escape:&quot;${value}&quot;}</template>
+<template name="{var|escape}" description="{$var|escape} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_escape2" context="html" enabled="true">{$$${var}|escape}</template>
+<template name="{var|indent:nr}" description="{$var|indent:nr} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_indent1" context="html" enabled="true">{$$${var}|indent:${nr}}</template>
+<template name="{var|indent}" description="{$var|indent} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_indent2" context="html" enabled="true">{$$${var}|indent}</template>
+<template name="{var|lower}" description="{$var|lower} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_lower" context="html" enabled="true">{$$${var}|lower}</template>
+<template name="{var|nl2br}" description="{$var|nl2br} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_nl2br" context="html" enabled="true">{$$${var}|nl2br}</template>
+<template name="{var|regex_replace}" description="{$var|regex_replace} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_regex_replace" context="html" enabled="true">{$$${var}|regex_replace:&quot;${regex}&quot;:&quot;${replace}&quot;}</template>
+<template name="{var|replace}" description="{$var|replace} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_replace" context="html" enabled="true">{$$${var}|replace:&quot;${find}&quot;:&quot;${replace}&quot;}</template>
+<template name="{var|spacify}" description="{$var|spacify} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_spacify" context="html" enabled="true">{$$${var}|spacify}</template>
+<template name="{var|string_format}" description="{$var|string_format} (Smarty)" id="net.sourceforge.phpdt.html.smarty_string_format" context="html" enabled="true">{$$${var}|string_format:&quot;%.2f&quot;}</template>
+<template name="{var|strip_tags}" description="{$var|strip_tags} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_strip_tags" context="html" enabled="true">{$$${var}|strip_tags}</template>
+<template name="{var|strip}" description="{$var|strip} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_strip" context="html" enabled="true">{$$${var}|strip}</template>
+<template name="{var|truncate}" description="{$var|truncate} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_truncate" context="html" enabled="true">{$$${var}|truncate:${nr}}</template>
+<template name="{var|upper}" description="{$var|upper} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_upper" context="html" enabled="true">{$$${var}|upper}</template>
+<template name="{var|wordwrap}" description="{$var|wordwrap} (Smarty)" id="net.sourceforge.phpdt.html.smarty_var_wordwrap" context="html" enabled="true">{$$${var}|wordwrap:${nr}:&quot;${sign}&quot;}</template>
 </templates>
\ No newline at end of file
index 5d3c191..b14c08f 100644 (file)
@@ -405,6 +405,11 @@ OccurrenceAnnotation.label= PHP Marker Occurrences
 phpEditorFontDefiniton.label= Java Editor Text Font
 phpEditorFontDefintion.description= The Java editor text font is used by Java editors.
 
+#--- templates
+templates.php.contextType.name= php
+templates.phpdoc.contextType.name= phpdoc
+templates.html.contextType.name= html
+
 #--- folding
 foldingStructureProvidersExtensionPoint= Folding Structure Providers
 defaultFoldingStructureProviderName= Default PHP Folding
index e0439f7..a767b83 100644 (file)
             class="net.sourceforge.phpdt.internal.ui.preferences.CodeAssistPreferencePage"
             id="net.sourceforge.phpdt.internal.ui.preferences.CodeAssistPreferencePage">
       </page>
-      <page
+            <page
+            name="%templatePageName"
+            category="net.sourceforge.phpdt.internal.ui.preferences.JavaEditorPreferencePage"
+            class="net.sourceforge.phpdt.internal.ui.preferences.JavaTemplatePreferencePage"
+            id="net.sourceforge.phpeclipse.preference.TemplatePreferencePage">
+      </page>
+  <!--      <page
             name="%templatePageName"
             category="net.sourceforge.phpdt.internal.ui.preferences.JavaEditorPreferencePage"
             class="net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage"
             id="net.sourceforge.phpeclipse.preference.TemplatePreferencePage">
       </page>
- <!--     <page
+      <page
             name="Language Settings"
             category="net.sourceforge.phpeclipse.preference.PHPEclipsePreferencePage"
             class="net.sourceforge.phpeclipse.PHPLanguagePreferencePage"
                        preferencesClass="net.sourceforge.phpdt.internal.ui.text.folding.DefaultJavaFoldingPreferenceBlock">
                </provider>
        </extension>
+       
+       <!-- =========================================================================== -->
+<!-- Templates                                                                   -->
+<!-- =========================================================================== -->
+   <extension
+         point="org.eclipse.ui.editors.templates">
+      <contextType
+            name="%templates.php.contextType.name"
+            class="net.sourceforge.phpdt.internal.corext.template.php.JavaContextType"
+            id="java">
+      </contextType>
+      <contextType
+            name="%templates.phpdoc.contextType.name"
+            class="net.sourceforge.phpdt.internal.corext.template.php.JavaDocContextType"
+            id="javadoc">
+      </contextType>
+      <contextType
+            name="%templates.html.contextType.name"
+            class="net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType"
+            id="javadoc">
+      </contextType>
+      <include
+               file="templates/default-templates.xml"
+               translations="templates/default-templates.properties">
+      </include>
+      <include
+               file="templates/default-codetemplates.xml"
+               translations="templates/default-templates.properties">
+      </include>
+   </extension>
 </plugin>
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/formatter/CodeFormatter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/core/formatter/CodeFormatter.java
new file mode 100644 (file)
index 0000000..d977c00
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.core.formatter;
+
+import org.eclipse.text.edits.TextEdit;
+
+/**
+ * Specification for a generic source code formatter.
+ * 
+ * @since 3.0
+ */
+public abstract class CodeFormatter {
+
+       /**
+        * Unknown kind
+        */
+       public static final int K_UNKNOWN = 0x00;
+
+       /**
+        * Kind used to format an expression
+        */
+       public static final int K_EXPRESSION = 0x01;
+       
+       /**
+        * Kind used to format a set of statements
+        */
+       public static final int K_STATEMENTS = 0x02;
+       
+       /**
+        * Kind used to format a set of class body declarations
+        */
+       public static final int K_CLASS_BODY_DECLARATIONS = 0x04;
+       
+       /**
+        * Kind used to format a compilation unit
+        */
+       public static final int K_COMPILATION_UNIT = 0x08;
+
+       /** 
+        * Format <code>source</code>,
+        * and returns a text edit that correspond to the difference between the given string and the formatted string.
+        * It returns null if the given string cannot be formatted.
+        * 
+        * If the offset position is matching a whitespace, the result can include whitespaces. It would be up to the
+        * caller to get rid of preceeding whitespaces.
+        * 
+        * @param kind Use to specify the kind of the code snippet to format. It can be any of these:
+        *                K_EXPRESSION, K_STATEMENTS, K_CLASS_BODY_DECLARATIONS, K_COMPILATION_UNIT, K_UNKNOWN
+        * @param source the source to format
+        * @param offset the given offset to start recording the edits (inclusive).
+        * @param length the given length to stop recording the edits (exclusive).
+        * @param indentationLevel the initial indentation level, used 
+        *      to shift left/right the entire source fragment. An initial indentation
+        *      level of zero or below has no effect.
+        * @param lineSeparator the line separator to use in formatted source,
+        *     if set to <code>null</code>, then the platform default one will be used.
+        * @return the text edit
+        * @throws IllegalArgumentException if offset is lower than 0, length is lower than 0 or
+        * length is greater than source length.
+        */
+       public abstract TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator);
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ASTVisitor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ASTVisitor.java
new file mode 100644 (file)
index 0000000..06b7659
--- /dev/null
@@ -0,0 +1,618 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.compiler;
+
+import net.sourceforge.phpdt.core.compiler.*;
+import net.sourceforge.phpeclipse.internal.compiler.ast.*; 
+import net.sourceforge.phpdt.internal.compiler.lookup.*;
+
+/** 
+ * A visitor for iterating through the parse tree.
+ */
+public abstract class ASTVisitor {
+
+       public void acceptProblem(IProblem problem) {
+               // do nothing by default
+       }
+       public void endVisit(
+               AllocationExpression allocationExpression,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(AND_AND_Expression and_and_Expression, BlockScope scope) {
+               // do nothing by default
+       }
+//     public void endVisit(JavadocArrayQualifiedTypeReference typeRef, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocArraySingleTypeReference typeRef, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocArgumentExpression expression, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocFieldReference fieldRef, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocMessageSend messageSend, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocQualifiedTypeReference typeRef, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocReturnStatement statement, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocSingleNameReference argument, BlockScope scope) {
+//             // do nothing by default
+//     }
+//     public void endVisit(JavadocSingleTypeReference typeRef, BlockScope scope) {
+//             // do nothing by default
+//     }
+       public void endVisit(Argument argument, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ArrayAllocationExpression arrayAllocationExpression,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ArrayInitializer arrayInitializer, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ArrayQualifiedTypeReference arrayQualifiedTypeReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ArrayQualifiedTypeReference arrayQualifiedTypeReference,
+               ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ArrayReference arrayReference, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Assignment assignment, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(AssertStatement assertStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(BinaryExpression binaryExpression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Block block, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Break breakStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Case caseStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(CastExpression castExpression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(CharLiteral charLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ClassLiteralAccess classLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Clinit clinit, ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               CompilationUnitDeclaration compilationUnitDeclaration,
+               CompilationUnitScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(CompoundAssignment compoundAssignment, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ConditionalExpression conditionalExpression,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ConstructorDeclaration constructorDeclaration,
+               ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Continue continueStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(DoStatement doStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(DoubleLiteral doubleLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(EqualExpression equalExpression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ExplicitConstructorCall explicitConstructor,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               ExtendedStringLiteral extendedStringLiteral,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(FalseLiteral falseLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(FieldDeclaration fieldDeclaration, MethodScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(FieldReference fieldReference, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(FloatLiteral floatLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(EmptyStatement emptyStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ForStatement forStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(IfStatement ifStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ImportReference importRef, CompilationUnitScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(Initializer initializer, MethodScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               InstanceOfExpression instanceOfExpression,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(IntLiteral intLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(LabeledStatement labeledStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(LocalDeclaration localDeclaration, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(LongLiteral longLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(MessageSend messageSend, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
+               // do nothing by default
+       }
+//     public void endVisit(StringLiteralConcatenation literal, BlockScope scope) {
+//             // do nothing by default
+//     }
+       public void endVisit(NullLiteral nullLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(OR_OR_Expression or_or_Expression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(PostfixExpression postfixExpression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(PrefixExpression prefixExpression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               QualifiedAllocationExpression qualifiedAllocationExpression,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               QualifiedNameReference qualifiedNameReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               QualifiedSuperReference qualifiedSuperReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               QualifiedThisReference qualifiedThisReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               QualifiedTypeReference qualifiedTypeReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               QualifiedTypeReference qualifiedTypeReference,
+               ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ReturnStatement returnStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               SingleNameReference singleNameReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               SingleTypeReference singleTypeReference,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               SingleTypeReference singleTypeReference,
+               ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(StringLiteral stringLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(SuperReference superReference, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(SwitchStatement switchStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               SynchronizedStatement synchronizedStatement,
+               BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ThisReference thisReference, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(ThrowStatement throwStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(TrueLiteral trueLiteral, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(TryStatement tryStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               TypeDeclaration localTypeDeclaration,
+               BlockScope scope) {
+               // do nothing by default
+       }       
+       public void endVisit(
+               TypeDeclaration memberTypeDeclaration,
+               ClassScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(
+               TypeDeclaration typeDeclaration,
+               CompilationUnitScope scope) {
+               // do nothing by default
+       }       
+       public void endVisit(UnaryExpression unaryExpression, BlockScope scope) {
+               // do nothing by default
+       }
+       public void endVisit(WhileStatement whileStatement, BlockScope scope) {
+               // do nothing by default
+       }
+       public boolean visit(
+               AllocationExpression allocationExpression,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+               // do nothing by default
+       }
+       public boolean visit(AND_AND_Expression and_and_Expression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+//     public boolean visit(JavadocArrayQualifiedTypeReference typeRef, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocArraySingleTypeReference typeRef, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocArgumentExpression expression, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocFieldReference fieldRef, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocMessageSend messageSend, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocQualifiedTypeReference typeRef, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocReturnStatement statement, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocSingleNameReference argument, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+//     public boolean visit(JavadocSingleTypeReference typeRef, BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+       public boolean visit(Argument argument, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ArrayAllocationExpression arrayAllocationExpression,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ArrayInitializer arrayInitializer, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ArrayQualifiedTypeReference arrayQualifiedTypeReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ArrayQualifiedTypeReference arrayQualifiedTypeReference,
+               ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ArrayReference arrayReference, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ArrayTypeReference arrayTypeReference, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ArrayTypeReference arrayTypeReference, ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Assignment assignment, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(AssertStatement assertStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(BinaryExpression binaryExpression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Block block, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Break breakStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Case caseStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(CastExpression castExpression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(CharLiteral charLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ClassLiteralAccess classLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Clinit clinit, ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               CompilationUnitDeclaration compilationUnitDeclaration,
+               CompilationUnitScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(CompoundAssignment compoundAssignment, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ConditionalExpression conditionalExpression,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ConstructorDeclaration constructorDeclaration,
+               ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Continue continueStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(DoStatement doStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(DoubleLiteral doubleLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(EqualExpression equalExpression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(EmptyStatement emptyStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ExplicitConstructorCall explicitConstructor,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               ExtendedStringLiteral extendedStringLiteral,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(FalseLiteral falseLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(FieldReference fieldReference, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(FloatLiteral floatLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ForStatement forStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(IfStatement ifStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ImportReference importRef, CompilationUnitScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(Initializer initializer, MethodScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               InstanceOfExpression instanceOfExpression,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(IntLiteral intLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(LabeledStatement labeledStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(LocalDeclaration localDeclaration, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(LongLiteral longLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(MessageSend messageSend, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+//     public boolean visit(
+//                     StringLiteralConcatenation literal,
+//                     BlockScope scope) {
+//             return true; // do nothing by default, keep traversing
+//     }
+       public boolean visit(NullLiteral nullLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(OR_OR_Expression or_or_Expression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(PostfixExpression postfixExpression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(PrefixExpression prefixExpression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               QualifiedAllocationExpression qualifiedAllocationExpression,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               QualifiedNameReference qualifiedNameReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               QualifiedSuperReference qualifiedSuperReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               QualifiedThisReference qualifiedThisReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               QualifiedTypeReference qualifiedTypeReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               QualifiedTypeReference qualifiedTypeReference,
+               ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               SingleNameReference singleNameReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               SingleTypeReference singleTypeReference,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               SingleTypeReference singleTypeReference,
+               ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(StringLiteral stringLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(SuperReference superReference, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(SwitchStatement switchStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               SynchronizedStatement synchronizedStatement,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ThisReference thisReference, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(ThrowStatement throwStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(TrueLiteral trueLiteral, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(TryStatement tryStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               TypeDeclaration localTypeDeclaration,
+               BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(
+               TypeDeclaration memberTypeDeclaration,
+               ClassScope scope) {
+               return true; // do nothing by default, keep traversing
+       }       
+       public boolean visit(
+               TypeDeclaration typeDeclaration,
+               CompilationUnitScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(UnaryExpression unaryExpression, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+       public boolean visit(WhileStatement whileStatement, BlockScope scope) {
+               return true; // do nothing by default, keep traversing
+       }
+}
index 3ff7c78..dab8298 100644 (file)
@@ -26,7 +26,7 @@ import net.sourceforge.phpdt.internal.core.util.CommentRecorderParser;
 import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.AnonymousLocalTypeDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Argument;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.ConstructorDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.ExplicitConstructorCall;
@@ -516,7 +516,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
   //                   new SingleNameReference(
   //                           identifierStack[identifierPtr],
   //                           identifierPositionStack[identifierPtr--]);
-  //           ref.bits &= ~AstNode.RestrictiveFlagMASK;
+  //           ref.bits &= ~ASTNode.RestrictiveFlagMASK;
   //           ref.bits |= LOCAL | FIELD;
   //           if (reportReferenceInfo) {
   //                   this.addUnknownRef(ref);
@@ -543,7 +543,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
   //                   (int) (identifierPositionStack[identifierPtr + 1] >> 32),
   //   // sourceStart
   //    (int) identifierPositionStack[identifierPtr + length]); // sourceEnd
-  //   ref.bits &= ~AstNode.RestrictiveFlagMASK;
+  //   ref.bits &= ~ASTNode.RestrictiveFlagMASK;
   //   ref.bits |= LOCAL | FIELD;
   //   if (reportReferenceInfo) {
   //           this.addUnknownRef(ref);
@@ -586,7 +586,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
     // }
     // collect the top level ast nodes
     int length = 0;
-    AstNode[] nodes = null;
+    ASTNode[] nodes = null;
     if (sourceType == null) {
       if (isInRange) {
         requestor.enterCompilationUnit();
@@ -600,9 +600,9 @@ public class SourceElementParser extends CommentRecorderParser {//extends
         //                     (currentPackage == null ? 0 : 1)
         //                     + (imports == null ? 0 : imports.length)
         //                     + (types == null ? 0 : types.length);
-        //             nodes = new AstNode[length];
+        //             nodes = new ASTNode[length];
         length = (imports == null ? 0 : imports.length) + types.size();
-        nodes = new AstNode[length];
+        nodes = new ASTNode[length];
         int index = 0;
         //             if (currentPackage != null) {
         //                     nodes[index++] = currentPackage;
@@ -614,7 +614,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
         }
 
         for (int i = 0, max = types.size(); i < max; i++) {
-          nodes[index++] = (AstNode) types.get(i);
+          nodes[index++] = (ASTNode) types.get(i);
         }
       }
     } else {
@@ -622,9 +622,9 @@ public class SourceElementParser extends CommentRecorderParser {//extends
       ArrayList types = parsedUnit.types;
       if (types != null) {
         length = types.size();
-        nodes = new AstNode[length];
+        nodes = new ASTNode[length];
         for (int i = 0, max = types.size(); i < max; i++) {
-          nodes[i] = (AstNode) types.get(i);
+          nodes[i] = (ASTNode) types.get(i);
         }
       }
     }
@@ -633,7 +633,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
     if (nodes != null && length > 0) {
       quickSort(nodes, 0, length - 1);
       for (int i = 0; i < length; i++) {
-        AstNode node = nodes[i];
+        ASTNode node = nodes[i];
                                if (node instanceof ImportReference) {
                                        ImportReference importRef = (ImportReference)node;
 //                                     if (node == parsedUnit.currentPackage) {
@@ -912,7 +912,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
 //     }
   }
   public void notifySourceElementRequestor(TypeDeclaration typeDeclaration, boolean notifyTypePresence) {
-    //// public void notifySourceElementRequestor(AstNode typeDeclaration,
+    //// public void notifySourceElementRequestor(ASTNode typeDeclaration,
     // boolean notifyTypePresence) {
 
     // range check
@@ -1241,10 +1241,10 @@ public class SourceElementParser extends CommentRecorderParser {//extends
   /**
    * Sort the given ast nodes by their positions.
    */
-  private static void quickSort(AstNode[] sortedCollection, int left, int right) {
+  private static void quickSort(ASTNode[] sortedCollection, int left, int right) {
     int original_left = left;
     int original_right = right;
-    AstNode mid = sortedCollection[(left + right) / 2];
+    ASTNode mid = sortedCollection[(left + right) / 2];
     do {
       while (sortedCollection[left].sourceStart < mid.sourceStart) {
         left++;
@@ -1253,7 +1253,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
         right--;
       }
       if (left <= right) {
-        AstNode tmp = sortedCollection[left];
+        ASTNode tmp = sortedCollection[left];
         sortedCollection[left] = sortedCollection[right];
         sortedCollection[right] = tmp;
         left++;
@@ -1297,7 +1297,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
   }
 
   private void visitIfNeeded(AbstractMethodDeclaration method) {
-    if (this.localDeclarationVisitor != null && (method.bits & AstNode.HasLocalTypeMASK) != 0) {
+    if (this.localDeclarationVisitor != null && (method.bits & ASTNode.HasLocalTypeMASK) != 0) {
       if (method.statements != null) {
         int statementsLength = method.statements.length;
         for (int i = 0; i < statementsLength; i++)
@@ -1308,7 +1308,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
 
   //private void visitIfNeeded(FieldDeclaration field) {
   //   if (this.localDeclarationVisitor != null
-  //           && (field.bits & AstNode.HasLocalTypeMASK) != 0) {
+  //           && (field.bits & ASTNode.HasLocalTypeMASK) != 0) {
   //                   if (field.initialization != null) {
   //                           field.initialization.traverse(this.localDeclarationVisitor, null);
   //                   }
@@ -1317,7 +1317,7 @@ public class SourceElementParser extends CommentRecorderParser {//extends
   //
   //private void visitIfNeeded(Initializer initializer) {
   //   if (this.localDeclarationVisitor != null
-  //           && (initializer.bits & AstNode.HasLocalTypeMASK) != 0) {
+  //           && (initializer.bits & ASTNode.HasLocalTypeMASK) != 0) {
   //                   if (initializer.block != null) {
   //                           initializer.block.traverse(this.localDeclarationVisitor, null);
   //                   }
index d488c0e..e483357 100644 (file)
@@ -17,7 +17,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.TryStatement;
 
 /**
@@ -42,7 +42,7 @@ public class ExceptionHandlingFlowContext extends FlowContext {
        
        public ExceptionHandlingFlowContext(
                FlowContext parent,
-               AstNode associatedNode,
+               ASTNode associatedNode,
                ReferenceBinding[] handledExceptions,
                BlockScope scope,
                UnconditionalFlowInfo flowInfo) {
@@ -71,7 +71,7 @@ public class ExceptionHandlingFlowContext extends FlowContext {
        }
 
        public void complainIfUnusedExceptionHandlers(
-               AstNode[] exceptionHandlers,
+               ASTNode[] exceptionHandlers,
                BlockScope scope,
                TryStatement tryStatement) {
                // report errors for unreachable exception handlers
@@ -135,7 +135,7 @@ public class ExceptionHandlingFlowContext extends FlowContext {
                ReferenceBinding exceptionType,
                UnconditionalFlowInfo flowInfo,
                TypeBinding raisedException,
-               AstNode invocationSite,
+               ASTNode invocationSite,
                boolean wasAlreadyDefinitelyCaught) {
                        
                int index = indexes.get(exceptionType);
index 972d228..21644b3 100644 (file)
@@ -14,7 +14,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.VariableBinding;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Reference;
 
 /**
@@ -27,7 +27,7 @@ public class FinallyFlowContext extends FlowContext {
        VariableBinding finalVariables[];
        int assignCount;
        
-       public FinallyFlowContext(FlowContext parent, AstNode associatedNode) {
+       public FinallyFlowContext(FlowContext parent, ASTNode associatedNode) {
                super(parent, associatedNode);
        }
 
index 360ffea..11624b5 100644 (file)
@@ -19,7 +19,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants;
 import net.sourceforge.phpdt.internal.compiler.lookup.VariableBinding;
 import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Reference;
 import net.sourceforge.phpeclipse.internal.compiler.ast.TryStatement;
 
@@ -29,12 +29,12 @@ import net.sourceforge.phpeclipse.internal.compiler.ast.TryStatement;
  */
 public class FlowContext implements TypeConstants {
        
-       public AstNode associatedNode;
+       public ASTNode associatedNode;
        public FlowContext parent;
 
        public final static FlowContext NotContinuableContext = new FlowContext(null, null);
                
-       public FlowContext(FlowContext parent, AstNode associatedNode) {
+       public FlowContext(FlowContext parent, ASTNode associatedNode) {
 
                this.parent = parent;
                this.associatedNode = associatedNode;
@@ -47,7 +47,7 @@ public class FlowContext implements TypeConstants {
        
        public void checkExceptionHandlers(
                TypeBinding[] raisedExceptions,
-               AstNode location,
+               ASTNode location,
                FlowInfo flowInfo,
                BlockScope scope) {
 
@@ -73,7 +73,7 @@ public class FlowContext implements TypeConstants {
                FlowContext traversedContext = this;
 
                while (traversedContext != null) {
-                       AstNode sub;
+                       ASTNode sub;
                        if (((sub = traversedContext.subRoutine()) != null) && sub.cannotReturn()) {
                                // traversing a non-returning subroutine means that all unhandled 
                                // exceptions will actually never get sent...
@@ -182,7 +182,7 @@ public class FlowContext implements TypeConstants {
 
        public void checkExceptionHandlers(
                TypeBinding raisedException,
-               AstNode location,
+               ASTNode location,
                FlowInfo flowInfo,
                BlockScope scope) {
 
@@ -193,7 +193,7 @@ public class FlowContext implements TypeConstants {
                // until the point where it is safely handled (Smarter - see comment at the end)
                FlowContext traversedContext = this;
                while (traversedContext != null) {
-                       AstNode sub;
+                       ASTNode sub;
                        if (((sub = traversedContext.subRoutine()) != null) && sub.cannotReturn()) {
                                // traversing a non-returning subroutine means that all unhandled 
                                // exceptions will actually never get sent...
@@ -456,7 +456,7 @@ public class FlowContext implements TypeConstants {
        void removeFinalAssignmentIfAny(Reference reference) {
        }
 
-       public AstNode subRoutine() {
+       public ASTNode subRoutine() {
 
                return null;
        }
index 83cb333..11a8759 100644 (file)
@@ -13,7 +13,7 @@ package net.sourceforge.phpdt.internal.compiler.flow;
 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 
 /**
  * Reflects the context of code analysis, keeping track of enclosing
@@ -23,12 +23,12 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
 
        public int exceptionCount;
        public TypeBinding[] thrownExceptions = new TypeBinding[5];
-       public AstNode[] exceptionThrowers = new AstNode[5];
+       public ASTNode[] exceptionThrowers = new ASTNode[5];
        public FlowInfo[] exceptionThrowerFlowInfos = new FlowInfo[5];
        
        public InitializationFlowContext(
                FlowContext parent,
-               AstNode associatedNode,
+               ASTNode associatedNode,
                BlockScope scope) {
                super(
                        parent,
@@ -65,7 +65,7 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
                ReferenceBinding exceptionType,
                UnconditionalFlowInfo flowInfo,
                TypeBinding raisedException,
-               AstNode invocationSite,
+               ASTNode invocationSite,
                boolean wasMasked) {
                        
                // even if unreachable code, need to perform unhandled exception diagnosis
@@ -80,7 +80,7 @@ public class InitializationFlowContext extends ExceptionHandlingFlowContext {
                        System.arraycopy(
                                exceptionThrowers,
                                0,
-                               (exceptionThrowers = new AstNode[size * 2]),
+                               (exceptionThrowers = new ASTNode[size * 2]),
                                0,
                                size);
                        System.arraycopy(
index 13af45c..e927a45 100644 (file)
@@ -10,7 +10,7 @@
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.compiler.flow;
 
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 
 /**
  * Reflects the context of code analysis, keeping track of enclosing
@@ -22,7 +22,7 @@ public class InsideSubRoutineFlowContext extends FlowContext {
        
        public InsideSubRoutineFlowContext(
                FlowContext parent,
-               AstNode associatedNode) {
+               ASTNode associatedNode) {
                super(parent, associatedNode);
                this.initsOnReturn = FlowInfo.DEAD_END;                         
        }
@@ -42,7 +42,7 @@ public class InsideSubRoutineFlowContext extends FlowContext {
                return associatedNode.cannotReturn();
        }
        
-       public AstNode subRoutine() {
+       public ASTNode subRoutine() {
                return associatedNode;
        }
        
index 7192673..97d94ed 100644 (file)
@@ -13,7 +13,7 @@ package net.sourceforge.phpdt.internal.compiler.flow;
 import net.sourceforge.phpdt.core.compiler.CharOperation;
 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 
 /**
  * Reflects the context of code analysis, keeping track of enclosing
@@ -25,7 +25,7 @@ public class LabelFlowContext extends SwitchFlowContext {
        
        public LabelFlowContext(
                FlowContext parent,
-               AstNode associatedNode,
+               ASTNode associatedNode,
                char[] labelName,
                Label breakLabel,
                BlockScope scope) {
index 56556e8..21239c1 100644 (file)
@@ -16,7 +16,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
 import net.sourceforge.phpdt.internal.compiler.lookup.VariableBinding;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Reference;
 
 /**
@@ -34,7 +34,7 @@ public class LoopingFlowContext extends SwitchFlowContext {
        
        public LoopingFlowContext(
                FlowContext parent,
-               AstNode associatedNode,
+               ASTNode associatedNode,
                Label breakLabel,
                Label continueLabel,
                Scope associatedScope) {
index dc4f1e5..e07bb19 100644 (file)
@@ -11,7 +11,7 @@
 package net.sourceforge.phpdt.internal.compiler.flow;
 
 import net.sourceforge.phpdt.internal.compiler.codegen.Label;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 
 /**
  * Reflects the context of code analysis, keeping track of enclosing
@@ -23,7 +23,7 @@ public class SwitchFlowContext extends FlowContext {
        
        public SwitchFlowContext(
                FlowContext parent,
-               AstNode associatedNode,
+               ASTNode associatedNode,
                Label breakLabel) {
                super(parent, associatedNode);
                this.breakLabel = breakLabel;
index 3740e12..685d8cb 100644 (file)
@@ -15,7 +15,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Statement;
 
 /**
@@ -144,7 +144,7 @@ public class UnconditionalFlowInfo extends FlowInfo {
        public boolean complainIfUnreachable(Statement statement, BlockScope scope, boolean didAlreadyComplain) {
        
                if ((this.reachMode & UNREACHABLE) != 0) {
-                       statement.bits &= ~AstNode.IsReachableMASK;
+                       statement.bits &= ~ASTNode.IsReachableMASK;
                        boolean reported = this == DEAD_END;
                        if (!didAlreadyComplain && reported) {
                                scope.problemReporter().unreachableCode(statement);
index 429d073..f366aaa 100644 (file)
@@ -224,7 +224,7 @@ public class BlockScope extends Scope {
 //                             // do not report fake used variable
 //                             if (local.useFlag == LocalVariableBinding.UNUSED
 //                                     && (local.declaration != null) // unused (and non secret) local
-//                                     && ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
+//                                     && ((local.declaration.bits & ASTNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
 //                                             
 //                                     if (!(local.declaration instanceof Argument))  // do not report unused catch arguments
 //                                             this.problemReporter().unusedLocalVariable(local.declaration);
@@ -255,7 +255,7 @@ public class BlockScope extends Scope {
 //                                     if (this.offset > 0xFFFF) { // no more than 65535 words of locals
 //                                             this.problemReporter().noMoreAvailableSpaceForLocal(
 //                                                     local, 
-//                                                     local.declaration == null ? (AstNode)this.methodScope().referenceContext : local.declaration);
+//                                                     local.declaration == null ? (ASTNode)this.methodScope().referenceContext : local.declaration);
 //                                     }
 //                             } else {
 //                                     local.resolvedPosition = -1; // not generated
index 4fe05b4..2cae6de 100644 (file)
@@ -243,7 +243,7 @@ public class MethodScope extends BlockScope {
 //                     // do not report fake used variable
 //                     if (isReportingUnusedArgument
 //                                     && local.useFlag == LocalVariableBinding.UNUSED
-//                                     && ((local.declaration.bits & AstNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
+//                                     && ((local.declaration.bits & ASTNode.IsLocalDeclarationReachableMASK) != 0)) { // declaration is reachable
 //                             this.problemReporter().unusedArgument(local.declaration);
 //                     }
 //
@@ -276,7 +276,7 @@ public class MethodScope extends BlockScope {
 //                                     this.offset++;
 //                             }
 //                             if (this.offset > 0xFF) { // no more than 255 words of arguments
-//                                     this.problemReporter().noMoreAvailableSpaceForArgument(argument, (AstNode)this.referenceContext); 
+//                                     this.problemReporter().noMoreAvailableSpaceForArgument(argument, (ASTNode)this.referenceContext); 
 //                             }
 //                     }
 //             }
index 41a9404..f1eb422 100644 (file)
@@ -21,7 +21,7 @@ import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
 import net.sourceforge.phpdt.internal.compiler.util.Util;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
 import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.FieldDeclaration;
 import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference;
@@ -1440,7 +1440,7 @@ public class Parser //extends PHPParserSuperclass
     if (astPtr == 0) {
       compilationUnit.types.add(methodDecl);
     } else {
-      AstNode node = astStack[astPtr];
+      ASTNode node = astStack[astPtr];
       if (node instanceof TypeDeclaration) {
         TypeDeclaration typeDecl = ((TypeDeclaration) node);
         if (typeDecl.methods == null) {
@@ -3545,10 +3545,10 @@ public class Parser //extends PHPParserSuperclass
   //ast stack
   final static int AstStackIncrement = 100;
   protected int astPtr;
-  protected AstNode[] astStack = new AstNode[AstStackIncrement];
+  protected ASTNode[] astStack = new ASTNode[AstStackIncrement];
   protected int astLengthPtr;
   protected int[] astLengthStack;
-  AstNode[] noAstNodes = new AstNode[AstStackIncrement];
+  ASTNode[] noAstNodes = new ASTNode[AstStackIncrement];
   public CompilationUnitDeclaration compilationUnit; /*
                                                       * the result from parse()
                                                       */
@@ -3975,7 +3975,7 @@ public class Parser //extends PHPParserSuperclass
       astLengthStack[astLengthPtr] = pos;
     }
   }
-  protected void pushOnAstStack(AstNode node) {
+  protected void pushOnAstStack(ASTNode node) {
     /*
      * add a new obj on top of the ast stack
      */
@@ -3983,8 +3983,8 @@ public class Parser //extends PHPParserSuperclass
       astStack[++astPtr] = node;
     } catch (IndexOutOfBoundsException e) {
       int oldStackLength = astStack.length;
-      AstNode[] oldStack = astStack;
-      astStack = new AstNode[oldStackLength + AstStackIncrement];
+      ASTNode[] oldStack = astStack;
+      astStack = new ASTNode[oldStackLength + AstStackIncrement];
       System.arraycopy(oldStack, 0, astStack, 0, oldStackLength);
       astPtr = oldStackLength;
       astStack[astPtr] = node;
index 8290a0c..c13f9f6 100644 (file)
@@ -10,7 +10,7 @@
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.compiler.parser;
 
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Block;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Statement;
 
@@ -187,7 +187,7 @@ public Parser parser(){
 /* 
  * Answer the associated parsed structure
  */
-public AstNode parseTree(){
+public ASTNode parseTree(){
        return null;
 }
 /*
index 5ee16b9..744a7ab 100644 (file)
@@ -97,7 +97,7 @@ public class UnitParser extends Parser {
 
     //         int astLength = astStack.length;
     //         if (noAstNodes.length < astLength){
-    //                 noAstNodes = new AstNode[astLength];
+    //                 noAstNodes = new ASTNode[astLength];
     //                 //System.out.println("Resized AST stacks : "+ astLength);
     //         
     //         }
@@ -302,8 +302,8 @@ public class UnitParser extends Parser {
     // field.initialization = expressionStack[expressionPtr];
     // 
     // // mark field with local type if one was found during parsing
-    // if ((type.bits & AstNode.HasLocalTypeMASK) != 0) {
-    //         field.bits |= AstNode.HasLocalTypeMASK;
+    // if ((type.bits & ASTNode.HasLocalTypeMASK) != 0) {
+    //         field.bits |= ASTNode.HasLocalTypeMASK;
     // }       
   }
   // A P I
@@ -337,8 +337,8 @@ public class UnitParser extends Parser {
     // ini.block = ((Initializer) astStack[astPtr]).block;
     // 
     // // mark initializer with local type if one was found during parsing
-    // if ((type.bits & AstNode.HasLocalTypeMASK) != 0) {
-    //         ini.bits |= AstNode.HasLocalTypeMASK;
+    // if ((type.bits & ASTNode.HasLocalTypeMASK) != 0) {
+    //         ini.bits |= ASTNode.HasLocalTypeMASK;
     // }       
   }
   // A P I
index 78baf7d..29ba040 100644 (file)
@@ -39,7 +39,7 @@ import net.sourceforge.phpeclipse.internal.compiler.ast.Argument;
 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayAllocationExpression;
 import net.sourceforge.phpeclipse.internal.compiler.ast.ArrayReference;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Assignment;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
+import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
 import net.sourceforge.phpeclipse.internal.compiler.ast.BinaryExpression;
 import net.sourceforge.phpeclipse.internal.compiler.ast.BranchStatement;
 import net.sourceforge.phpeclipse.internal.compiler.ast.Case;
@@ -87,7 +87,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.Unclassified, arguments, arguments, Error | Abort, 0,
         0);
   }
-  public void abortDueToInternalError(String errorMessage, AstNode location) {
+  public void abortDueToInternalError(String errorMessage, ASTNode location) {
     String[] arguments = new String[]{errorMessage};
     this.handle(IProblem.Unclassified, arguments, arguments, Error | Abort,
         location.sourceStart, location.sourceEnd);
@@ -135,7 +135,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         method.sourceStart, method.sourceEnd, method, method
             .compilationResult());
   }
-  public void alreadyDefinedLabel(char[] labelName, AstNode location) {
+  public void alreadyDefinedLabel(char[] labelName, ASTNode location) {
     String[] arguments = new String[]{new String(labelName)};
     this.handle(IProblem.DuplicateLabel, arguments, arguments,
         location.sourceStart, location.sourceEnd);
@@ -251,7 +251,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.CannotAllocateVoidArray, NoArgument, NoArgument,
         expression.sourceStart, expression.sourceEnd);
   }
-  public void cannotAssignToFinalField(FieldBinding field, AstNode location) {
+  public void cannotAssignToFinalField(FieldBinding field, ASTNode location) {
     this.handle(IProblem.FinalFieldAssignment, new String[]{
         (field.declaringClass == null ? "array" : new String(
             field.declaringClass.readableName())), //$NON-NLS-1$
@@ -262,13 +262,13 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         location.sourceEnd);
   }
   public void cannotAssignToFinalLocal(LocalVariableBinding local,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(local.readableName())};
     this.handle(IProblem.NonBlankFinalLocalAssignment, arguments, arguments,
         location.sourceStart, location.sourceEnd);
   }
   public void cannotAssignToFinalOuterLocal(LocalVariableBinding local,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(local.readableName())};
     this.handle(IProblem.FinalOuterLocalAssignment, arguments, arguments,
         location.sourceStart, location.sourceEnd);
@@ -305,12 +305,12 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         typeRef.sourceStart, typeRef.sourceEnd);
   }
   public void cannotReferToNonFinalOuterLocal(LocalVariableBinding local,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(local.readableName())};
     this.handle(IProblem.OuterLocalMustBeFinal, arguments, arguments,
         location.sourceStart, location.sourceEnd);
   }
-  public void cannotReturnInInitializer(AstNode location) {
+  public void cannotReturnInInitializer(ASTNode location) {
     this.handle(IProblem.CannotReturnInInitializer, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
@@ -326,7 +326,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         .shortReadableName())}, exceptionType.sourceStart,
         exceptionType.sourceEnd);
   }
-  public void cannotUseSuperInJavaLangObject(AstNode reference) {
+  public void cannotUseSuperInJavaLangObject(ASTNode reference) {
     this.handle(IProblem.ObjectHasNoSuperclass, NoArgument, NoArgument,
         reference.sourceStart, reference.sourceEnd);
   }
@@ -607,14 +607,14 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.NumericValueOutOfRange, arguments, arguments,
         lit.sourceStart, lit.sourceEnd);
   }
-  public void deprecatedField(FieldBinding field, AstNode location) {
+  public void deprecatedField(FieldBinding field, ASTNode location) {
     this.handle(IProblem.UsingDeprecatedField,
         new String[]{new String(field.declaringClass.readableName()),
             new String(field.name)}, new String[]{
             new String(field.declaringClass.shortReadableName()),
             new String(field.name)}, location.sourceStart, location.sourceEnd);
   }
-  public void deprecatedMethod(MethodBinding method, AstNode location) {
+  public void deprecatedMethod(MethodBinding method, ASTNode location) {
     if (method.isConstructor())
       this.handle(IProblem.UsingDeprecatedConstructor, new String[]{
           new String(method.declaringClass.readableName()),
@@ -630,7 +630,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
               new String(method.selector), parametersAsShortString(method)},
           location.sourceStart, location.sourceEnd);
   }
-  public void deprecatedType(TypeBinding type, AstNode location) {
+  public void deprecatedType(TypeBinding type, ASTNode location) {
     if (location == null)
       return; // 1G828DN - no type ref for synthetic arguments
     this.handle(IProblem.UsingDeprecatedType, new String[]{new String(type
@@ -665,7 +665,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         arguments, reference.sourceStart, reference.sourceEnd);
   }
   public void duplicateInitializationOfFinalLocal(LocalVariableBinding local,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(local.readableName())};
     this.handle(IProblem.DuplicateFinalLocalInitialization, arguments,
         arguments, location.sourceStart, location.sourceEnd);
@@ -754,7 +754,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         new String(messageSend.selector), shortBuffer.toString()},
         messageSend.sourceStart, messageSend.sourceEnd);
   }
-  public void errorThisSuperInStatic(AstNode reference) {
+  public void errorThisSuperInStatic(ASTNode reference) {
     String[] arguments = new String[]{reference.isSuper() ? "super" : "this"}; //$NON-NLS-2$ //$NON-NLS-1$
     this.handle(IProblem.ThisInStaticContext, arguments, arguments,
         reference.sourceStart, reference.sourceEnd);
@@ -1014,7 +1014,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         localDecl.sourceStart, localDecl.sourceEnd);
   }
   public void illegalPrimitiveOrArrayTypeForEnclosingInstance(
-      TypeBinding enclosingType, AstNode location) {
+      TypeBinding enclosingType, ASTNode location) {
     this.handle(IProblem.IllegalPrimitiveOrArrayTypeForEnclosingInstance,
         new String[]{new String(enclosingType.readableName())},
         new String[]{new String(enclosingType.shortReadableName())},
@@ -1050,7 +1050,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.IllegalVisibilityModifierForInterfaceMemberType,
         arguments, arguments, type.sourceStart(), type.sourceEnd());
   }
-  public void illegalVoidExpression(AstNode location) {
+  public void illegalVoidExpression(ASTNode location) {
     this.handle(IProblem.InvalidVoidExpression, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
@@ -1223,7 +1223,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         NoArgument, fieldDecl.sourceStart, fieldDecl.sourceEnd);
   }
   public void innerTypesCannotDeclareStaticInitializers(
-      ReferenceBinding innerType, AstNode location) {
+      ReferenceBinding innerType, ASTNode location) {
     this.handle(IProblem.CannotDefineStaticInitializerInLocalType,
         new String[]{new String(innerType.readableName())},
         new String[]{new String(innerType.shortReadableName())},
@@ -1240,7 +1240,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.InterfaceCannotHaveInitializers, arguments, arguments,
         fieldDecl.sourceStart, fieldDecl.sourceEnd);
   }
-  public void invalidBreak(AstNode location) {
+  public void invalidBreak(ASTNode location) {
     this.handle(IProblem.InvalidBreak, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
@@ -1293,7 +1293,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         parametersAsShortString(targetConstructor)}, statement.sourceStart,
         statement.sourceEnd);
   }
-  public void invalidContinue(AstNode location) {
+  public void invalidContinue(ASTNode location) {
     this.handle(IProblem.InvalidContinue, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
@@ -1601,7 +1601,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
             new String(type.shortReadableName())}, expression.sourceStart,
         expression.sourceEnd);
   }
-  public void invalidParenthesizedExpression(AstNode reference) {
+  public void invalidParenthesizedExpression(ASTNode reference) {
     this.handle(IProblem.InvalidParenthesizedExpression, NoArgument,
         NoArgument, reference.sourceStart, reference.sourceEnd);
   }
@@ -1681,7 +1681,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         new String(type.sourceName())}, superinterfaceRef.sourceStart,
         superinterfaceRef.sourceEnd);
   }
-  public void invalidType(AstNode location, TypeBinding type) {
+  public void invalidType(ASTNode location, TypeBinding type) {
     int flag = IProblem.UndefinedType; // default
     switch (type.problemId()) {
       case NotFound :
@@ -1736,7 +1736,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
             : compUnitDecl.sourceEnd);
   }
   public void maskedExceptionHandler(ReferenceBinding exceptionType,
-      AstNode location) {
+      ASTNode location) {
     this.handle(IProblem.MaskedCatch, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
@@ -1756,7 +1756,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         methodDecl.sourceStart, methodDecl.sourceEnd);
   }
   //public void missingEnclosingInstanceSpecification(ReferenceBinding
-  // enclosingType, AstNode location) {
+  // enclosingType, ASTNode location) {
   //   boolean insideConstructorCall =
   //           (location instanceof ExplicitConstructorCall)
   //                   && (((ExplicitConstructorCall) location).accessMode ==
@@ -1807,21 +1807,21 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
   public void needImplementation() {
     this.abortDueToInternalError(Util.bind("abort.missingCode")); //$NON-NLS-1$
   }
-  public void needToEmulateFieldReadAccess(FieldBinding field, AstNode location) {
+  public void needToEmulateFieldReadAccess(FieldBinding field, ASTNode location) {
     this.handle(IProblem.NeedToEmulateFieldReadAccess,
         new String[]{new String(field.declaringClass.readableName()),
             new String(field.name)}, new String[]{
             new String(field.declaringClass.shortReadableName()),
             new String(field.name)}, location.sourceStart, location.sourceEnd);
   }
-  public void needToEmulateFieldWriteAccess(FieldBinding field, AstNode location) {
+  public void needToEmulateFieldWriteAccess(FieldBinding field, ASTNode location) {
     this.handle(IProblem.NeedToEmulateFieldWriteAccess,
         new String[]{new String(field.declaringClass.readableName()),
             new String(field.name)}, new String[]{
             new String(field.declaringClass.shortReadableName()),
             new String(field.name)}, location.sourceStart, location.sourceEnd);
   }
-  public void needToEmulateMethodAccess(MethodBinding method, AstNode location) {
+  public void needToEmulateMethodAccess(MethodBinding method, ASTNode location) {
     if (method.isConstructor())
       this.handle(IProblem.NeedToEmulateConstructorAccess, new String[]{
           new String(method.declaringClass.readableName()),
@@ -1843,7 +1843,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         arguments, typeDecl.sourceStart, typeDecl.sourceEnd);
   }
   public void noMoreAvailableSpaceForArgument(LocalVariableBinding local,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(local.name)};
     this.handle(local instanceof SyntheticArgumentBinding
         ? IProblem.TooManySyntheticArgumentSlots
@@ -1851,12 +1851,12 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         location.sourceStart, location.sourceEnd);
   }
   public void noMoreAvailableSpaceForLocal(LocalVariableBinding local,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(local.name)};
     this.handle(IProblem.TooManyLocalVariableSlots, arguments, arguments, Abort
         | Error, location.sourceStart, location.sourceEnd);
   }
-  public void noSuchEnclosingInstance(TypeBinding targetType, AstNode location,
+  public void noSuchEnclosingInstance(TypeBinding targetType, ASTNode location,
       boolean isConstructorCall) {
     int id;
     if (isConstructorCall) {
@@ -2172,7 +2172,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         startPos, scanner.currentPosition - 1,
         parser.compilationUnit.compilationResult);
   }
-  public void shouldReturn(TypeBinding returnType, AstNode location) {
+  public void shouldReturn(TypeBinding returnType, ASTNode location) {
     this.handle(IProblem.ShouldReturnValue, new String[]{new String(returnType
         .readableName())}, new String[]{new String(returnType
         .shortReadableName())}, location.sourceStart, location.sourceEnd);
@@ -2241,7 +2241,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
             new String(abstractMethods[0].declaringClass.shortReadableName())},
         type.sourceStart(), type.sourceEnd());
   }
-  public void stringConstantIsExceedingUtf8Limit(AstNode location) {
+  public void stringConstantIsExceedingUtf8Limit(ASTNode location) {
     this.handle(IProblem.StringConstantIsExceedingUtf8Limit, NoArgument,
         NoArgument, location.sourceStart, location.sourceEnd);
   }
@@ -2276,7 +2276,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
                                               * surfaced in getMessage()
                                               */}, start, end);
   }
-  public void tooManyDimensions(AstNode expression) {
+  public void tooManyDimensions(ASTNode expression) {
     this.handle(IProblem.TooManyArrayDimensions, NoArgument, NoArgument,
         expression.sourceStart, expression.sourceEnd);
   }
@@ -2318,7 +2318,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         compUnitDecl.compilationResult);
   }
   public void typeMismatchError(TypeBinding resultType,
-      TypeBinding expectedType, AstNode location) {
+      TypeBinding expectedType, ASTNode location) {
     String resultTypeName = new String(resultType.readableName());
     String expectedTypeName = new String(expectedType.readableName());
     String resultTypeShortName = new String(resultType.shortReadableName());
@@ -2363,7 +2363,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.UnexpectedStaticModifierForMethod, arguments,
         arguments, methodDecl.sourceStart, methodDecl.sourceEnd);
   }
-  public void unhandledException(TypeBinding exceptionType, AstNode location) {
+  public void unhandledException(TypeBinding exceptionType, ASTNode location) {
     boolean insideDefaultConstructor = (referenceContext instanceof ConstructorDeclaration)
         && ((ConstructorDeclaration) referenceContext).isDefaultConstructor();
     boolean insideImplicitConstructorCall = (location instanceof ExplicitConstructorCall)
@@ -2377,13 +2377,13 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         .shortReadableName())}, location.sourceStart, location.sourceEnd);
   }
   public void uninitializedBlankFinalField(FieldBinding binding,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(binding.readableName())};
     this.handle(IProblem.UninitializedBlankFinalField, arguments, arguments,
         location.sourceStart, location.sourceEnd);
   }
   public void uninitializedLocalVariable(LocalVariableBinding binding,
-      AstNode location) {
+      ASTNode location) {
     String[] arguments = new String[]{new String(binding.readableName())};
     this.handle(IProblem.UninitializedLocalVariable, arguments, arguments,
         location.sourceStart, location.sourceEnd);
@@ -2400,7 +2400,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         new String[]{new String(targetType.shortReadableName())},
         expression.sourceStart, expression.sourceEnd);
   }
-  public void unnecessaryReceiverForStaticMethod(AstNode location,
+  public void unnecessaryReceiverForStaticMethod(ASTNode location,
       MethodBinding method) {
     this.handle(IProblem.NonStaticAccessToStaticMethod, new String[]{
         new String(method.declaringClass.readableName()),
@@ -2409,7 +2409,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         new String(method.selector), parametersAsShortString(method)},
         location.sourceStart, location.sourceEnd);
   }
-  public void unnecessaryReceiverForStaticField(AstNode location,
+  public void unnecessaryReceiverForStaticField(ASTNode location,
       FieldBinding field) {
     this.handle(IProblem.NonStaticAccessToStaticField,
         new String[]{new String(field.declaringClass.readableName()),
@@ -2422,7 +2422,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
         statement.sourceStart, statement.sourceEnd);
   }
   public void unreachableExceptionHandler(ReferenceBinding exceptionType,
-      AstNode location) {
+      ASTNode location) {
     this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
@@ -2576,7 +2576,7 @@ public class ProblemReporter extends ProblemHandler implements ProblemReasons {
     this.handle(IProblem.UnreachableCatch, NoArgument, NoArgument,
         typeRef.sourceStart, typeRef.sourceEnd);
   }
-  public void nonExternalizedStringLiteral(AstNode location) {
+  public void nonExternalizedStringLiteral(ASTNode location) {
     this.handle(IProblem.NonExternalizedStringLiteral, NoArgument, NoArgument,
         location.sourceStart, location.sourceEnd);
   }
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextType.java
deleted file mode 100644 (file)
index e0ae7de..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import net.sourceforge.phpdt.internal.corext.textmanipulation.MultiTextEdit;
-import net.sourceforge.phpdt.internal.corext.textmanipulation.NopTextEdit;
-import net.sourceforge.phpdt.internal.corext.textmanipulation.SimpleTextEdit;
-import net.sourceforge.phpdt.internal.corext.textmanipulation.TextBuffer;
-import net.sourceforge.phpdt.internal.corext.textmanipulation.TextBufferEditor;
-import net.sourceforge.phpdt.internal.corext.textmanipulation.TextEdit;
-
-import org.eclipse.core.runtime.CoreException;
-
-
-/**
- * A context type is a context factory.
- */
-public abstract class ContextType implements ITemplateEditor {
-
-  /** name of the context type */
-  private final String fName;
-
-  /** variables used by this content type */
-  private final Map fVariables = new HashMap();
-
-  /**
-   * Creates a context type with a name.
-   * 
-   * @param name the name of the context. It has to be unique wrt to other context names.
-   */
-  public ContextType(String name) {
-    fName = name;
-  }
-
-  /**
-   * Returns the name of the context type.
-   */
-  public String getName() {
-    return fName;
-  }
-
-  /**
-   * Adds a template variable to the context type.
-   */
-  public void addVariable(TemplateVariable variable) {
-    fVariables.put(variable.getName(), variable);
-  }
-
-  /**
-   * Removes a template variable from the context type.
-   */
-  public void removeVariable(TemplateVariable variable) {
-    fVariables.remove(variable.getName());
-  }
-
-  /**
-   * Removes all template variables from the context type.
-   */
-  public void removeAllVariables() {
-    fVariables.clear();
-  }
-
-  /**
-   * Returns an iterator for the variables known to the context type.
-   */
-  public Iterator variableIterator() {
-    return fVariables.values().iterator();
-  }
-
-  /**
-   * Creates a template context.
-   */
-  public abstract TemplateContext createContext();
-
-  /*
-   * @see ITemplateEditor#edit(TemplateBuffer)
-   */
-  public void edit(TemplateBuffer templateBuffer, TemplateContext context) throws CoreException {
-    TextBuffer textBuffer = TextBuffer.create(templateBuffer.getString());
-    TemplatePosition[] variables = templateBuffer.getVariables();
-
-    MultiTextEdit positions = variablesToPositions(variables);
-    MultiTextEdit multiEdit = new MultiTextEdit();
-
-    // iterate over all variables and try to resolve them
-    for (int i = 0; i != variables.length; i++) {
-      TemplatePosition variable = variables[i];
-
-      if (variable.isResolved())
-        continue;
-
-      String name = variable.getName();
-      int[] offsets = variable.getOffsets();
-      int length = variable.getLength();
-
-      TemplateVariable evaluator = (TemplateVariable) fVariables.get(name);
-      String value = (evaluator == null) ? null : evaluator.evaluate(context);
-
-      if (value == null)
-        continue;
-
-      variable.setLength(value.length());
-      variable.setResolved(evaluator.isResolved(context));
-
-      for (int k = 0; k != offsets.length; k++)
-        multiEdit.add(SimpleTextEdit.createReplace(offsets[k], length, value));
-    }
-
-    TextBufferEditor editor = new TextBufferEditor(textBuffer);
-    editor.add(positions);
-    editor.add(multiEdit);
-    editor.performEdits(null);
-
-    positionsToVariables(positions, variables);
-
-    templateBuffer.setContent(textBuffer.getContent(), variables);
-  }
-
-  private static MultiTextEdit variablesToPositions(TemplatePosition[] variables) {
-    MultiTextEdit positions = new MultiTextEdit();
-    for (int i = 0; i != variables.length; i++) {
-      int[] offsets = variables[i].getOffsets();
-      for (int j = 0; j != offsets.length; j++)
-        positions.add(new NopTextEdit(offsets[j], 0));
-    }
-
-    return positions;
-  }
-
-  private static void positionsToVariables(MultiTextEdit positions, TemplatePosition[] variables) {
-    Iterator iterator = positions.iterator();
-
-    for (int i = 0; i != variables.length; i++) {
-      TemplatePosition variable = variables[i];
-
-      int[] offsets = new int[variable.getOffsets().length];
-      for (int j = 0; j != offsets.length; j++)
-        offsets[j] = ((TextEdit) iterator.next()).getTextRange().getOffset();
-
-      variable.setOffsets(offsets);
-    }
-  }
-
-  /**
-   * Returns the templates associated with this context type.
-   */
-  public Template[] getTemplates() {
-    Template[] templates = Templates.getInstance().getTemplates();
-
-    Vector vector = new Vector();
-    for (int i = 0; i != templates.length; i++)
-      if (templates[i].getContextTypeName().equals(fName))
-        vector.add(templates[i]);
-
-    return (Template[]) vector.toArray(new Template[vector.size()]);
-  }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextTypeRegistry.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextTypeRegistry.java
deleted file mode 100644 (file)
index db8650a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPContextType;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPDocContextType;
-
-
-
-/**
- * A singleton to keep track of all known context types.
- */
-public class ContextTypeRegistry {
-
-       /** the singleton */
-       private static ContextTypeRegistry fInstance;
-       
-       /** all known context types */
-       private final Map fContextTypes= new HashMap();
-       
-       /**
-        * Returns the single instance of this class.
-        */
-       public static ContextTypeRegistry getInstance() {
-               if (fInstance == null)
-                       fInstance= new ContextTypeRegistry();
-                       
-               return fInstance;       
-       }
-
-       /**
-        * Adds a context type to the registry.
-        */     
-       public void add(ContextType contextType) {
-               fContextTypes.put(contextType.getName(), contextType);
-       }
-       
-       /**
-        * Removes a context type from the registry.
-        */
-       public void remove(ContextType contextType) {
-               fContextTypes.remove(contextType.getName());
-       }
-
-       /**
-        * Returns the context type if the name is valid, <code>null</code> otherwise.
-        */
-       public ContextType getContextType(String name) {
-               return (ContextType) fContextTypes.get(name);
-       }
-       
-       /**
-        * Returns an iterator over the registered context type names.
-        */
-       public Iterator iterator() {
-               return fContextTypes.keySet().iterator();       
-       }
-
-       // XXX bootstrap with java and javadoc context types
-       private ContextTypeRegistry() {
-               add(new PHPContextType());
-    add(new PHPDocContextType());
-               add(new HTMLContextType());
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/DocumentTemplateContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/DocumentTemplateContext.java
deleted file mode 100644 (file)
index b7fa493..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import net.sourceforge.phpdt.internal.corext.Assert;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-
-/**
- * A typical text based document template context.
- */
-public abstract class DocumentTemplateContext extends TemplateContext {
-
-  /** The text of the document. */
-  private final IDocument fDocument;
-  /** The completion offset. */
-  private final int fCompletionOffset;
-  /** The completion length. */
-  private final int fCompletionLength;
-
-  /**
-   * Creates a document template context.
-   */
-  protected DocumentTemplateContext(ContextType type, IDocument document,
-    int completionOffset, int completionLength)
-  {
-    super(type);
-               
-    Assert.isNotNull(document);
-    Assert.isTrue(completionOffset >= 0 && completionOffset <= document.getLength());
-    Assert.isTrue(completionLength >= 0);
-               
-    fDocument= document;
-    fCompletionOffset= completionOffset;
-    fCompletionLength= completionLength;
-  }
-       
-  public IDocument getDocument() {
-    return fDocument;  
-  }
-       
-  /**
-   * Returns the completion offset within the string of the context.
-   */
-  public int getCompletionOffset() {
-    return fCompletionOffset;  
-  }
-       
-  /**
-   * Returns the completion length within the string of the context.
-   */
-  public int getCompletionLength() {
-    return fCompletionLength;
-  }
-       
-  /**
-   * Returns the keyword which triggered template insertion.
-   */
-  public String getKey() {
-    int offset= getStart();
-    int length= getEnd() - offset;
-    try {
-      return fDocument.get(offset, length);
-    } catch (BadLocationException e) {
-      return ""; //$NON-NLS-1$ 
-    }
-  }
-
-  /**
-   * Returns the beginning offset of the keyword.
-   */
-  public int getStart() {
-    return fCompletionOffset;          
-  }
-       
-  /**
-   * Returns the end offset of the keyword.
-   */
-  public int getEnd() {
-    return fCompletionOffset + fCompletionLength;
-  }
-               
-}
-
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ITemplateEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ITemplateEditor.java
deleted file mode 100644 (file)
index 2698b77..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * A template editor implements an action to edit a template buffer in its context.
- */
-public interface ITemplateEditor {
-
-       /**
-        * Modifies a template buffer.
-        * 
-        * @param buffer the template buffer
-        * @param context the template context
-        * @throws CoreException if the buffer cannot be successfully modified
-        */
-       void edit(TemplateBuffer buffer, TemplateContext context) throws CoreException;
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/SimpleTemplateVariable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/SimpleTemplateVariable.java
deleted file mode 100644 (file)
index 62b4a7a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-/**
- * A simple template variable, which always evaluates to a defined string.
- */
-public class SimpleTemplateVariable extends TemplateVariable {
-
-       /** The string to which this variable evaluates. */
-       private String fEvaluationString;
-       /** A flag indicating if this variable can be resolved. */
-       private boolean fResolved;
-
-       /*
-        * @see TemplateVariable#TemplateVariable(String, String)
-        */
-       protected SimpleTemplateVariable(String name, String description) {
-               super(name, description);
-       }
-
-       /**
-        * Sets the string to which this variable evaluates.
-        * 
-        * @param evaluationString the evaluation string, may be <code>null</code>.
-        */
-       public final void setEvaluationString(String evaluationString) {
-               fEvaluationString= evaluationString;    
-       }
-
-       /*
-        * @see TemplateVariable#evaluate(TemplateContext)
-        */
-       public String evaluate(TemplateContext context) {
-               return fEvaluationString;
-       }
-
-       /**
-        * Sets the resolved flag.
-        */
-       public final void setResolved(boolean resolved) {
-               fResolved= resolved;
-       }
-
-       /*
-        * @see TemplateVariable#isResolved(TemplateContext)
-        */
-       public boolean isResolved(TemplateContext context) {
-               return fResolved;
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/Template.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/Template.java
deleted file mode 100644 (file)
index 8c64cee..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-/**
- * A template consiting of a name and a pattern.
- */
-public class Template {
-
-       /** The name of this template */
-       private String fName;
-       /** A description of this template */
-       private String fDescription;
-       /** The name of the context type of this template */
-       private String fContextTypeName;
-       /** The template pattern. */
-       private String fPattern;
-       /** A flag indicating if the template is active or not. */
-       private boolean fEnabled= true;
-
-       /**
-        * Creates an empty template.
-        */
-       public Template() {
-               this("", "", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-       }
-       
-       /**
-        * Creates a copy of a template.
-        */
-       public Template(Template template) {
-               this(template.getName(), template.getDescription(), template.getContextTypeName(), template.getPattern());      
-       }
-
-       /**
-        * Creates a template.
-        * 
-        * @param name the name of the template.
-        * @param description the description of the template.
-        * @param contextTypeName the name of the context type in which the template can be applied.
-        * @param pattern the template pattern.
-        */             
-       public Template(String name, String description, String contextTypeName, String pattern) {
-               fName= name;
-               fDescription= description;
-               fContextTypeName= contextTypeName;
-               fPattern= pattern;
-       }
-       
-       /*
-        * @see Object#equals(Object)
-        */
-       public boolean equals(Object object) {
-               if (!(object instanceof Template))
-                       return false;
-                       
-               Template template= (Template) object;
-
-               if (template == this)
-                       return true;            
-
-               return
-                       template.fName.equals(fName) &&
-                       template.fPattern.equals(fPattern) &&
-                       template.fContextTypeName.equals(fContextTypeName);
-       }
-       
-       /*
-        * @see Object#hashCode()
-        */
-       public int hashCode() {
-               return fName.hashCode() ^ fPattern.hashCode() ^ fContextTypeName.hashCode();
-       }
-
-       /**
-        * Sets the description of the template.
-        */
-       public void setDescription(String description) {
-               fDescription= description;
-       }
-       
-       /**
-        * Returns the description of the template.
-        */
-       public String getDescription() {
-               return fDescription;
-       }
-       
-       /**
-        * Sets the name of the context type in which the template can be applied.
-        */
-       public void setContext(String contextTypeName) {
-               fContextTypeName= contextTypeName;
-       }
-       
-       /**
-        * Returns the name of the context type in which the template can be applied.
-        */
-       public String getContextTypeName() {
-               return fContextTypeName;
-       }
-
-       /**
-        * Sets the name of the template.
-        */
-       public void setName(String name) {
-               fName= name;
-       }
-                       
-       /**
-        * Returns the name of the template.
-        */
-       public String getName() {
-           if (fName==null) {
-             return "";
-           }
-               return fName;
-       }
-
-       /**
-        * Sets the pattern of the template.
-        */
-       public void setPattern(String pattern) {
-               fPattern= pattern;
-       }
-               
-       /**
-        * Returns the template pattern.
-        */
-       public String getPattern() {
-               return fPattern;
-       }
-       
-       /**
-        * Sets the enable state of the template.
-        */
-       public void setEnabled(boolean enable) {
-               fEnabled= enable;       
-       }
-       
-       /**
-        * Returns <code>true</code> if template is enabled, <code>false</code> otherwise.
-        */
-       public boolean isEnabled() {
-               return fEnabled;        
-       }
-       
-       /**
-        * Returns <code>true</code> if template matches the prefix and context,
-        * <code>false</code> otherwise.
-        */
-       public boolean matches(String prefix, String contextTypeName) {
-               return 
-                       fEnabled &&
-                       fContextTypeName.equals(contextTypeName) &&
-                       (prefix.length() != 0) &&
-                       fName.toLowerCase().startsWith(prefix.toLowerCase());
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateBuffer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateBuffer.java
deleted file mode 100644 (file)
index 9783027..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import org.eclipse.core.runtime.CoreException;
-
-//import org.eclipse.jdt.internal.corext.Assert;
-
-/**
- * A template buffer is a container for a string and variables.
- */
-public final class TemplateBuffer {
-       
-       /** The string of the template buffer */ 
-       private String fString;
-       /** The variable positions of the template buffer */
-       private TemplatePosition[] fVariables;
-       
-       /**
-        * Creates a template buffer.
-        * 
-        * @param string the string
-        * @param variables the variable positions
-        * @throws CoreException for illegal variable positions
-        */
-    public TemplateBuffer(String string, TemplatePosition[] variables) throws CoreException {
-               setContent(string, variables);
-    }
-
-       /**
-        * Sets the content of the template buffer.
-        * 
-        * @param string the string
-        * @param variables the variable positions
-        * @throws CoreException for illegal variable positions
-        */
-       public final void setContent(String string, TemplatePosition[] variables) throws CoreException {
-       //      Assert.isNotNull(string);
-       //      Assert.isNotNull(variables);
-
-               // XXX assert non-overlapping variable properties
-
-               fString= string;
-               fVariables= variables;
-       }
-
-       /**
-        * Returns the string of the template buffer.
-        */
-       public final String getString() {
-               return fString;
-       }
-       
-       /**
-        * Returns the variable positions of the template buffer.
-        */
-       public final TemplatePosition[] getVariables() {
-               return fVariables;
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateContext.java
deleted file mode 100644 (file)
index b4ca23d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * A template context. A template context is associated with a context type.
- */
-public abstract class TemplateContext {
-
-       /** context type of this context */
-       private final ContextType fContextType;
-
-       /**
-        * Creates a template context of a particular context type.
-        */
-       protected TemplateContext(ContextType contextType) {
-               fContextType= contextType;
-       }
-
-       /**
-        * Returns the context type of this context.
-        */
-       public ContextType getContextType() {
-               return fContextType;   
-       }
-
-       /**
-        * Evaluates the template and returns a template buffer.
-        */
-       public abstract TemplateBuffer evaluate(Template template) throws CoreException;
-       
-       /**
-        * Tests if the specified template can be evaluated in this context.
-        */
-       public abstract boolean canEvaluate(Template template);
-       
-}
index 9ed4fca..032c5ce 100644 (file)
@@ -1,7 +1,13 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.corext.template;
 
 import java.text.MessageFormat;
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplatePosition.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplatePosition.java
deleted file mode 100644 (file)
index 9acc561..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-/**
- * 
- */
-public class TemplatePosition {
-
-       /** The name of the template position */
-       private final String fName;
-       /** The default value of the template position */
-       private final String fDefaultValue;
-
-       /** The length of the template positions. */
-       private int fLength;
-       /** The offsets of the template positions. */
-       private int[] fOffsets;
-       /** A flag indicating if the template position has been resolved. */
-       private boolean fResolved;
-       
-       /**
-        * Creates a template position.
-        * 
-        * @param name the name of the template position.
-        * @param defaultValue the default value of the position.
-        * @param offsets the array of offsets of the position.
-        * @param the length of the position.
-        */
-       public TemplatePosition(String name, String defaultValue, int[] offsets, int length) {
-               fName= name;
-               fDefaultValue= defaultValue;
-               fOffsets= offsets;
-               fLength= length;
-               fResolved= false;
-       }
-
-       /**
-        * Returns the name of the position.
-        */
-       public String getName() {
-           return fName;
-       }       
-
-       /**
-        * Returns the default value of the position.
-        */
-       public String getDefaultValue() {
-               return fDefaultValue;
-       }
-       
-       /**
-        * Sets the length of the position.
-        */
-       public void setLength(int length) {
-           fLength= length;
-       }
-       
-       /**
-        * Returns the length of the position.
-        */
-       public int getLength() {
-               return fLength;   
-       }
-       
-       /**
-        * Sets the offsets of the position.
-        */
-       public void setOffsets(int[] offsets) {
-               fOffsets= offsets; 
-       }
-       
-       /**
-        * Returns the offsets of the position.
-        */
-       public int[] getOffsets() {
-               return fOffsets;   
-       }
-       
-       /**
-        * Sets the resolved flag of the position.
-        */
-       public void setResolved(boolean resolved) {
-           fResolved= resolved;
-       }       
-
-       /**
-        * Returns <code>true</code> if the position is resolved, <code>false</code> otherwise.
-        */     
-       public boolean isResolved() {
-               return fResolved;   
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateSet.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateSet.java
deleted file mode 100644 (file)
index 3ddf18f..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.eclipse.core.runtime.CoreException;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * <code>ObfuscatorIgnoreSet</code> manages a collection of templates and makes them
- * persistent.
- */
-public class TemplateSet {
-
-  private static class TemplateComparator implements Comparator {
-    public int compare(Object arg0, Object arg1) {
-      if (arg0 == arg1)
-        return 0;
-
-      if (arg0 == null)
-        return -1;
-
-      Template template0 = (Template) arg0;
-      Template template1 = (Template) arg1;
-
-      return template0.getName().compareTo(template1.getName());
-    }
-  }
-
-  private static final String TEMPLATE_TAG = "template"; //$NON-NLS-1$
-  private static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
-  private static final String DESCRIPTION_ATTRIBUTE = "description"; //$NON-NLS-1$
-  private static final String CONTEXT_ATTRIBUTE = "context"; //$NON-NLS-1$
-  private static final String ENABLED_ATTRIBUTE = "enabled"; //$NON-NLS-1$
-
-  private List fTemplates = new ArrayList();
-  private Comparator fTemplateComparator = new TemplateComparator();
-  private Template[] fSortedTemplates = new Template[0];
-
-  /**
-   * Convenience method for reading templates from a file.
-   * 
-   * @see #addFromStream(InputStream)
-   */
-  public void addFromFile(File file) throws CoreException {
-    InputStream stream = null;
-
-    try {
-      stream = new FileInputStream(file);
-      addFromStream(stream);
-
-    } catch (IOException e) {
-      throwReadException(e);
-
-    } finally {
-      try {
-        if (stream != null)
-          stream.close();
-      } catch (IOException e) {
-      }
-    }
-  }
-
-  /**
-   * Reads templates from a XML stream and adds them to the template set.
-   */
-  public void addFromStream(InputStream stream) throws CoreException {
-    try {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder parser = factory.newDocumentBuilder();
-      Document document = parser.parse(new InputSource(stream));
-      NodeList elements = document.getElementsByTagName(TEMPLATE_TAG);
-
-      int count = elements.getLength();
-      for (int i = 0; i != count; i++) {
-        Node node = elements.item(i);
-        NamedNodeMap attributes = node.getAttributes();
-
-        if (attributes == null)
-          continue;
-
-        String name = getAttributeValue(attributes, NAME_ATTRIBUTE);
-        String description = getAttributeValue(attributes, DESCRIPTION_ATTRIBUTE);
-        String context = getAttributeValue(attributes, CONTEXT_ATTRIBUTE);
-        Node enabledNode = attributes.getNamedItem(ENABLED_ATTRIBUTE);
-
-        if (name == null || description == null || context == null)
-          throw new SAXException(TemplateMessages.getString("TemplateSet.error.missing.attribute")); //$NON-NLS-1$
-
-        boolean enabled = (enabledNode == null) || (enabledNode.getNodeValue().equals("true")); //$NON-NLS-1$
-
-        StringBuffer buffer = new StringBuffer();
-        NodeList children = node.getChildNodes();
-        for (int j = 0; j != children.getLength(); j++) {
-          String value = children.item(j).getNodeValue();
-          if (value != null)
-            buffer.append(value);
-        }
-        String pattern = buffer.toString().trim();
-
-        Template template = new Template(name, description, context, pattern);
-        template.setEnabled(enabled);
-        add(template);
-      }
-
-      sort();
-
-    } catch (ParserConfigurationException e) {
-      throwReadException(e);
-    } catch (IOException e) {
-      throwReadException(e);
-    } catch (SAXParseException e) {
-                       System.out.println("SAXParseException in line:"+e.getLineNumber()+" column:"+e.getColumnNumber());
-      throwReadException(e);
-    } catch (SAXException e) {
-      throwReadException(e);
-    }
-  }
-
-  private String getAttributeValue(NamedNodeMap attributes, String name) {
-    Node node = attributes.getNamedItem(name);
-
-    return node == null ? null : node.getNodeValue();
-  }
-
-  /**
-   * Convenience method for saving to a file.
-   * 
-   * @see #saveToStream(OutputStream)
-   */
-  public void saveToFile(File file) throws CoreException {
-    OutputStream stream = null;
-
-    try {
-      stream = new FileOutputStream(file);
-      saveToStream(stream);
-
-    } catch (IOException e) {
-      throwWriteException(e);
-
-    } finally {
-      try {
-        if (stream != null)
-          stream.close();
-      } catch (IOException e) {
-      }
-    }
-  }
-
-  /**
-   * Saves the template set as XML.
-   */
-  public void saveToStream(OutputStream stream) throws CoreException {
-    try {
-      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-      DocumentBuilder builder = factory.newDocumentBuilder();
-      Document document = builder.newDocument();
-
-      Node root = document.createElement("templates"); // $NON-NLS-1$ //$NON-NLS-1$
-      document.appendChild(root);
-
-      for (int i = 0; i != fTemplates.size(); i++) {
-        Template template = (Template) fTemplates.get(i);
-
-        Node node = document.createElement("template"); // $NON-NLS-1$ //$NON-NLS-1$
-        root.appendChild(node);
-
-        NamedNodeMap attributes = node.getAttributes();
-
-        Attr name = document.createAttribute(NAME_ATTRIBUTE);
-        name.setValue(template.getName());
-        attributes.setNamedItem(name);
-
-        Attr description = document.createAttribute(DESCRIPTION_ATTRIBUTE);
-        description.setValue(template.getDescription());
-        attributes.setNamedItem(description);
-
-        Attr context = document.createAttribute(CONTEXT_ATTRIBUTE);
-        context.setValue(template.getContextTypeName());
-        attributes.setNamedItem(context);
-
-        Attr enabled = document.createAttribute(ENABLED_ATTRIBUTE);
-        enabled.setValue(template.isEnabled() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
-        attributes.setNamedItem(enabled);
-
-        Text pattern = document.createTextNode(template.getPattern());
-        node.appendChild(pattern);
-      }
-
-      Transformer transformer=TransformerFactory.newInstance().newTransformer();
-         transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
-         transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
-         DOMSource source = new DOMSource(document);
-         StreamResult result = new StreamResult(stream);
-
-         transformer.transform(source, result);
-      
-//      OutputFormat format = new OutputFormat();
-//      format.setPreserveSpace(true);
-//      Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); //$NON-NLS-1$
-//      serializer.asDOMSerializer().serialize(document);
-
-    } catch (ParserConfigurationException e) {
-      throwWriteException(e);
-    } catch (TransformerException e) {
-               throwWriteException(e);
-       }
-//    } catch (IOException e) {
-//      throwWriteException(e);
-//    }
-  }
-
-  private static void throwReadException(Throwable t) throws CoreException {
-    PHPeclipsePlugin.log(t);
-    //         IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-    //                 ObfuscatorMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
-    //         throw new JavaUIException(status);
-  }
-
-  private static void throwWriteException(Throwable t) throws CoreException {
-    PHPeclipsePlugin.log(t);
-    //         IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION,
-    //                 ObfuscatorMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
-    //         throw new JavaUIException(status);
-  }
-
-  /**
-   * Adds a template to the set.
-   */
-  public void add(Template template) {
-    if (exists(template))
-      return; // ignore duplicate
-
-    fTemplates.add(template);
-    sort();
-  }
-
-  private boolean exists(Template template) {
-    for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
-      Template anotherTemplate = (Template) iterator.next();
-
-      if (template.equals(anotherTemplate))
-        return true;
-    }
-
-    return false;
-  }
-
-  /**
-   * Removes a template to the set.
-   */
-  public void remove(Template template) {
-    fTemplates.remove(template);
-    sort();
-  }
-
-  /**
-   * Empties the set.
-   */
-  public void clear() {
-    fTemplates.clear();
-    sort();
-  }
-
-  /**
-   * Returns all templates.
-   */
-  public Template[] getTemplates() {
-    return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
-  }
-
-  /**
-   * Returns all templates with a given name.
-   */
-  public Template[] getTemplates(String name) {
-    ArrayList res = new ArrayList();
-    for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
-      Template curr = (Template) iterator.next();
-      if (curr.getName().equals(name)) {
-        res.add(curr);
-      }
-    }
-    return (Template[]) res.toArray(new Template[res.size()]);
-  }
-
-  private void sort() {
-    fSortedTemplates = (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
-    Arrays.sort(fSortedTemplates, fTemplateComparator);
-  }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateTranslator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateTranslator.java
deleted file mode 100644 (file)
index 750913b..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * The template translator translates a string into a template buffer.
- * The EBNF grammer of a valid string is as follows:
- * 
- * <p>
- * template := (text | escape)*.<br />
- * text := character - dollar.<br />
- * escape := dollar ('{' identifier '}' | dollar).<br />
- * dollar := '$'.<br />
- * </p>
- */
-public class TemplateTranslator {
-
-       // states
-       private static final int TEXT= 0;
-       private static final int ESCAPE= 1;
-       private static final int IDENTIFIER= 2;
-
-       // tokens
-       private static final char ESCAPE_CHARACTER= '$';
-       private static final char IDENTIFIER_BEGIN= '{';
-       private static final char IDENTIFIER_END= '}';
-
-       /** a buffer for the translation result string */
-    private final StringBuffer fBuffer= new StringBuffer();    
-    /** position offsets of variables */
-    private final Vector fOffsets= new Vector();
-    /** position lengths of variables */
-    private final Vector fLengths= new Vector();
-
-       /** the current parsing state */
-    private int fState;    
-    /** the last translation error */
-    private String fErrorMessage;
-
-       /**
-        * Returns an error message if an error occured for the last translation, <code>null</code>
-        * otherwise.
-        */
-       public String getErrorMessage() {
-           return fErrorMessage;
-       }
-
-       /**
-        * Translates a template string to <code>TemplateBuffer</code>. <code>null</code>
-        * is returned if there was an error. <code>getErrorMessage()</code> retrieves the
-        * associated error message.
-        * 
-        * @param string the string to translate.
-        * @return returns the template buffer corresponding to the string, <code>null</code>
-        *         if there was an error.
-        * @see #getErrorMessage()
-        */
-       public TemplateBuffer translate(String string) throws CoreException {
-
-           fBuffer.setLength(0);
-           fOffsets.clear();
-           fLengths.clear();
-           fState= TEXT;
-           fErrorMessage= null;
-           
-               if (!parse(string))
-                       return null;
-                       
-               switch (fState) {
-               case TEXT:
-                       break;
-               
-               // illegal, but be tolerant
-               case ESCAPE:
-                       fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
-                       fBuffer.append(ESCAPE_CHARACTER);
-                       return null;
-                               
-               // illegal, but be tolerant
-               case IDENTIFIER:
-                       fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
-                       fBuffer.append(ESCAPE_CHARACTER);
-                       return null;            
-               }                       
-               
-               int[] offsets= new int[fOffsets.size()];
-               int[] lengths= new int[fLengths.size()];
-               
-               for (int i= 0; i < fOffsets.size(); i++) {
-                       offsets[i]= ((Integer) fOffsets.get(i)).intValue();
-                       lengths[i]= ((Integer) fLengths.get(i)).intValue();
-               }
-
-               String translatedString= fBuffer.toString();
-               TemplatePosition[] variables= findVariables(translatedString, offsets, lengths);
-
-               return new TemplateBuffer(translatedString, variables);
-       }
-       
-       private static TemplatePosition[] findVariables(String string, int[] offsets, int[] lengths) {
-
-               Map map= new HashMap();
-               
-               for (int i= 0; i != offsets.length; i++) {
-                   int offset= offsets[i];
-                   int length= lengths[i];
-                   
-                   String content= string.substring(offset, offset + length);
-                   Vector vector= (Vector) map.get(content);
-                   if (vector == null) {
-                       vector= new Vector();
-                       map.put(content, vector);
-                   }               
-                   vector.add(new Integer(offset));
-               }
-               
-               TemplatePosition[] variables= new TemplatePosition[map.size()];
-               int k= 0;
-               
-               Set keys= map.keySet();
-               for (Iterator i= keys.iterator(); i.hasNext(); ) {
-                       String name= (String) i.next();                 
-                       Vector vector= (Vector) map.get(name);
-                       
-                       int[] offsets_= new int[vector.size()];
-                       for (int j= 0; j != offsets_.length; j++)
-                               offsets_[j]= ((Integer) vector.get(j)).intValue();
-                               
-                       variables[k]= new TemplatePosition(name, name, offsets_, name.length());
-                       k++;
-               }
-               
-               return variables;
-       }
-
-       /** internal parser */
-       private boolean parse(String string) {
-
-               for (int i= 0; i != string.length(); i++) {
-                   char ch= string.charAt(i);
-                       
-                       switch (fState) {
-                       case TEXT:
-                               switch (ch) {
-                               case ESCAPE_CHARACTER:
-                                       fState= ESCAPE;
-                                       break;
-                                       
-                               default:
-                                       fBuffer.append(ch);
-                                       break;
-                               }
-                               break;
-                               
-                       case ESCAPE:
-                               switch (ch) {
-                               case ESCAPE_CHARACTER:
-                                       fBuffer.append(ch);
-                                       fState= TEXT;
-                                       break;
-                               
-                               case IDENTIFIER_BEGIN:
-                                       fOffsets.add(new Integer(fBuffer.length()));
-                                       fState= IDENTIFIER;
-                                       break;
-                                       
-                               default:
-                                       // illegal single escape character, but be tolerant
-                                       fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.incomplete.variable"); //$NON-NLS-1$
-                                       fBuffer.append(ESCAPE_CHARACTER);
-                                       fBuffer.append(ch);
-                                       fState= TEXT;
-                                       return false;
-                               }
-                               break;
-
-                       case IDENTIFIER:
-                               switch (ch) {
-                               case IDENTIFIER_END:
-                                       int offset = ((Integer) fOffsets.get(fOffsets.size() - 1)).intValue();
-                                       fLengths.add(new Integer(fBuffer.length() - offset));
-                                       fState= TEXT;
-                                       break;
-                               
-                               default:
-                                       if (!Character.isUnicodeIdentifierStart((char) ch) &&
-                                               !Character.isUnicodeIdentifierPart((char) ch))
-                                       {
-                                               // illegal identifier character
-                                               fErrorMessage= TemplateMessages.getString("TemplateTranslator.error.invalid.identifier"); //$NON-NLS-1$
-                                               return false;
-                                       }
-                               
-                                       fBuffer.append(ch);
-                                       break;
-                               }
-                               break;
-                       }
-               }
-               
-               return true;
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateVariable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/TemplateVariable.java
deleted file mode 100644 (file)
index 7d3c055..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-/**
- * A template variable.
- */
-public abstract class TemplateVariable {
-
-       /** name of the variable */
-       private final String fName;
-
-       /** description of the variable */
-       private final String fDescription;
-       
-       /**
-        * Creates an instance of <code>TemplateVariable</code>.
-        * 
-        * @param name the name of the variable
-        * @param description the description for the variable
-        */
-       protected TemplateVariable(String name, String description) {
-               fName= name;
-               fDescription= description;   
-       }
-       
-       /**
-        * Returns the name of the variable.
-        */
-       public String getName() {
-               return fName;
-       }
-
-       /**
-        * Returns the description for the variable.
-        */
-       public String getDescription() {
-               return fDescription;   
-       }
-
-       /**
-        * Tests if this variable can be evaluated.
-        */
-//     public abstract boolean canEvaluate(TemplateContext context);
-       
-       /**
-        * Evaluates this variable
-        * 
-        * @return the evaluated string, or <code>null</code> if not evaluatable.
-        */
-       public abstract String evaluate(TemplateContext context);
-
-       /**
-        * Returns whether this variable is resolved.
-        * By default, the variable is not resolved.
-        * Clients can overwrite this method to force resolution of the variable.
-        */
-       public boolean isResolved(TemplateContext context) {
-               return false;
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/Templates.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/Templates.java
deleted file mode 100644 (file)
index 84cddff..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template;
-
-import java.io.File;
-import java.io.InputStream;
-
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.ErrorDialog;
-
-/**
- * <code>ObfuscatorIgnores</code> gives access to the available templates.
- */
-public class Templates extends TemplateSet {
-
-       private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$
-       private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$
-
-       /** Singleton. */
-       private static Templates fgTemplates;
-
-       /**
-        * Returns an instance of templates.
-        */
-       public static Templates getInstance() {
-               if (fgTemplates == null)
-                       fgTemplates= create();
-               
-               return fgTemplates;
-       }
-
-       private static Templates create() {
-               Templates templates= new Templates();
-
-               try {                   
-                       File templateFile= getTemplateFile();
-                       if (templateFile.exists()) {
-                               templates.addFromFile(templateFile);
-                       } else {
-                               templates.addFromStream(getDefaultsAsStream());
-                               templates.saveToFile(templateFile);
-                       }
-
-               } catch (CoreException e) {
-                       PHPeclipsePlugin.log(e);
-                       ErrorDialog.openError(null,
-                               TemplateMessages.getString("Templates.error.title"), //$NON-NLS-1$
-                               e.getMessage(), e.getStatus());
-
-                       templates.clear();
-               }
-
-               return templates;
-       }       
-       
-       /**
-        * Resets the template set.
-        */
-       public void reset() throws CoreException {
-               clear();
-               addFromFile(getTemplateFile());
-       }
-
-       /**
-        * Resets the template set with the default templates.
-        */
-       public void restoreDefaults() throws CoreException {
-               clear();
-               addFromStream(getDefaultsAsStream());
-       }
-
-       /**
-        * Saves the template set.
-        */
-       public void save() throws CoreException {                                       
-               saveToFile(getTemplateFile());
-       }
-
-       private static InputStream getDefaultsAsStream() {
-               return Templates.class.getResourceAsStream(DEFAULT_FILE);
-       }
-
-       private static File getTemplateFile() {
-               IPath path= PHPeclipsePlugin.getDefault().getStateLocation();
-               path= path.append(TEMPLATE_FILE);
-               
-               return path.toFile();
-       }
-}
-
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml
deleted file mode 100644 (file)
index 020827a..0000000
+++ /dev/null
@@ -1,573 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<templates>
-<template name="class" description="class template with constructor" context="php" enabled="true">class ${class_name} {
-  function ${class_name}() {
-         ${cursor}
-  }
-}</template>
-<template name="class" description="class with attribute" context="php" enabled="true">class ${class_name} {
-  var $$${attribute};
-  function ${class_name}() {
-         ${cursor}
-  }
-  
-  function set_${attribute}( $$${attr} ) {
-    $$this->${attribute} = $$${attr};
-       }
-
-       function get_${attribute}() {
-    return $$this->${attribute};
-       }
-}</template>
-<template name="for" description="iterate over array" context="php" enabled="true">for ($$${index} = 0; $$${index} &lt; sizeof($$${array}); $$${index}++) {
-       ${cursor}
-}</template>
-<template name="for" description="iterate over array w/ temporary variable" context="php" enabled="true">for ($$${index} = 0; $$${index} &lt; sizeof($$${array}); $$${index}++) {
-       $$${array_element} = $$${array}[$$${index}];
-       ${cursor}
-}</template>
-<template name="function" description="function template" context="php" enabled="true">function ${function_name} () {
-       ${cursor}
-}</template>
-<template name="function" description="function template with return" context="php" enabled="true">function ${function_name} () {
-       return (${cursor});
-}</template>
-<template name="while" description="while iteration" context="php" enabled="true">while (${condition}) {
-       ${cursor}
-}</template>
-<template name="switch" description="switch case statement" context="php" enabled="true">switch (${key}) {
-       case ${value}:
-               ${cursor}
-               break;
-
-       default:
-               break;
-}</template><template name="if" description="if statement" context="php" enabled="true">if (${condition}) {
-       ${cursor}
-}</template><template name="ifelse" description="if else statement" context="php" enabled="true">if (${condition}) {
-       ${cursor}
-} else {
-       
-}</template><template name="elseif" description="else if block" context="php" enabled="true">elseif (${condition}) {
-       ${cursor}
-}</template><template name="else" description="else block" context="php" enabled="true">else {
-       ${cursor}
-}</template>
-<template name="filecomment" description="file comment used by the class and interface wizards" context="php" enabled="true">/**
- * Created on ${date} by ${user}
- *
- */</template><template name="functioncomment" description="function comment" context="php" enabled="true">/**
- * @author ${user}
- *
- */</template>
- <template name="echo" description="echo a string" context="php" enabled="true">echo "${string}";
-  ${cursor}</template>
-
-  <!-- phpdoc -->
-
-  <template description="&lt;code&gt;&lt;/code&gt;" name="&lt;code&gt;" context="phpdoc"
-  >&lt;code&gt;${cursor}&lt;/code&gt;</template>
-
-  <template description="&lt;code&gt;null&lt;/code&gt;" name="&lt;code&gt;" context="phpdoc"
-  >&lt;code&gt;null&lt;/code&gt;</template>
-
-  <template description="&lt;pre&gt;&lt;/pre&gt;" name="&lt;pre&gt;" context="phpdoc"
-  >&lt;pre&gt;${cursor}&lt;/pre&gt;</template>
-
-  <template description="&lt;b&gt;&lt;/b&gt;" name="&lt;b&gt;" context="phpdoc"
-  >&lt;b&gt;${cursor}&lt;/b&gt;</template>
-
-  <template description="&lt;i&gt;&lt;/i&gt;" name="&lt;i&gt;" context="phpdoc"
-  >&lt;i&gt;${cursor}&lt;/i&gt;</template>
-
-  <template description="author name" name="@author" context="phpdoc"
-  >@author ${user}</template>
-  
-  <template name="&lt;html" description="html page with head,title,body" context="html" enabled="true">
-&lt;html&gt;
-&lt;head&gt;
-&lt;meta http-equiv="Content-Language" content="en" /&gt;
-&lt;meta name="GENERATOR" content="PHPEclipse 1.0" /&gt;
-&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
-&lt;title&gt;${title}&lt;/title&gt;
-&lt;/head&gt;
-&lt;body bgcolor="#FFFFFF" text="#000000" link="#FF9966" vlink="#FF9966" alink="#FFCC99"&gt;
-${cursor}
-&lt;/body&gt;
-&lt;/html&gt;
-  </template>  
-  <template name="&lt;title" description="title" context="html" enabled="true">
-  &lt;title&gt;${cursor}&lt;/title&gt;
-  </template> 
-  
-  <template name="&lt;table" description="3x3 table" context="html" enabled="true">
-  &lt;table&gt;
-    &lt;tr&gt;
-      &lt;td&gt;${t00}&lt;/td&gt;&lt;td&gt;${t01}&lt;/td&gt;&lt;td&gt;${t02}&lt;/td&gt;
-    &lt;/tr&gt;
-    &lt;tr&gt;
-      &lt;td&gt;${t10}&lt;/td&gt;&lt;td&gt;${t11}&lt;/td&gt;&lt;td&gt;${t12}&lt;/td&gt;
-    &lt;/tr&gt;
-    &lt;tr&gt;
-      &lt;td&gt;${t20}&lt;/td&gt;&lt;td&gt;${t21}&lt;/td&gt;&lt;td&gt;${t22}&lt;/td&gt;
-    &lt;/tr&gt;    
-  &lt;/table&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;table" description="3x3 table with header" context="html" enabled="true">
-  &lt;table&gt;
-    &lt;tr&gt;
-      &lt;th&gt;${header0}&lt;/th&gt;&lt;th&gt;${header1}&lt;/th&gt;&lt;th&gt;${header2}&lt;/th&gt;
-    &lt;/tr&gt;
-    &lt;tr&gt;
-      &lt;td&gt;${t00}&lt;/td&gt;&lt;td&gt;${t01}&lt;/td&gt;&lt;td&gt;${t02}&lt;/td&gt;
-    &lt;/tr&gt;
-    &lt;tr&gt;
-      &lt;td&gt;${t10}&lt;/td&gt;&lt;td&gt;${t11}&lt;/td&gt;&lt;td&gt;${t12}&lt;/td&gt;
-    &lt;/tr&gt;
-    &lt;tr&gt;
-      &lt;td&gt;${t20}&lt;/td&gt;&lt;td&gt;${t21}&lt;/td&gt;&lt;td&gt;${t22}&lt;/td&gt;
-    &lt;/tr&gt;    
-  &lt;/table&gt;
-  ${cursor}
-  </template>
-  
-  <template name="&lt;a" description="hyperlink (href)" context="html" enabled="true">
-  &lt;a href="${link}"&gt;${description}&lt;/a&gt; ${cursor}
-  </template>  
-  <template name="&lt;a" description="hyperlink image" context="html" enabled="true">
-  &lt;a href="${link}"&gt;&lt;img src="${image}"&gt;&lt;/a&gt; ${cursor}
-  </template> 
-  <template name="&lt;a" description="hyperlink fragment identifier (name)" context="html" enabled="true">
-  &lt;a name="${anchor}"&gt;${description}&lt;/a&gt; ${cursor}
-  </template> 
-  <template name="&lt;p" description="paragraph" context="html" enabled="true">
-  &lt;p&gt;${cursor}&lt;/p&gt;
-  </template>
-  <template name="&lt;h1" description="heading 1" context="html" enabled="true">
-  &lt;h1&gt;${cursor}&lt;/h1&gt;
-  </template>
-  <template name="&lt;h2" description="heading 2" context="html" enabled="true">
-  &lt;h2&gt;${cursor}&lt;/h2&gt;
-  </template>
-  <template name="&lt;h3" description="heading 3" context="html" enabled="true">
-  &lt;h3&gt;${cursor}&lt;/h3&gt;
-  </template>
-  <template name="&lt;h4" description="heading 4" context="html" enabled="true">
-  &lt;h4&gt;${cursor}&lt;/h4&gt;
-  </template>
-  <template name="&lt;h5" description="heading 5" context="html" enabled="true">
-  &lt;h5&gt;${cursor}&lt;/h5&gt;
-  </template>
-  <template name="&lt;h6" description="heading 6" context="html" enabled="true">
-  &lt;h6&gt;${cursor}&lt;/h6&gt;
-  </template>
-  <template name="&lt;address" description="address" context="html" enabled="true">
-  &lt;address&gt;${cursor}&lt;/address&gt;
-  </template>
-  <template name="&lt;pre" description="preformat" context="html" enabled="true">
-  &lt;pre&gt;${cursor}&lt;/pre&gt;
-  </template>
-  <template name="&lt;code" description="code block" context="html" enabled="true">
-  &lt;code&gt;${cursor}&lt;/code&gt;
-  </template>
-  <template name="&lt;blockquote" description="blockquote" context="html" enabled="true">
-  &lt;blockquote&gt;${cursor}&lt;br/&gt;
-  &lt;/blockquote&gt;
-  </template>
-  <template name="&lt;hr" description="horizontal line" context="html" enabled="true">
-  &lt;hr width="100%" size="2"&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;ul" description="bulleted list" context="html" enabled="true">
-  &lt;ul&gt;
-    &lt;li&gt;${item1}&lt;br/&gt;
-    &lt;/li&gt;
-    &lt;li&gt;${item2}&lt;br/&gt;
-    &lt;/li&gt;
-  &lt;/ul&gt;
-  </template>
-  <template name="&lt;ol" description="numbered list" context="html" enabled="true">
-  &lt;ol&gt;
-    &lt;li&gt;${item1}&lt;br/&gt;
-    &lt;/li&gt;
-    &lt;li&gt;${item2}&lt;br/&gt;
-    &lt;/li&gt;
-  &lt;/ol&gt;
-  </template>
-  <template name="&lt;dl" description="term list" context="html" enabled="true">
-  &lt;dl&gt;
-    &lt;dt&gt;${item1}&lt;br/&gt;
-    &lt;/dt&gt;
-    &lt;dt&gt;${item2}&lt;br/&gt;
-    &lt;/dt&gt;
-  &lt;/dl&gt;
-  </template>
-  <template name="&lt;dl" description="definition list" context="html" enabled="true">
-  &lt;dl&gt;
-    &lt;dd&gt;${item1}&lt;br/&gt;
-    &lt;/dd&gt;
-    &lt;dd&gt;${item2}&lt;br/&gt;
-    &lt;/dd&gt;
-  &lt;/dl&gt;
-  </template>
-  <template name="&lt;form" description="form get" context="html" enabled="true">
-  &lt;form action="${link}" method="${get}"&gt;
-  ${cursor}
-  &lt;/form&gt;
-  </template>
-  <template name="&lt;form" description="form post" context="html" enabled="true">
-  &lt;form action="${link}" method="${post}" enctype="text/plain"&gt;
-  ${cursor}
-  &lt;/form&gt;
-  </template>
-  <template name="&lt;form" description="form upload file" context="html" enabled="true">
-  &lt;form action="${link}" method="${post}" enctype="multipart/form-data"&gt;
-  &lt;p&gt;${text}&lt;/p&gt;
-  &lt;input type="file" name="${name}" size="50" maxlength="100000" accept="text/*"/&gt;&lt;br/&gt;
-  &lt;input type="submit" value="${value}"/&gt;
-  ${cursor}
-  &lt;/form&gt;
-  </template>
-  <template name="&lt;input" description="input type=text (form)" context="html" enabled="true">
-  &lt;input type="text" name="${name}" value="${value}" size="40" maxlength="40"/&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;input" description="input type=password (form)" context="html" enabled="true">
-  &lt;input type="password" name="${name}" size="40" maxlength="40"/&gt;
-  ${cursor}
-  </template>  
-  <template name="&lt;input" description="input type=radio (form)" context="html" enabled="true">
-  &lt;input type="radio" name="${name}" value="${value}"/&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;input" description="input type=checkbox (form)" context="html" enabled="true">
-  &lt;input type="checkbox" name="${name}" value="${value}"/&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;input" description="input type=button (form button)" context="html" enabled="true">
-  &lt;input type="button" name="${name}" value="${value}"/&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;input" description="input type=submit (form button)" context="html" enabled="true">
-  &lt;input type="submit" name="${name}" value="${value}"/&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;input" description="input type=reset (form button)" context="html" enabled="true">
-  &lt;input type="reset" name="${name}" value="${value}"/&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;textarea" description="textarea (form)" context="html" enabled="true">
-  &lt;textarea name="${name}" rows="10" cols="50" wrap="off"&gt;
-  ${text}
-  &lt;/textarea&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;select" description="select option (form)" context="html" enabled="true">
-  &lt;select name="${name}" size="3"&gt;
-    &lt;option value="${value1}"&gt;${option1}&lt;/option&gt;
-    &lt;option value="${value2}"&gt;${option2}&lt;/option&gt;
-    &lt;option value="${value3}"&gt;${option3}&lt;/option&gt;
-  &lt;/select&gt;
-  </template>
-  <template name="&lt;xml" description="xml version=1.0" context="html" enabled="true">
-  &lt;?xml version="1.0"?&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;xml" description="xml-stylesheet type=text/xsl" context="html" enabled="true">
-  &lt;?xml-stylesheet type="text/xsl" href="${url}"&gt;
-  ${cursor}
-  </template>
-  <template name="&lt;script" description="JavaScript inline" context="html" enabled="true">&lt;script language="JavaScript" type="text/javascript"&gt;
-  ${cursor}
-&lt;/script&gt;
-  </template>
-  <template name="&lt;script" description="JavaScript file" context="html" enabled="true">&lt;script language="JavaScript" type="text/javascript" src="${jsfile}.js"&gt;&lt;/script&gt;${cursor}
-  </template>
-  <template name="&lt;style" description="style text/css" context="html" enabled="true">&lt;/style type="text/css"&gt;
-<!--
-  ${cursor}
--->
-&lt;/style&gt;
-  </template>
-  <template name="&amp;quot" description="quot" context="html" enabled="true">&amp;quot;</template>
-  <template name="&amp;amp" description="ampersand" context="html" enabled="true">&amp;amp;</template>
-  <template name="&amp;lt" description="less than" context="html" enabled="true">&amp;lt;</template>
-  <template name="&amp;gt" description="greater than" context="html" enabled="true">&amp;gt;</template>
-  
-  <template name="&amp;nbsp" description="no-break space" context="html" enabled="true">&amp;nbsp;</template>
-  <template name="&amp;iexcl" description="iexcl" context="html" enabled="true">&amp;iexcl;</template>
-  <template name="&amp;cent" description="cent" context="html" enabled="true">&amp;cent;</template>
-  <template name="&amp;pound" description="pound" context="html" enabled="true">&amp;pound;</template>
-  <template name="&amp;curren" description="curren" context="html" enabled="true">&amp;curren;</template>
-  <template name="&amp;yen" description="yen" context="html" enabled="true">&amp;yen;</template>
-  <template name="&amp;brvbar" description="brvbar" context="html" enabled="true">&amp;brvbar;</template>
-  <template name="&amp;brkbar" description="brkbar" context="html" enabled="true">&amp;brkbar;</template>
-  <template name="&amp;sect" description="sect" context="html" enabled="true">&amp;sect;</template>
-  <template name="&amp;uml" description="uml" context="html" enabled="true">&amp;uml;</template>
-  <template name="&amp;die" description="die" context="html" enabled="true">&amp;die;</template>
-  <template name="&amp;copy" description="copy" context="html" enabled="true">&amp;copy;</template>
-  <template name="&amp;ordf" description="ordf" context="html" enabled="true">&amp;ordf;</template>
-  <template name="&amp;laquo" description="laquo" context="html" enabled="true">&amp;laquo;</template>
-  <template name="&amp;not" description="not" context="html" enabled="true">&amp;not;</template>
-  <template name="&amp;shy" description="shy" context="html" enabled="true">&amp;shy;</template>
-  <template name="&amp;reg" description="reg" context="html" enabled="true">&amp;reg;</template>
-  <template name="&amp;macr" description="macr" context="html" enabled="true">&amp;macr;</template>
-  <template name="&amp;hibar" description="hibar" context="html" enabled="true">&amp;hibar;</template>
-  <template name="&amp;deg" description="deg" context="html" enabled="true">&amp;deg;</template>
-  <template name="&amp;plusmn" description="plusmn" context="html" enabled="true">&amp;plusmn;</template>
-  <template name="&amp;sup2" description="sup2" context="html" enabled="true">&amp;sup2;</template>
-  <template name="&amp;sup3" description="sup3" context="html" enabled="true">&amp;sup3;</template>
-  <template name="&amp;acute" description="acute" context="html" enabled="true">&amp;acute;</template>
-  <template name="&amp;micro" description="micro" context="html" enabled="true">&amp;micro;</template>
-  <template name="&amp;para" description="para" context="html" enabled="true">&amp;para;</template>
-  <template name="&amp;middot" description="middot" context="html" enabled="true">&amp;middot;</template>
-  <template name="&amp;cedil" description="cedil" context="html" enabled="true">&amp;cedil;</template>
-  <template name="&amp;sup1" description="sup1" context="html" enabled="true">&amp;sup1;</template>
-  <template name="&amp;ordm" description="ordm" context="html" enabled="true">&amp;ordm;</template>
-  <template name="&amp;raquo" description="raquo" context="html" enabled="true">&amp;raquo;</template>
-  <template name="&amp;frac14" description="frac14" context="html" enabled="true">&amp;frac14;</template>
-  <template name="&amp;frac12" description="frac12" context="html" enabled="true">&amp;frac12;</template>
-  <template name="&amp;frac34" description="frac34" context="html" enabled="true">&amp;frac34;</template>
-  <template name="&amp;iquest" description="iquest" context="html" enabled="true">&amp;iquest;</template>
-  <template name="&amp;Agrave" description="Agrave" context="html" enabled="true">&amp;Agrave;</template>
-  <template name="&amp;Aacute" description="Aacute" context="html" enabled="true">&amp;Aacute;</template>
-  <template name="&amp;Acirc" description="Acirc" context="html" enabled="true">&amp;Acirc;</template>
-  <template name="&amp;Atilde" description="Atilde" context="html" enabled="true">&amp;Atilde;</template>
-  <template name="&amp;Auml" description="Auml" context="html" enabled="true">&amp;Auml;</template>
-  <template name="&amp;Aring" description="Aring" context="html" enabled="true">&amp;Aring;</template>
-  <template name="&amp;AElig" description="AElig" context="html" enabled="true">&amp;AElig;</template>
-  <template name="&amp;Ccedil" description="Ccedil" context="html" enabled="true">&amp;Ccedil;</template>
-  <template name="&amp;Egrave" description="Egrave" context="html" enabled="true">&amp;Egrave;</template>
-  <template name="&amp;Eacute" description="Eacute" context="html" enabled="true">&amp;Eacute;</template>
-  <template name="&amp;Ecirc" description="Ecirc" context="html" enabled="true">&amp;Ecirc;</template>
-  <template name="&amp;Euml" description="Euml" context="html" enabled="true">&amp;Euml;</template>
-  <template name="&amp;lgrave" description="lgrave" context="html" enabled="true">&amp;lgrave;</template>
-  <template name="&amp;lacute" description="lacute" context="html" enabled="true">&amp;lacute;</template>
-  <template name="&amp;lcirc" description="lcirc" context="html" enabled="true">&amp;lcirc;</template>
-  <template name="&amp;luml" description="luml" context="html" enabled="true">&amp;luml;</template>
-  <template name="&amp;ETH" description="ETH" context="html" enabled="true">&amp;ETH;</template>
-  <template name="&amp;Ntilde" description="Ntilde" context="html" enabled="true">&amp;Ntilde;</template>
-  <template name="&amp;Ograve" description="Ograve" context="html" enabled="true">&amp;Ograve;</template>
-  <template name="&amp;Oacute" description="Oacute" context="html" enabled="true">&amp;Oacute;</template>
-  <template name="&amp;Ocirc" description="Ocirc" context="html" enabled="true">&amp;Ocirc;</template>
-  <template name="&amp;Otilde" description="Otilde" context="html" enabled="true">&amp;Otilde;</template>
-  <template name="&amp;Ouml" description="Ouml" context="html" enabled="true">&amp;Ouml;</template>
-  <template name="&amp;times" description="times" context="html" enabled="true">&amp;times;</template>
-  <template name="&amp;Oslash" description="Oslash" context="html" enabled="true">&amp;Oslash;</template>
-  <template name="&amp;Ugrave" description="Ugrave" context="html" enabled="true">&amp;Ugrave;</template>
-  <template name="&amp;Uacute" description="Uacute" context="html" enabled="true">&amp;Uacute;</template>
-  <template name="&amp;Ucirc" description="Ucirc" context="html" enabled="true">&amp;Ucirc;</template>
-  <template name="&amp;Uuml" description="Uuml" context="html" enabled="true">&amp;Uuml;</template>
-  <template name="&amp;Yacute" description="Yacute" context="html" enabled="true">&amp;Yacute;</template>
-  <template name="&amp;THORN" description="THORN" context="html" enabled="true">&amp;THORN;</template>
-  <template name="&amp;szlig" description="szlig" context="html" enabled="true">&amp;szlig;</template>
-  <template name="&amp;agrave" description="agrave" context="html" enabled="true">&amp;agrave;</template>
-  <template name="&amp;aacute" description="aacute" context="html" enabled="true">&amp;aacute;</template>
-  <template name="&amp;acirc" description="acirc" context="html" enabled="true">&amp;acirc;</template>
-  <template name="&amp;atilde" description="atilde" context="html" enabled="true">&amp;atilde;</template>
-  <template name="&amp;auml" description="auml" context="html" enabled="true">&amp;auml;</template>
-  <template name="&amp;aring" description="aring" context="html" enabled="true">&amp;aring;</template>
-  <template name="&amp;aelig" description="aelig" context="html" enabled="true">&amp;aelig;</template>
-  <template name="&amp;ccedil" description="ccedil" context="html" enabled="true">&amp;ccedil;</template>
-  <template name="&amp;egrave" description="egrave" context="html" enabled="true">&amp;egrave;</template>
-  <template name="&amp;eacute" description="eacute" context="html" enabled="true">&amp;eacute;</template>
-  <template name="&amp;ecirc" description="ecirc" context="html" enabled="true">&amp;ecirc;</template>
-  <template name="&amp;euml" description="euml" context="html" enabled="true">&amp;euml;</template>
-  <template name="&amp;igrave" description="igrave" context="html" enabled="true">&amp;igrave;</template>
-  <template name="&amp;iacute" description="iacute" context="html" enabled="true">&amp;iacute;</template>
-  <template name="&amp;icirc" description="icirc" context="html" enabled="true">&amp;icirc;</template>
-  <template name="&amp;iuml" description="iuml" context="html" enabled="true">&amp;iuml;</template>
-  <template name="&amp;eth" description="eth" context="html" enabled="true">&amp;eth;</template>
-  <template name="&amp;ntilde" description="ntilde" context="html" enabled="true">&amp;ntilde;</template>
-  <template name="&amp;ograve" description="ograve" context="html" enabled="true">&amp;ograve;</template>
-  <template name="&amp;oacute" description="oacute" context="html" enabled="true">&amp;oacute;</template>
-  <template name="&amp;ocirc" description="ocirc" context="html" enabled="true">&amp;ocirc;</template>
-  <template name="&amp;otilde" description="otilde" context="html" enabled="true">&amp;otilde;</template>
-  <template name="&amp;ouml" description="ouml" context="html" enabled="true">&amp;ouml;</template>
-  <template name="&amp;divide" description="divide" context="html" enabled="true">&amp;divide;</template>
-  <template name="&amp;oslash" description="oslash" context="html" enabled="true">&amp;oslash;</template>
-  <template name="&amp;ugrave" description="ugrave" context="html" enabled="true">&amp;ugrave;</template>
-  <template name="&amp;uacute" description="uacute" context="html" enabled="true">&amp;uacute;</template>
-  <template name="&amp;ucirc" description="ucirc" context="html" enabled="true">&amp;ucirc;</template>
-  <template name="&amp;uuml" description="uuml" context="html" enabled="true">&amp;uuml;</template>
-  <template name="&amp;yacute" description="yacute" context="html" enabled="true">&amp;yacute;</template>
-  <template name="&amp;thorn" description="thorn" context="html" enabled="true">&amp;thorn;</template>
-  <template name="&amp;yuml" description="yuml" context="html" enabled="true">&amp;yuml;</template>
-
-  <template name="#00FFFF" description="Aqua (Color Code)" context="html" enabled="true">#00FFFF</template>
-  <template name="#000000" description="Black (Color Code)" context="html" enabled="true">#000000</template>
-  <template name="#0000FF" description="Blue (Color Code)" context="html" enabled="true">#0000FF</template>
-  <template name="#A52A2A" description="Brown (Color Code)" context="html" enabled="true">#A52A2A</template>
-  <template name="#00FFFF" description="Cyan (Color Code)" context="html" enabled="true">#00FFFF</template>
-  <template name="#FF00FF" description="Fuchsia (Color Code)" context="html" enabled="true">#FF00FF</template>
-  <template name="#FFD700" description="Gold (Color Code)" context="html" enabled="true">#FFD700</template>
-  <template name="#808080" description="Gray (Color Code)" context="html" enabled="true">#808080</template>
-  <template name="#008000" description="Green (Color Code)" context="html" enabled="true">#008000</template>
-  <template name="#00FF00" description="Lime (Color Code)" context="html" enabled="true">#00FF00</template>
-  <template name="#FF00FF" description="Magenta (Color Code)" context="html" enabled="true">#FF00FF</template>
-  <template name="#800000" description="Maroon (Color Code)" context="html" enabled="true">#800000</template>
-  <template name="#000080" description="Navy (Color Code)" context="html" enabled="true">#000080</template>
-  <template name="#808000" description="Olive (Color Code)" context="html" enabled="true">#808000</template>
-  <template name="#FFA500" description="Orange (Color Code)" context="html" enabled="true">#FFA500</template>
-  <template name="#FFC0CB" description="Pink (Color Code)" context="html" enabled="true">#FFC0CB</template>
-  <template name="#800080" description="Purple (Color Code)" context="html" enabled="true">#800080</template>
-  <template name="#FF0000" description="Red (Color Code)" context="html" enabled="true">#FF0000</template>
-  <template name="#C0C0C0" description="Silver (Color Code)" context="html" enabled="true">#C0C0C0</template>
-  <template name="#008080" description="Teal (Color Code)" context="html" enabled="true">#008080</template>
-  <template name="#FFFFFF" description="White (Color Code)" context="html" enabled="true">#FFFFFF</template>
-  <template name="#FFFF00" description="Yellow (Color Code)" context="html" enabled="true">#FFFF00</template>
-
-  <template name="Aqua" description="Aqua (Color Code)" context="html" enabled="true">#00FFFF</template>
-  <template name="Black" description="Black (Color Code)" context="html" enabled="true">#000000</template>
-  <template name="Blue" description="Blue (Color Code)" context="html" enabled="true">#0000FF</template>
-  <template name="Brown" description="Brown (Color Code)" context="html" enabled="true">#A52A2A</template>
-  <template name="Cyan" description="Cyan (Color Code)" context="html" enabled="true">#00FFFF</template>
-  <template name="Fuchsia" description="Fuchsia (Color Code)" context="html" enabled="true">#FF00FF</template>
-  <template name="Gold" description="Gold (Color Code)" context="html" enabled="true">#FFD700</template>
-  <template name="Gray" description="Gray (Color Code)" context="html" enabled="true">#808080</template>
-  <template name="Green" description="Green (Color Code)" context="html" enabled="true">#008000</template>
-  <template name="Lime" description="Lime (Color Code)" context="html" enabled="true">#00FF00</template>
-  <template name="Magenta" description="Magenta (Color Code)" context="html" enabled="true">#FF00FF</template>
-  <template name="Maroon" description="Maroon (Color Code)" context="html" enabled="true">#800000</template>
-  <template name="Navy" description="Mavy (Color Code)" context="html" enabled="true">#000080</template>
-  <template name="Olive" description="Olive (Color Code)" context="html" enabled="true">#808000</template>
-  <template name="Orange" description="Orange (Color Code)" context="html" enabled="true">#FFA500</template>
-  <template name="Pink" description="Pink (Color Code)" context="html" enabled="true">#FFC0CB</template>
-  <template name="Purple" description="Purple (Color Code)" context="html" enabled="true">#800080</template>
-  <template name="Red" description="Red (Color Code)" context="html" enabled="true">#FF0000</template>
-  <template name="Silver" description="Silver (Color Code)" context="html" enabled="true">#C0C0C0</template>
-  <template name="Teal" description="Teal (Color Code)" context="html" enabled="true">#008080</template>
-  <template name="White" description="White (Color Code)" context="html" enabled="true">#FFFFFF</template>
-  <template name="Yellow" description="Yellow (Color Code)" context="html" enabled="true">#FFFF00</template>
-  <template name="&lt;br&gt;" description="&lt;br&gt;" context="html" enabled="true">&lt;br/&gt;${cursor}</template>
-  <template name="&lt;div&gt;" description="div block with id" context="html" enabled="true">&lt;div id=&quot;${id}&quot;&gt;${cursor}&lt;/div&gt;</template>
-  <template name="&lt;strong&gt;" description="&lt;strong&gt;" context="html" enabled="true">&lt;strong&gt;${cursor}&lt;/strong&gt;</template>
-  <template name="@author" description="author name email" context="phpdoc" enabled="true">@author ${user} &lt;${email}&gt;</template>
-  <template name="@access" description="access private" context="phpdoc" enabled="true">@access private</template>
-  <template name="@access" description="access protected" context="phpdoc" enabled="true">@access protected</template>
-  <template name="@access" description="access public" context="phpdoc" enabled="true">@access public</template>
-  <template name="@category" description="category" context="phpdoc" enabled="true">@category ${categoryname}</template>
-  <template name="@copyright" description="copyright" context="phpdoc" enabled="true">@copyright Copyright &amp;copy; ${year}, ${user}</template>
-  <template name="@deprecated" description="deprecated version date" context="phpdoc" enabled="true">@deprecated ${version} - ${date}</template>
-  <template name="@example" description="example path description" context="phpdoc" enabled="true">@example ${path} ${description}</template>
-  <template name="@abstract" description="abstract" context="phpdoc" enabled="true">@abstract</template>
-  <template name="@final" description="final" context="phpdoc" enabled="true">@final</template>
-  <template name="@filesource" description="filesource" context="phpdoc" enabled="true">@filesource</template>
-  <template name="@global" description="global datatype globalvariable" context="phpdoc" enabled="true">@global ${datatype} ${globalvariable}</template>
-  <template name="@global" description="global datatype description" context="phpdoc" enabled="true">@global ${datatype} ${description}</template>
-  <template name="@ignore" description="ignore" context="phpdoc" enabled="true">@ignore</template>
-  <template name="@internal " description="internal comment" context="phpdoc" enabled="true">@internal ${comment}</template>
-  <template name="@license" description="license url name" context="phpdoc" enabled="true">@license ${url} ${nameoflicense}</template>
-  <template name="@link" description="link url description" context="phpdoc" enabled="true">@link ${url} ${description}</template>
-  <template name="@name" description="name globalvariable" context="phpdoc" enabled="true">@name ${globalvariable}</template>
-  <template name="@package" description="package packagename" context="phpdoc" enabled="true">@package ${packagename}</template>
-  <template name="@param" description="param datatype paramname description" context="phpdoc" enabled="true">@param ${datatype} ${paramname} ${description}</template>
-  <template name="@param" description="param datatype paramname" context="phpdoc" enabled="true">@param ${datatype} ${paramname}</template>
-  <template name="@return" description="return datatype description" context="phpdoc" enabled="true">@return ${datatype} ${description}</template>
-  <template name="@see" description="see element" context="phpdoc" enabled="true">@see ${element}</template><template name="@since" description="since version date" context="phpdoc" enabled="true">@since ${version} - ${date}</template>
-  <template name="@staticvar" description="staticvar datatype description" context="phpdoc" enabled="true">@staticvar ${datatype} ${description}</template>
-  <template name="@subpackage" description="subpackage subpackagename" context="phpdoc" enabled="true">@subpackage ${subpackagename}</template>
-  <template name="@todo" description="@todo information_string" context="phpdoc" enabled="true">@todo ${information_string}</template>
-  <template name="@tutorial" description="tutorial string description" context="phpdoc" enabled="true">@tutorial ${string} ${description}</template>
-  <template name="@uses" description="uses element description" context="phpdoc" enabled="true">@uses ${element} ${description}</template>
-  <template name="@var" description="var datatype description" context="phpdoc" enabled="true">@var ${datatype} ${description}</template>
-  <template name="@version" description="version versionstring" context="phpdoc" enabled="true">@version ${versionstring}</template>
-  <template name="{" description="{* *} (Smarty comment)" context="html" enabled="true">{* ${cursor} *}</template>
-  <template name="{assign" description="{assign var= value= } (Smarty)" context="html" enabled="true">{assign var=&quot;${name}&quot; values=&quot;${value}&quot;}</template>
-  <template name="{capture" description="{capture }{/capture} (Smarty)" context="html" enabled="true">{capture name=${name}}
-${cursor}
-{/capture}</template>
-<template name="{config_load" description="{config_load} (Smarty)" context="html" enabled="true">{config_load file=&quot;${file}&quot;}</template>
-<template name="{config_load" description="{config_load} with section (Smarty)" context="html" enabled="true">{config_load file=&quot;${file}&quot; section=&quot;${section}&quot;}</template>
-<template name="{counter" description="{counter start= skip= print= } (Smarty)" context="html" enabled="true">{counter start=${start} skip=${skip} print=false}</template>
-<template name="{counter" description="{counter} (Smarty)" context="html" enabled="true">{counter}</template><template name="{cycle" description="{cycle values= } (Smarty)" context="html" enabled="true">{cycle values=&quot;${values}&quot;}</template>
-<template name="{eval" description="{eval var=#conf#} (Smarty)" context="html" enabled="true">{eval var=#${conf}#}</template>
-<template name="{eval" description="{eval var=$var} (smarty)" context="html" enabled="true">{eval var=$$${var}}</template>
-<template name="{fetch" description="{fetch file=} (Smarty)" context="html" enabled="true">{fetch file=&quot;${file}&quot;}</template>
-<template name="{foreach" description="{foreach}{/foreach} (Smarty)" context="html" enabled="true">{foreach from=$$${from} item=${item}}
-${cursor}
-{/foreach}</template>
-<template name="{foreach" description="{foreach}{/foreach} with key (Smarty)" context="html" enabled="true">{foreach from=$$${from} item=${item} key=${key}}
-${cursor}
-{/foreach}</template>
-<template name="{foreach" description="{foreach}{/foreach} with name (Smarty)" context="html" enabled="true">{foreach from=$$${from} item=${item} name=${name}}
-${cursor}
-{/foreach}</template>
-<template name="{foreach" description="{foreach}{foreachelse}{/foreach} (Smarty)" context="html" enabled="true">{foreach from=$$${from} item=${item}}
-${cursor}
-{foreachelse}
-${cursor}
-{/foreach}</template>
-<template name="{foreach" description="{foreach}{foreachelse}{/foreach} with key (Smarty)" context="html" enabled="true">{foreach from=$$${from} item=${item} key=${key}}
-${cursor}
-{foreachelse}
-${cursor}
-{/foreach}</template>
-<template name="{foreach" description="{foreach}{foreachelse}{/foreach} with name (Smarty)" context="html" enabled="true">{foreach from=$$${from} item=${item} name=${name}}
-${cursor}
-{foreachelse}
-${cursor}
-{/foreach}</template>
-<template name="{if" description="{if}{/if} (Smarty)" context="html" enabled="true">{if $$${var}}${cursor}{/if}</template><template name="{if" description="{if}{elseif}{/if} (Smarty)" context="html" enabled="true">{if $$${var}}
-${cursor}
-{elseif $$${var2}}
-
-{/if}</template><template name="{if" description="{if}{elseif}{else}{/if} (Smarty)" context="html" enabled="true">{if $$${var}}
-${cursor}
-{elseif $$${var2}}
-
-{else}
-
-{/if}</template>
-<template name="{if" description="{if}{else}{/if} (Smarty)" context="html" enabled="true">{if $$${var}}
-${cursor}
-{else}
-
-{/if}</template><template name="{include" description="{include file=&quot;&quot;} (Smarty)" context="html" enabled="true">{include file=&quot;${file}&quot;}</template>
-<template name="{include_php" description="{include_php file=&quot;&quot;} (Smarty)" context="html" enabled="true">{include_php file=&quot;${file}&quot;}</template>
-<template name="{ldelim}" description="{ldelim} (Smarty)" context="html" enabled="true">{ldelim}</template>
-<template name="{literal" description="{literal}{/literal} (Smarty)" context="html" enabled="true">{literal}
-${cursor}
-{/literal}</template>
-<template name="{rdelim}" description="{rdelim} (Smarty)" context="html" enabled="true">{rdelim}</template>
-<template name="{section" description="{section }{/section} (Smarty)" context="html" enabled="true">{section name=${name} loop=$$${loop}}
-${cursor}
-{/section}</template><template name="{section" description="{section}{sectionelse}{/section} (Smarty)" context="html" enabled="true">{section name=${name} loop=$$${loop}}
-${cursor}
-{sectionelse}
-
-{/section}</template><template name="{smarty.cookies.var}" description="{$smarty.cookies.var} (Smarty)" context="html" enabled="true">{$$smarty.cookies.${var}}</template>
-<template name="{smarty.env.var}" description="{$smarty.env.var} (Smarty)" context="html" enabled="true">{$$smarty.env.${var}}</template>
-<template name="{smarty.get.var}" description="{$smarty.get.var} (Smarty)" context="html" enabled="true">{$$smarty.get.${var}}</template>
-<template name="{smarty.now|date_format}" description="{$smarty.now|date_format} (Smarty)" context="html" enabled="true">{$$smarty.now|date_format:&quot;%Y-%m-%d %H:%M:%S&quot;}</template>
-<template name="{smarty.now}" description="{$smarty.now} (Smarty)" context="html" enabled="true">{$$smarty.now}</template>
-<template name="{smarty.post.var}" description="{$smarty.post.var} (Smarty)" context="html" enabled="true">{$$smarty.post.${var}}</template>
-<template name="{smarty.request.var}" description="{$smarty.request.var} (Smarty)" context="html" enabled="true">{$$smarty.request.${var}}</template>
-<template name="{smarty.server.var}" description="{$smarty.server.var} (Smarty)" context="html" enabled="true">{$$smarty.server.${var}}</template>
-<template name="{strip" description="{strip}{/strip} (Smarty)" context="html" enabled="true">{strip}
-${cursor}
-{/strip}</template>
-<template name="{var|capitalize}" description="{$var|capitalize} (Smarty)" context="html" enabled="true">{$$${var}|capitalize}</template>
-<template name="{var|count_characters}" description="{$var|count_characters} (Smarty)" context="html" enabled="true">{$$${var}|count_characters}</template>
-<template name="{var|count_paragraphs}" description="{$var|count_paragraphs} (Smarty)" context="html" enabled="true">{$$${var}|count_paragraphs}</template>
-<template name="{var|count_sentences}" description="{$var|count_sentences} (Smarty)" context="html" enabled="true">{$$${var}|count_sentences}</template>
-<template name="{var|count_words}" description="{$var|count_words} (Smarty)" context="html" enabled="true">{$$${var}|count_words}</template>
-<template name="{var|date_format}" description="{$var|date_format} (Smarty)" context="html" enabled="true">{$$${var}|date_format:&quot;%Y-%m-%d %H:%M:%S&quot;}</template>
-<template name="{var|default}" description="{$var|default} (Smarty)" context="html" enabled="true">{$$${var}|default:&quot;${text}&quot;}</template>
-<template name="{var|escape:value}" description="{$var|escape:value} (Smarty)" context="html" enabled="true">{$$${var}|escape:&quot;${value}&quot;}</template>
-<template name="{var|escape}" description="{$var|escape} (Smarty)" context="html" enabled="true">{$$${var}|escape}</template>
-<template name="{var|indent:nr}" description="{$var|indent:nr} (Smarty)" context="html" enabled="true">{$$${var}|indent:${nr}}</template>
-<template name="{var|indent}" description="{$var|indent} (Smarty)" context="html" enabled="true">{$$${var}|indent}</template>
-<template name="{var|lower}" description="{$var|lower} (Smarty)" context="html" enabled="true">{$$${var}|lower}</template>
-<template name="{var|nl2br}" description="{$var|nl2br} (Smarty)" context="html" enabled="true">{$$${var}|nl2br}</template>
-<template name="{var|regex_replace}" description="{$var|regex_replace} (Smarty)" context="html" enabled="true">{$$${var}|regex_replace:&quot;${regex}&quot;:&quot;${replace}&quot;}</template>
-<template name="{var|replace}" description="{$var|replace} (Smarty)" context="html" enabled="true">{$$${var}|replace:&quot;${find}&quot;:&quot;${replace}&quot;}</template>
-<template name="{var|spacify}" description="{$var|spacify} (Smarty)" context="html" enabled="true">{$$${var}|spacify}</template>
-<template name="{var|string_format}" description="{$var|string_format} (Smarty)" context="html" enabled="true">{$$${var}|string_format:&quot;%.2f&quot;}</template>
-<template name="{var|strip_tags}" description="{$var|strip_tags} (Smarty)" context="html" enabled="true">{$$${var}|strip_tags}</template>
-<template name="{var|strip}" description="{$var|strip} (Smarty)" context="html" enabled="true">{$$${var}|strip}</template>
-<template name="{var|truncate}" description="{$var|truncate} (Smarty)" context="html" enabled="true">{$$${var}|truncate:${nr}}</template>
-<template name="{var|upper}" description="{$var|upper} (Smarty)" context="html" enabled="true">{$$${var}|upper}</template>
-<template name="{var|wordwrap}" description="{$var|wordwrap} (Smarty)" context="html" enabled="true">{$$${var}|wordwrap:${nr}:&quot;${sign}&quot;}</template>
-</templates>
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContext.java
new file mode 100644 (file)
index 0000000..9aef349
--- /dev/null
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import java.util.Iterator;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.internal.corext.Assert;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+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;
+
+       public CodeTemplateContext(String contextTypeName, IJavaProject project, String lineDelim) {
+               super(PHPeclipsePlugin.getDefault().getCodeTemplateContextRegistry().getContextType(contextTypeName));
+               fLineDelimiter= lineDelim;
+               fProject= project;
+       }
+
+       public IJavaProject getJavaProject() {
+               return fProject;
+       }
+
+       /*
+        * @see net.sourceforge.phpdt.internal.corext.template.TemplateContext#evaluate(net.sourceforge.phpdt.internal.corext.template.Template)
+        */
+       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
+               // test that all variables are defined
+               Iterator iterator= getContextType().resolvers();
+               while (iterator.hasNext()) {
+                       TemplateVariableResolver var= (TemplateVariableResolver) iterator.next();
+                       if (var instanceof CodeTemplateContextType.CodeTemplateVariableResolver) {
+                               Assert.isNotNull(getVariable(var.getType()), "Variable " + var.getType() + "not defined"); //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+               }
+
+               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();
+                       tracker.set(code);
+                       int nLines= tracker.getNumberOfLines();
+                       if (nLines == 1) {
+                               return code;
+                       }
+                       
+                       StringBuffer buf= new StringBuffer();
+                       for (int i= 0; i < nLines; i++) {
+                               if (i != 0) {
+                                       buf.append(lineDelim);
+                               }
+                               IRegion region = tracker.getLineInformation(i);
+                               String line= code.substring(region.getOffset(), region.getOffset() + region.getLength());
+                               buf.append(line);
+                       }
+                       return buf.toString();
+               } catch (BadLocationException e) {
+                       // can not happen
+                       return code;
+               }
+       }               
+
+       /* (non-Javadoc)
+        * @see net.sourceforge.phpdt.internal.corext.template.TemplateContext#canEvaluate(net.sourceforge.phpdt.internal.corext.template.Template)
+        */
+       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());
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContextType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplateContextType.java
new file mode 100644 (file)
index 0000000..57796de
--- /dev/null
@@ -0,0 +1,310 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+import net.sourceforge.phpdt.core.ToolFactory;
+import net.sourceforge.phpdt.core.compiler.IScanner;
+import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
+import net.sourceforge.phpdt.core.compiler.InvalidInputException;
+
+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$
+
+       /* templates */
+       public static final String COMMENT_SUFFIX= "comment"; //$NON-NLS-1$
+       public static final String CATCHBLOCK= "catchblock"; //$NON-NLS-1$
+       public static final String METHODSTUB= "methodbody"; //$NON-NLS-1$      
+       public static final String NEWTYPE= "newtype"; //$NON-NLS-1$    
+       public static final String CONSTRUCTORSTUB= "constructorbody"; //$NON-NLS-1$
+       public static final String GETTERSTUB= "getterbody"; //$NON-NLS-1$
+       public static final String SETTERSTUB= "setterbody"; //$NON-NLS-1$
+       public static final String TYPECOMMENT= "type" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String FIELDCOMMENT= "field" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String METHODCOMMENT= "method" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String CONSTRUCTORCOMMENT= "constructor" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String OVERRIDECOMMENT= "override" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String GETTERCOMMENT= "getter" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String SETTERCOMMENT= "setter" + COMMENT_SUFFIX; //$NON-NLS-1$
+       
+       /* resolver types */
+       public static final String EXCEPTION_TYPE= "exception_type"; //$NON-NLS-1$
+       public static final String EXCEPTION_VAR= "exception_var"; //$NON-NLS-1$
+       public static final String ENCLOSING_METHOD= "enclosing_method"; //$NON-NLS-1$
+       public static final String ENCLOSING_TYPE= "enclosing_type"; //$NON-NLS-1$
+       public static final String BODY_STATEMENT= "body_statement"; //$NON-NLS-1$
+       public static final String FIELD= "field"; //$NON-NLS-1$
+       public static final String FIELD_TYPE= "field_type"; //$NON-NLS-1$
+       public static final String BARE_FIELD_NAME= "bare_field_name"; //$NON-NLS-1$
+       
+       public static final String PARAM= "param"; //$NON-NLS-1$
+       public static final String RETURN_TYPE= "return_type"; //$NON-NLS-1$
+       public static final String SEE_TAG= "see_to_overridden"; //$NON-NLS-1$
+       
+       public static final String TAGS= "tags"; //$NON-NLS-1$
+       
+       public static final String TYPENAME= "type_name"; //$NON-NLS-1$
+       public static final String FILENAME= "file_name"; //$NON-NLS-1$
+       public static final String PACKAGENAME= "package_name"; //$NON-NLS-1$
+       public static final String PROJECTNAME= "project_name"; //$NON-NLS-1$
+
+       public static final String PACKAGE_DECLARATION= "package_declaration"; //$NON-NLS-1$
+       public static final String TYPE_DECLARATION= "type_declaration"; //$NON-NLS-1$
+       public static final String TYPE_COMMENT= "typecomment"; //$NON-NLS-1$
+       
+       
+       /**
+        * Resolver that resolves to the variable defined in the context.
+        */
+       public static class CodeTemplateVariableResolver extends TemplateVariableResolver {
+               public CodeTemplateVariableResolver(String type, String description) {
+                       super(type, description);
+               }
+               
+               protected String resolve(TemplateContext context) {
+                       return context.getVariable(getType());
+               }
+       }
+       
+       /**
+        * Resolver for javadoc tags.
+        */
+       public static class TagsVariableResolver extends TemplateVariableResolver {
+               public TagsVariableResolver() {
+                       super(TAGS,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.tags")); //$NON-NLS-1$
+               }
+               
+               protected String resolve(TemplateContext context) {
+                       return "@"; //$NON-NLS-1$
+               }
+       }       
+               
+       /**
+        * Resolver for todo tags.
+        */
+       protected static class Todo extends TemplateVariableResolver {
+
+               public Todo() {
+                       super("todo", JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.todo")); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+               
+               protected String resolve(TemplateContext context) {
+                       String todoTaskTag= StubUtility.getTodoTaskTag(((CodeTemplateContext) context).getJavaProject());
+                       if (todoTaskTag == null)
+                               return "XXX"; //$NON-NLS-1$
+       
+                       return todoTaskTag;
+               }
+       }
+       
+       private boolean fIsComment;
+       
+       public CodeTemplateContextType(String contextName) {
+               super(contextName);
+               
+               fIsComment= false;
+               
+               // global
+               addResolver(new GlobalTemplateVariables.Dollar());
+               addResolver(new GlobalTemplateVariables.Date());
+               addResolver(new GlobalTemplateVariables.Year());
+               addResolver(new GlobalTemplateVariables.Time());
+               addResolver(new GlobalTemplateVariables.User());
+               addResolver(new Todo());
+               
+               if (CATCHBLOCK_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(EXCEPTION_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.exceptiontype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(EXCEPTION_VAR,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.exceptionvar"))); //$NON-NLS-1$
+               } else if (METHODBODY_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.bodystatement"))); //$NON-NLS-1$
+               } else if (CONSTRUCTORBODY_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.bodystatement"))); //$NON-NLS-1$
+               } else if (GETTERBODY_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
+               } else if (SETTERBODY_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(PARAM, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.param"))); //$NON-NLS-1$
+               } else if (NEWTYPE_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(TYPENAME,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typename"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(PACKAGE_DECLARATION,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.packdeclaration"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(TYPE_DECLARATION,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typedeclaration"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typecomment"))); //$NON-NLS-1$
+                       addCompilationUnitVariables();
+               } else if (TYPECOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(TYPENAME,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.typename"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new TagsVariableResolver());
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               } else if (FIELDCOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.fieldtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.fieldname"))); //$NON-NLS-1$
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               } else if (METHODCOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(RETURN_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.returntype"))); //$NON-NLS-1$
+                       addResolver(new TagsVariableResolver());
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               } else if (OVERRIDECOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(SEE_TAG,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.seetag"))); //$NON-NLS-1$
+                       addResolver(new TagsVariableResolver());
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               } else if (CONSTRUCTORCOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new TagsVariableResolver());
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               } else if (GETTERCOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(BARE_FIELD_NAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.barefieldname"))); //$NON-NLS-1$
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               } else if (SETTERCOMMENT_CONTEXTTYPE.equals(contextName)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD_TYPE,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldtype"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(FIELD, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.getterfieldname"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD,  JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.enclosingmethod"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(PARAM, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.param"))); //$NON-NLS-1$
+                       addResolver(new CodeTemplateVariableResolver(BARE_FIELD_NAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.barefieldname"))); //$NON-NLS-1$
+                       addCompilationUnitVariables();
+                       fIsComment= true;
+               }
+       }
+       
+       private void addCompilationUnitVariables() {
+               addResolver(new CodeTemplateVariableResolver(FILENAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.filename"))); //$NON-NLS-1$
+               addResolver(new CodeTemplateVariableResolver(PACKAGENAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.packagename"))); //$NON-NLS-1$
+               addResolver(new CodeTemplateVariableResolver(PROJECTNAME, JavaTemplateMessages.getString("CodeTemplateContextType.variable.description.projectname"))); //$NON-NLS-1$
+       }
+       
+       /*
+        * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
+        */
+       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);
+               }
+               for (int i= 0; i < variables.length; i++) {
+                       String type= variables[i].getType();
+                       if (getResolver(type) == null) {
+                               throw new TemplateException(JavaTemplateMessages.getFormattedString("CodeTemplateContextType.validate.unknownvariable", type)); //$NON-NLS-1$
+                       }
+                       required.remove(type);
+               }
+               if (!required.isEmpty()) {
+                       String missing= (String) required.get(0);
+                       throw new TemplateException(JavaTemplateMessages.getFormattedString("CodeTemplateContextType.validate.missingvariable", missing)); //$NON-NLS-1$
+               }
+               super.validateVariables(variables);
+       }       
+       
+       
+
+       /* (non-Javadoc)
+        * @see net.sourceforge.phpdt.internal.corext.template.ContextType#createContext()
+        */
+       public TemplateContext createContext() {
+               return null;
+       }
+
+       public static void registerContextTypes(ContextTypeRegistry registry) {
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CATCHBLOCK_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODBODY_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORBODY_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERBODY_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERBODY_CONTEXTTYPE));           
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NEWTYPE_CONTEXTTYPE));
+               
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.TYPECOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FIELDCOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODCOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORCOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.OVERRIDECOMMENT_CONTEXTTYPE));              
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERCOMMENT_CONTEXTTYPE));                
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERCOMMENT_CONTEXTTYPE));                
+       }
+       
+       
+
+       /*
+        * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validate(java.lang.String)
+        */
+       public void validate(String pattern) throws TemplateException {
+               super.validate(pattern);
+               if (fIsComment) {
+                       if (!isValidComment(pattern)) {
+                               throw new TemplateException(JavaTemplateMessages.getString("CodeTemplateContextType.validate.invalidcomment")); //$NON-NLS-1$
+                       }
+               }
+       }
+               
+       
+       private boolean isValidComment(String template) {
+               IScanner scanner= ToolFactory.createScanner(true, false, false, true);// false);
+               scanner.setSource(template.toCharArray());
+               try {
+                       int next= scanner.getNextToken();
+                       while (next == ITerminalSymbols.TokenNameCOMMENT_LINE || next == ITerminalSymbols.TokenNameCOMMENT_PHPDOC || next == ITerminalSymbols.TokenNameCOMMENT_BLOCK) {
+                               next= scanner.getNextToken();
+                       }
+                       return next == ITerminalSymbols.TokenNameEOF;
+               } catch (InvalidInputException e) {
+               }
+               return false;
+       }       
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplates.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CodeTemplates.java
new file mode 100644 (file)
index 0000000..f28361a
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.templates.Template;
+
+/**
+ * <code>CodeTemplates</code> gives access to the available code templates.
+ * @since 3.0
+ * @deprecated use {@link org.eclipse.jdt.internal.ui.JavaPlugin#getCodeTemplateStore()} instead 
+ */
+public class CodeTemplates extends net.sourceforge.phpdt.internal.corext.template.php.TemplateSet {
+
+       private static final String DEFAULT_FILE= "default-codetemplates.xml"; //$NON-NLS-1$
+       private static final String TEMPLATE_FILE= "codetemplates.xml"; //$NON-NLS-1$
+       private static final ResourceBundle fgResourceBundle= ResourceBundle.getBundle(JavaTemplateMessages.class.getName());
+
+       /** Singleton. */
+       private static CodeTemplates fgTemplates;
+
+       public static Template getCodeTemplate(String name) {
+               return getInstance().getFirstTemplate(name);
+       }
+
+       /**
+        * Returns an instance of templates.
+        */
+       public static CodeTemplates getInstance() {
+               if (fgTemplates == null)
+                       fgTemplates= new CodeTemplates();
+               
+               return fgTemplates;
+       }
+       
+       private CodeTemplates() {
+               super("codetemplate", PHPeclipsePlugin.getDefault().getCodeTemplateContextRegistry()); //$NON-NLS-1$
+               create();
+       }
+       
+       private void create() {
+               
+               try {
+                       addFromStream(getDefaultsAsStream(), false, true, fgResourceBundle);
+                       File templateFile= getTemplateFile();
+                       if (templateFile.exists()) {
+                               addFromFile(templateFile, false, fgResourceBundle);
+                       }
+                       saveToFile(templateFile);
+
+               } catch (CoreException e) {
+                 PHPeclipsePlugin.log(e);
+                       clear();
+               }
+
+       }       
+       
+       /**
+        * Resets the template set.
+        */
+       public void reset() throws CoreException {
+               clear();
+               addFromFile(getTemplateFile(), false, fgResourceBundle);
+       }
+
+       /**
+        * Resets the template set with the default templates.
+        */
+       public void restoreDefaults() throws CoreException {
+               clear();
+               addFromStream(getDefaultsAsStream(), false, true, fgResourceBundle);
+       }
+
+       /**
+        * Saves the template set.
+        */
+       public void save() throws CoreException {                                       
+               saveToFile(getTemplateFile());
+       }
+
+       private static InputStream getDefaultsAsStream() {
+               return CodeTemplates.class.getResourceAsStream(DEFAULT_FILE);
+       }
+
+       private static File getTemplateFile() {
+               IPath path= PHPeclipsePlugin.getDefault().getStateLocation();
+               path= path.append(TEMPLATE_FILE);
+               
+               return path.toFile();
+       }
+
+}
index 2332163..cf9649b 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
  * 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
@@ -19,11 +19,8 @@ import java.util.Vector;
 
 import net.sourceforge.phpdt.core.CompletionRequestorAdapter;
 import net.sourceforge.phpdt.core.ICompilationUnit;
-import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.core.compiler.IProblem;
 
-
-
 /**
  * A completion requestor to collect informations on local variables.
  * This class is used for guessing variable names like arrays, collections, etc.
@@ -136,68 +133,37 @@ class CompilationUnitCompletion extends CompletionRequestorAdapter {
                return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
        }
        
-       LocalVariable[] findLocalCollections() throws JavaModelException {
-               Vector vector= new Vector();
-
-               for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
-                       LocalVariable localVariable= (LocalVariable) iterator.next();
-
-                       String typeName= qualify(localVariable.typeName);
-                       
-                       if (typeName == null)
-                               continue;
-                                               
-                       if (isSubclassOf(typeName, "java.util.Collection")) //$NON-NLS-1$                       
-                               vector.add(localVariable);
-               }
-
-               return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
-       }
+//     LocalVariable[] findLocalCollections() throws JavaModelException {
+//             Vector vector= new Vector();
+//
+//             for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
+//                     LocalVariable localVariable= (LocalVariable) iterator.next();
+//
+//                     String typeName= qualify(localVariable.typeName);
+//                     
+//                     if (typeName == null)
+//                             continue;
+//                                             
+//                     if (isSubclassOf(typeName, "java.util.Collection")) //$NON-NLS-1$                       
+//                             vector.add(localVariable);
+//             }
+//
+//             return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
+//     }
 
        String simplifyTypeName(String qualifiedName) {
                return (String) fTypes.get(qualifiedName);      
        }
 
-       private LocalVariable[] findLocalIntegers() {
-               Vector vector= new Vector();
-
-               for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
-                       LocalVariable localVariable= (LocalVariable) iterator.next();
-
-                       if (localVariable.typeName.equals("int")) //$NON-NLS-1$
-                               vector.add(localVariable);
-               }
-
-               return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
-       }
-
-       private LocalVariable[] findLocalIterator() throws JavaModelException {
-               Vector vector= new Vector();
-
-               for (Iterator iterator= fLocalVariables.iterator(); iterator.hasNext();) {
-                       LocalVariable localVariable= (LocalVariable) iterator.next();
-
-                       String typeName= qualify(localVariable.typeName);                       
-
-                       if (typeName == null)
-                               continue;
-
-                       if (isSubclassOf(typeName, "java.util.Iterator")) //$NON-NLS-1$
-                               vector.add(localVariable);
-               }
-
-               return (LocalVariable[]) vector.toArray(new LocalVariable[vector.size()]);
-       }       
-
        private static boolean isArray(String type) {
                return type.endsWith("[]"); //$NON-NLS-1$
        }
        
        // returns fully qualified name if successful
-       private String qualify(String typeName) throws JavaModelException {
-               if (fUnit == null)
-                       return null;
-
+//     private String qualify(String typeName) throws JavaModelException {
+//             if (fUnit == null)
+//                     return null;
+//
 //             IType[] types= fUnit.getTypes();
 //
 //             if (types.length == 0)
@@ -209,20 +175,25 @@ class CompilationUnitCompletion extends CompletionRequestorAdapter {
 //                     return null;
 //                     
 //             return resolvedTypeNames[0][0] + '.' + resolvedTypeNames[0][1];
-    return null;
-       }       
+//     }       
        
        // type names must be fully qualified
-       private boolean isSubclassOf(String typeName0, String typeName1) throws JavaModelException {
-               if (typeName0.equals(typeName1))
-                       return true;
-
-               if (fUnit == null)
-                       return false;
-
+//     private boolean isSubclassOf(String typeName0, String typeName1) throws JavaModelException {
+//             if (typeName0.equals(typeName1))
+//                     return true;
+//
+//             if (fUnit == null)
+//                     return false;
+//
 //             IJavaProject project= fUnit.getJavaProject();
+//
 //             IType type0= project.findType(typeName0);
+//             if (type0 == null)
+//                     return false;
+//
 //             IType type1= project.findType(typeName1);
+//             if (type1 == null)
+//                     return false;
 //
 //             ITypeHierarchy hierarchy= type0.newSupertypeHierarchy(null);
 //             IType[] superTypes= hierarchy.getAllSupertypes(type0);
@@ -230,12 +201,12 @@ class CompilationUnitCompletion extends CompletionRequestorAdapter {
 //             for (int i= 0; i < superTypes.length; i++)
 //                     if (superTypes[i].equals(type1))
 //                             return true;                    
-               
-               return false;
-       }
+//             
+//             return false;
+//     }
 
        /*
-        * @see org.eclipse.jdt.core.ICompletionRequestor#acceptClass(char[], char[], char[], int, int, int, int)
+        * @see net.sourceforge.phpdt.core.ICompletionRequestor#acceptClass(char[], char[], char[], int, int, int, int)
         */
        public void acceptClass(char[] packageName, char[] className, char[] completionName, int modifiers,
                int completionStart, int completionEnd, int relevance)
@@ -245,7 +216,7 @@ class CompilationUnitCompletion extends CompletionRequestorAdapter {
        }
 
        /*
-        * @see org.eclipse.jdt.core.ICompletionRequestor#acceptInterface(char[], char[], char[], int, int, int, int)
+        * @see net.sourceforge.phpdt.core.ICompletionRequestor#acceptInterface(char[], char[], char[], int, int, int, int)
         */
        public void acceptInterface(char[] packageName, char[] interfaceName, char[] completionName,
                int modifiers, int completionStart, int completionEnd, int relevance)
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CompilationUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CompilationUnitContext.java
new file mode 100644 (file)
index 0000000..dc3d508
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.internal.ui.text.template.contentassist.MultiVariableGuess;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.TemplateContextType;
+
+//import net.sourceforge.phpdt.internal.ui.text.template.contentassist.MultiVariableGuess;
+
+
+/**
+ * A compilation unit context.
+ */
+public abstract class CompilationUnitContext extends DocumentTemplateContext {
+
+       /** The compilation unit, may be <code>null</code>. */
+       private final ICompilationUnit fCompilationUnit;
+       /** A flag to force evaluation in head-less mode. */
+       protected boolean fForceEvaluation;
+       /** A global state for proposals that change if a master proposal changes. */
+       protected MultiVariableGuess fMultiVariableGuess;
+
+       /**
+        * Creates a compilation unit context.
+        * 
+        * @param type   the context type
+        * @param document the document
+        * @param completionOffset the completion position within the document
+        * @param completionLength the completion length within the document
+        * @param compilationUnit the compilation unit (may be <code>null</code>)
+        */
+       protected CompilationUnitContext(TemplateContextType type, IDocument document, int completionOffset,
+               int completionLength, ICompilationUnit compilationUnit)
+       {
+               super(type, document, completionOffset, completionLength);
+               fCompilationUnit= compilationUnit;
+       }
+       
+       /**
+        * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
+        */
+       public final ICompilationUnit getCompilationUnit() {
+               return fCompilationUnit;
+       }
+
+       /**
+        * Returns the enclosing element of a particular element type, <code>null</code>
+        * if no enclosing element of that type exists.
+        */
+       public IJavaElement findEnclosingElement(int elementType) {
+               if (fCompilationUnit == null)
+                       return null;
+
+               try {
+                       IJavaElement element= fCompilationUnit.getElementAt(getStart());
+                       if (element == null) {
+                               element= fCompilationUnit;
+                       }
+                       
+                       return element.getAncestor(elementType);
+
+               } catch (JavaModelException e) {
+                       return null;
+               }       
+       }
+
+       /**
+        * Forces evaluation.
+        */
+       public void setForceEvaluation(boolean evaluate) {
+               fForceEvaluation= evaluate;     
+       }
+       
+       /**
+        * Returns the multivariable guess - state
+        * @return
+        */
+       public MultiVariableGuess getMultiVariableGuess() {
+               return fMultiVariableGuess;
+       } 
+
+       /**
+        * @param multiVariableGuess The multiVariableGuess to set.
+        */
+       public void setMultiVariableGuess(MultiVariableGuess multiVariableGuess) {
+               fMultiVariableGuess= multiVariableGuess;
+       }
+}
index aa3f8ad..d19bf3f 100644 (file)
@@ -1,36 +1,40 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.corext.template.php;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.IMethod;
+import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.core.Signature;
+
 
 /**
  * Compilation unit context type.
  */
-public abstract class CompilationUnitContextType extends ContextType {
+public abstract class CompilationUnitContextType extends TemplateContextType {
        
-       /** the document */
-       protected IDocument fDocument;
-
-       /** the completion position within the document string */
-       protected int fOffset;
-  
-  /** the completion length */
-  protected int fLength;
-  
-       /** the associated compilation unit, may be <code>null</code> */
-       //protected ICompilationUnit fCompilationUnit;
-/*
-       protected static class ReturnType extends TemplateVariable {
+       protected static class ReturnType extends TemplateVariableResolver {
                public ReturnType() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.return.type"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.return.type")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super("return_type", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.return.type")); //$NON-NLS-1$ //$NON-NLS-2$
                }
-    
-               public String evaluate(TemplateContext context) {
+               protected String resolve(TemplateContext context) {
                        IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
                        if (element == null)
                                return null;
@@ -41,73 +45,112 @@ public abstract class CompilationUnitContextType extends ContextType {
                                return null;
                        }
                }
-    
-               public boolean isResolved(TemplateContext context) {
-                       return evaluate(context) != null;
-               }               
        }
 
-       protected static class File extends TemplateVariable {
+       protected static class File extends TemplateVariableResolver {
                public File() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.file"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.file")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super("file", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.file")); //$NON-NLS-1$ //$NON-NLS-2$
                }
-               public String evaluate(TemplateContext context) {
+               protected String resolve(TemplateContext context) {
                        ICompilationUnit unit= ((CompilationUnitContext) context).getCompilationUnit();
                        
                        return (unit == null) ? null : unit.getElementName();
-      return null;
                }
-               public boolean isResolved(TemplateContext context) {
-                       return evaluate(context) != null;
-               }               
+               
+               /*
+                * @see org.eclipse.jface.text.templates.TemplateVariableResolver#isUnambiguous(org.eclipse.jface.text.templates.TemplateContext)
+                */
+               protected boolean isUnambiguous(TemplateContext context) {
+                       return resolve(context) != null;
+               }
+       }
+       
+       protected static class PrimaryTypeName extends TemplateVariableResolver {
+               public PrimaryTypeName() {
+                       super("primary_type_name", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.primary.type.name")); //$NON-NLS-1$ //$NON-NLS-2$
+                       
+               }
+               protected String resolve(TemplateContext context) {
+                       ICompilationUnit unit= ((CompilationUnitContext) context).getCompilationUnit();
+                       if (unit == null) 
+                               return null;
+                       String elementName= unit.getElementName();
+                       return elementName.substring(0, elementName.lastIndexOf('.'));
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.templates.TemplateVariableResolver#isUnambiguous(org.eclipse.jface.text.templates.TemplateContext)
+                */
+               protected boolean isUnambiguous(TemplateContext context) {
+                       return resolve(context) != null;
+               }
        }
 
-       protected static class EnclosingJavaElement extends TemplateVariable {
+       protected static class EnclosingJavaElement extends TemplateVariableResolver {
                protected final int fElementType;
                
                public EnclosingJavaElement(String name, String description, int elementType) {
                        super(name, description);
                        fElementType= elementType;
                }
-               public String evaluate(TemplateContext context) {
+               protected String resolve(TemplateContext context) {
                        IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(fElementType);
                        return (element == null) ? null : element.getElementName();                     
                }
-               public boolean isResolved(TemplateContext context) {
-                       return evaluate(context) != null;
+               
+               /*
+                * @see org.eclipse.jface.text.templates.TemplateVariableResolver#isUnambiguous(org.eclipse.jface.text.templates.TemplateContext)
+                */
+               protected boolean isUnambiguous(TemplateContext context) {
+                       return resolve(context) != null;
                }
        }
        
        protected static class Method extends EnclosingJavaElement {
                public Method() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.enclosing.method"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.method"), IJavaElement.METHOD); //$NON-NLS-1$ //$NON-NLS-2$
+                       super("enclosing_method", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.method"), IJavaElement.METHOD); //$NON-NLS-1$ //$NON-NLS-2$
                }
        }
 
        protected static class Type extends EnclosingJavaElement {
                public Type() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.enclosing.type"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.type"), IJavaElement.TYPE); //$NON-NLS-1$ //$NON-NLS-2$
+                       super("enclosing_type", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.type"), IJavaElement.TYPE); //$NON-NLS-1$ //$NON-NLS-2$
                }
        }
-
+/*
+       protected static class SuperClass extends EnclosingJavaElement {
+               public Type() {
+                       super("super_class", TemplateMessages.getString("JavaContextType.variable.description.type"), IJavaElement.TYPE);
+               }
+       }
+*/
        protected static class Package extends EnclosingJavaElement {
                public Package() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.enclosing.package"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.package"), IJavaElement.PACKAGE_FRAGMENT); //$NON-NLS-1$ //$NON-NLS-2$
+                       super("enclosing_package", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.package"), IJavaElement.PACKAGE_FRAGMENT); //$NON-NLS-1$ //$NON-NLS-2$
                }
        }       
 
        protected static class Project extends EnclosingJavaElement {
                public Project() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.enclosing.project"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.project"), IJavaElement.JAVA_PROJECT); //$NON-NLS-1$ //$NON-NLS-2$
+                       super("enclosing_project", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.project"), IJavaElement.JAVA_PROJECT); //$NON-NLS-1$ //$NON-NLS-2$
                }
        }       
-
-
-       protected static class Arguments extends TemplateVariable {
-               public Arguments() {
-                       super(JavaTemplateMessages.getString("CompilationUnitContextType.variable.name.enclosing.method.arguments"), JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.method.arguments")); //$NON-NLS-1$ //$NON-NLS-2$
+/*
+       protected static class Project2 extends TemplateVariableResolver {
+               public Project2() {
+                       super("project", TemplateMessages.getString("JavaContextType.variable.description.project"));
                }
                public String evaluate(TemplateContext context) {
+                       ICompilationUnit unit= ((JavaContext) context).getUnit();
+                       return (unit == null) ? null : unit.getJavaProject().getElementName();
+               }
+       }       
+*/
+       protected static class Arguments extends TemplateVariableResolver {
+               public Arguments() {
+                       super("enclosing_method_arguments", JavaTemplateMessages.getString("CompilationUnitContextType.variable.description.enclosing.method.arguments")); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+               protected String resolve(TemplateContext context) {
                        IJavaElement element= ((CompilationUnitContext) context).findEnclosingElement(IJavaElement.METHOD);
                        if (element == null)
                                return null;
@@ -131,7 +174,17 @@ public abstract class CompilationUnitContextType extends ContextType {
                        }
                }
        }
-*/
+
+/*     
+       protected static class Line extends TemplateVariableResolver {
+               public Line() {
+                       super("line", TemplateMessages.getString("CompilationUnitContextType.variable.description.line"));
+               }
+               public String evaluate(TemplateContext context) {
+                       return ((JavaTemplateContext) context).guessLineNumber();
+               }
+       }
+*/     
 
        /*
         * @see ContextType#ContextType(String)
@@ -140,14 +193,22 @@ public abstract class CompilationUnitContextType extends ContextType {
                super(name);    
        }
 
-       /**
-        * Sets context parameters. Needs to be called before createContext().
+       public abstract CompilationUnitContext createContext(IDocument document, int completionPosition, int length, ICompilationUnit compilationUnit);
+
+
+       /* (non-Javadoc)
+        * @see net.sourceforge.phpdt.internal.corext.template.ContextType#validateVariables(net.sourceforge.phpdt.internal.corext.template.TemplateVariable[])
         */
-       public void setContextParameters(IDocument document, int position, int length) {//, ICompilationUnit compilationUnit) {
-               fDocument= document;
-               fOffset= position;
-    fLength= length;
-//             fCompilationUnit= compilationUnit;
+       protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
+               // check for multiple cursor variables          
+               for (int i= 0; i < variables.length; i++) {
+                       TemplateVariable var= variables[i];
+                       if (var.getType().equals(GlobalTemplateVariables.Cursor.NAME)) {
+                               if (var.getOffsets().length > 1) {
+                                       throw new TemplateException(JavaTemplateMessages.getString("ContextType.error.multiple.cursor.variables")); //$NON-NLS-1$
+                               }
+                       }
+               }
        }
 
 }
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/GlobalVariables.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/GlobalVariables.java
deleted file mode 100644 (file)
index 8439ae9..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.php;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-
-import net.sourceforge.phpdt.internal.corext.template.SimpleTemplateVariable;
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
-
-/**
- * Global variables which are available in any context.
- */
-public class GlobalVariables {
-
-       /**
-        * The cursor variable determines the cursor placement after template edition.
-        */
-       static class Cursor extends SimpleTemplateVariable {
-               public Cursor() {
-                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.cursor"), PHPTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ //$NON-NLS-2$
-                       setEvaluationString(""); //$NON-NLS-1$
-                       setResolved(true);
-               }
-       }
-
-       /**
-        * The dollar variable inserts an escaped dollar symbol.
-        */
-       static class Dollar extends SimpleTemplateVariable {
-               public Dollar() {
-                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.dollar"), PHPTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
-                       setEvaluationString("$"); //$NON-NLS-1$
-                       setResolved(true);
-               }
-       }
-
-       /**
-        * The date variable evaluates to the current date.
-        */
-       static class Date extends SimpleTemplateVariable {
-               public Date() {
-                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.date"), PHPTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
-                       setResolved(true);
-               }
-               public String evaluate(TemplateContext context) {
-                       return DateFormat.getDateInstance().format(new java.util.Date());
-               }
-       }               
-       
-  /**
-   * The year variable evaluates to the current year.
-   */
-  static class Year extends SimpleTemplateVariable {
-    public Year() {
-      super(PHPTemplateMessages.getString("GlobalVariables.variable.name.year"), PHPTemplateMessages.getString("GlobalVariables.variable.description.year")); //$NON-NLS-1$ //$NON-NLS-2$
-      setResolved(true);
-    }
-    public String evaluate(TemplateContext context) {
-      return Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
-    }
-  }
-       /**
-        * The time variable evaluates to the current time.
-        */
-       static class Time extends SimpleTemplateVariable {
-               public Time() {
-                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.time"), PHPTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
-                       setResolved(true);
-               }
-               public String evaluate(TemplateContext context) {
-                       return DateFormat.getTimeInstance().format(new java.util.Date());
-               }
-       }
-
-       /**
-        * The user variable evaluates to the current user.
-        */
-       static class User extends SimpleTemplateVariable {
-               public User() {
-                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.user"), PHPTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
-                       setResolved(true);
-               }
-               public String evaluate(TemplateContext context) {
-                       return System.getProperty("user.name"); //$NON-NLS-1$
-               }       
-       }
-}
index 13afed8..eb0f0cf 100644 (file)
@@ -6,11 +6,13 @@ package net.sourceforge.phpdt.internal.corext.template.php;
 
 //import org.eclipse.jdt.core.ICompilationUnit;
 
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
+import net.sourceforge.phpdt.core.ICompilationUnit;
+
+import org.eclipse.jface.text.IDocument;
 
 /**
  * A context type for javadoc.
- */
+ */ 
 public class HTMLContextType extends CompilationUnitContextType {
 
        /**
@@ -20,12 +22,12 @@ public class HTMLContextType extends CompilationUnitContextType {
                super("html"); //$NON-NLS-1$
                
                // global
-               addVariable(new GlobalVariables.Cursor());
-               addVariable(new GlobalVariables.Dollar());
-               addVariable(new GlobalVariables.Date());
-    addVariable(new GlobalVariables.Year());
-               addVariable(new GlobalVariables.Time());
-               addVariable(new GlobalVariables.User());
+//             addVariable(new GlobalVariables.Cursor());
+//             addVariable(new GlobalVariables.Dollar());
+//             addVariable(new GlobalVariables.Date());
+//        addVariable(new GlobalVariables.Year());
+//             addVariable(new GlobalVariables.Time());
+//             addVariable(new GlobalVariables.User());
                
                // compilation unit
        /*      addVariable(new File());
@@ -40,8 +42,13 @@ public class HTMLContextType extends CompilationUnitContextType {
        /*
         * @see ContextType#createContext()
         */     
-       public TemplateContext createContext() {
-               return new HTMLUnitContext(this, fDocument, fOffset); //, fCompilationUnit);
+       public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
+                       return new HTMLUnitContext(this, document, offset, length, compilationUnit); 
        }
-
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.corext.template.java.CompilationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.jdt.core.ICompilationUnit)
+        */
+//     public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
+//             return new JavaDocContext(this, document, offset, length, compilationUnit);
+//     }
 }
index 136e438..0c4dfb3 100644 (file)
@@ -1,98 +1,60 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
 package net.sourceforge.phpdt.internal.corext.template.php;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
-import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
-
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateTranslator;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
 
 /**
- * A compilation unit context.
+ * A context for javadoc.
  */
-public class HTMLUnitContext extends DocumentTemplateContext {
-
-  /** The platform default line delimiter. */
-  private static final String PLATFORM_LINE_DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$
+public class HTMLUnitContext extends CompilationUnitContext {
 
-  /** special characters
-   * '&' for the start of HTML entities
-   * '<' for the start of HTML tags
-   * '#' for the start of colour attributes
+  // tags
+  //   private static final char HTML_TAG_BEGIN= '<';
+  //   private static final char HTML_TAG_END= '>';
+  //   private static final char JAVADOC_TAG_BEGIN= '@';
+  /**
+   * special characters '&' for the start of HTML entities ' <' for the start of HTML tags '#' for the start of colour attributes
    * '{' for the start of smarty partitions inside HTML code
    */
   private static final String specialChars = "&<#{";
 
-  /** The compilation unit, may be <code>null</code>. */
-  //   private final ICompilationUnit fCompilationUnit;
-  protected boolean fForceEvaluation;
   /**
-   * Creates a compilation unit context.
+   * Creates a javadoc template context.
    * 
-   * @param type   the context type.
-   * @param document the document.
-   * @param completionPosition the completion position within the document.
-   * @param compilationUnit the compilation unit (may be <code>null</code>).
+   * @param type
+   *          the context type.
+   * @param document
+   *          the document.
+   * @param completionOffset
+   *          the completion offset within the document.
+   * @param completionLength
+   *          the completion length within the document.
+   * @param compilationUnit
+   *          the compilation unit (may be <code>null</code>).
    */
-  protected HTMLUnitContext(ContextType type, IDocument document, int completionPosition)
-  //,ICompilationUnit compilationUnit)
-  {
-    super(type, document, completionPosition, 0);
-    // fCompilationUnit= compilationUnit;
+  public HTMLUnitContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
+      ICompilationUnit compilationUnit) {
+    super(type, document, completionOffset, completionLength, compilationUnit);
   }
 
   /*
-  * @see TemplateContext#canEvaluate(Template templates)
-  */
-  public boolean canEvaluate(Template template) {
-    // return fForceEvaluation || 
-    return template.matches(getKey(), getContextType().getName());
-  }
-
-  /**
-   * Returns <code>true</code> if template matches the prefix and context,
-   * <code>false</code> otherwise.
+   * @see TemplateContext#canEvaluate(Template templates)
    */
-  public boolean canEvaluate(String identifier) {
-    String prefix = getKey();
-    return
-    //      fEnabled &&
-    //      fContextTypeName.equals(contextTypeName) &&
-     (prefix.length() != 0) && identifier.toLowerCase().startsWith(prefix.toLowerCase());
-  }
-
-  /*
-  * @see TemplateContext#evaluate(Template template)
-  */
-  public TemplateBuffer evaluate(Template template) throws CoreException {
-    if (!canEvaluate(template))
-      return null;
-
-    TemplateTranslator translator = new TemplateTranslator();
-    TemplateBuffer buffer = translator.translate(template.getPattern());
-
-    getContextType().edit(buffer, this);
-
-    String lineDelimiter = null;
-    try {
-      lineDelimiter = getDocument().getLineDelimiter(0);
-    } catch (BadLocationException e) {
-    }
-
-    if (lineDelimiter == null)
-      lineDelimiter = PLATFORM_LINE_DELIMITER;
+  public boolean canEvaluate(Template template) {
+    String key = getKey();
 
-    //    ITemplateEditor formatter= new JavaFormatter(lineDelimiter);
-    //    formatter.edit(buffer, this);
+    if (fForceEvaluation)
+      return true;
 
-    return buffer;
+    return template.matches(key, getContextType().getId()) && (key.length() != 0)
+        && template.getName().toLowerCase().startsWith(key.toLowerCase());
   }
 
   /*
@@ -142,49 +104,61 @@ public class HTMLUnitContext extends DocumentTemplateContext {
     }
   }
 
-  /**
-   * Returns the character before start position of completion.
+  /*
+   * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getEnd()
    */
-  public char getCharacterBeforeStart() {
-    int start = getStart();
+  public int getEnd() {
+
+    if (getCompletionLength() == 0)
+      return super.getEnd();
 
     try {
-      return start == 0 ? ' ' : getDocument().getChar(start - 1);
+      IDocument document = getDocument();
+
+      int start = getCompletionOffset();
+      int end = getCompletionOffset() + getCompletionLength();
+
+      while (start != end && Character.isWhitespace(document.getChar(end - 1)))
+        end--;
+
+      return end;
 
     } catch (BadLocationException e) {
-      return ' ';
+      return super.getEnd();
     }
   }
-  /**
-   * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
-   */
-  //   public final ICompilationUnit getCompilationUnit() {
-  //           return fCompilationUnit;
-  //   }
 
-  /**
-   * Returns the enclosing element of a particular element type, <code>null</code>
-   * if no enclosing element of that type exists.
+  /*
+   * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getKey()
    */
-  //   public IJavaElement findEnclosingElement(int elementType) {
-  //           if (fCompilationUnit == null)
-  //                   return null;
-  //
-  //           try {
-  //                   IJavaElement element= fCompilationUnit.getElementAt(getStart());
-  //                   while (element != null && element.getElementType() != elementType)
-  //                           element= element.getParent();
-  //                   
-  //                   return element;
-  //
-  //           } catch (JavaModelException e) {
-  //                   return null;
-  //           }       
-  //   }
-  /**
-   * Forces evaluation.
+  public String getKey() {
+
+    if (getCompletionLength() == 0)
+      return super.getKey();
+
+    try {
+      IDocument document = getDocument();
+
+      int start = getStart();
+      int end = getCompletionOffset();
+      return start <= end ? document.get(start, end - start) : ""; //$NON-NLS-1$
+
+    } catch (BadLocationException e) {
+      return super.getKey();
+    }
+  }
+
+  /*
+   * @see TemplateContext#evaluate(Template)
    */
-  public void setForceEvaluation(boolean evaluate) {
-    fForceEvaluation = evaluate;
+  public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
+    TemplateTranslator translator = new TemplateTranslator();
+    TemplateBuffer buffer = translator.translate(template);
+
+    getContextType().resolve(buffer, this);
+
+    return buffer;
   }
+
 }
+
index 2d50010..30cebda 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
  * 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
@@ -13,15 +13,13 @@ package net.sourceforge.phpdt.internal.corext.template.php;
 import java.lang.reflect.InvocationTargetException;
 
 import net.sourceforge.phpdt.core.ICompilationUnit;
-import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.internal.corext.Assert;
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
-import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitCompletion.LocalVariable;
+import net.sourceforge.phpdt.internal.corext.util.Strings;
+import net.sourceforge.phpdt.internal.ui.preferences.CodeFormatterPreferencePage;
+import net.sourceforge.phpdt.internal.ui.text.template.contentassist.MultiVariable;
 import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.core.runtime.CoreException;
@@ -32,12 +30,19 @@ import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.Document;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateTranslator;
+import org.eclipse.jface.text.templates.TemplateVariable;
 import org.eclipse.swt.widgets.Shell;
 
 /**
  * A context for java source.
  */
-public class JavaContext extends PHPUnitContext {
+public class JavaContext extends CompilationUnitContext {
 
        /** The platform default line delimiter. */
        private static final String PLATFORM_LINE_DELIMITER= System.getProperty("line.separator"); //$NON-NLS-1$
@@ -52,42 +57,51 @@ public class JavaContext extends PHPUnitContext {
         * @param document the document.
         * @param completionOffset the completion offset within the document.
         * @param completionLength the completion length.
-        * @param unit the compilation unit (may be <code>null</code>).
+        * @param compilationUnit the compilation unit (may be <code>null</code>).
         */
-       public JavaContext(ContextType type, IDocument document, int completionOffset, int completionLength,
+       public JavaContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
                ICompilationUnit compilationUnit)
        {
-               super(type, document, completionOffset, completionLength); //, compilationUnit);
+               super(type, document, completionOffset, completionLength, compilationUnit);
        }
        
        /**
         * Returns the indentation level at the position of code completion.
         */
        private int getIndentation() {
-//             int start= getStart();
-//             IDocument document= getDocument();
-//             try {
-//                     IRegion region= document.getLineInformationOfOffset(start);
-//                     String lineContent= document.get(region.getOffset(), region.getLength());
+               int start= getStart();
+               IDocument document= getDocument();
+               try {
+                       IRegion region= document.getLineInformationOfOffset(start);
+                       String lineContent= document.get(region.getOffset(), region.getLength());
+                   return Strings.computeIndent(lineContent, CodeFormatterPreferencePage.getTabSize());
 //                     return Strings.computeIndent(lineContent, CodeFormatterUtil.getTabWidth());
-//             } catch (BadLocationException e) {
-//                     return 0;
-//             }
-return 0;
+               } catch (BadLocationException e) {
+                       return 0;
+               }
        }       
        
+       
+
        /*
         * @see TemplateContext#evaluate(Template template)
         */
-       public TemplateBuffer evaluate(Template template) throws CoreException {
+       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
 
                if (!canEvaluate(template))
-                       return null;
+                       throw new TemplateException(JavaTemplateMessages.getString("Context.error.cannot.evaluate")); //$NON-NLS-1$
                
-               TemplateTranslator translator= new TemplateTranslator();
-               TemplateBuffer buffer= translator.translate(template.getPattern());
+               TemplateTranslator translator= new TemplateTranslator() {
+                       /*
+                        * @see org.eclipse.jface.text.templates.TemplateTranslator#createVariable(java.lang.String, java.lang.String, int[])
+                        */
+                       protected TemplateVariable createVariable(String type, String name, int[] offsets) {
+                               return new MultiVariable(type, name, offsets);
+                       }
+               };
+               TemplateBuffer buffer= translator.translate(template);
 
-               getContextType().edit(buffer, this);
+               getContextType().resolve(buffer, this);
                        
                String lineDelimiter= null;
                try {
@@ -99,11 +113,11 @@ return 0;
                        lineDelimiter= PLATFORM_LINE_DELIMITER;
                        
                IPreferenceStore prefs= PHPeclipsePlugin.getDefault().getPreferenceStore();
-//             boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);                    
-//             
-//             ITemplateEditor formatter= new JavaFormatter(lineDelimiter, getIndentation(), useCodeFormatter);
-//             formatter.edit(buffer, this);
-
+               boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);                    
+               
+//             JavaFormatter formatter= new JavaFormatter(lineDelimiter, getIndentation(), useCodeFormatter);
+//             formatter.format(buffer, this);
+               
                return buffer;
        }
        
@@ -117,10 +131,15 @@ return 0;
                        return true;
 
                return
-                       template.matches(key, getContextType().getName()) &&
+                       template.matches(key, getContextType().getId()) &&
                        key.length() != 0 && template.getName().toLowerCase().startsWith(key.toLowerCase());
        }
 
+       public boolean canEvaluate(String identifier) {
+           String prefix = getKey();
+           return
+             identifier.toLowerCase().startsWith(prefix.toLowerCase());
+         }
        /*
         * @see DocumentTemplateContext#getCompletionPosition();
         */
@@ -163,11 +182,11 @@ return 0;
        }
 
        /*
-        * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getEnd()
+        * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getEnd()
         */
        public int getEnd() {
                
-               if (getCompletionLength() == 0)         
+               if (getCompletionLength() == 0)
                        return super.getEnd();
 
                try {                   
@@ -187,7 +206,7 @@ return 0;
        }
 
        /*
-        * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getKey()
+        * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getKey()
         */
        public String getKey() {
 
@@ -224,28 +243,8 @@ return 0;
                }
        }
 
-       private CompilationUnitCompletion guessVariableNames() {
-//             ICompilationUnit unit= getCompilationUnit();
-//             int start= getStart();
-//             
-//             if (unit == null)
-//                     return null;
-//             
-//             try {
-//                     CompilationUnitCompletion collector= new CompilationUnitCompletion(unit);
-//                     unit.codeComplete(start, collector);                    
-//                     return collector;
-//             
-//             } catch (JavaModelException e) {
-//                     handleException(null, e);
-//                     return null;
-//             }
-    return null;
-       }       
-       
-       
        private static void handleException(Shell shell, Exception e) {
-               String title= PHPTemplateMessages.getString("JavaContext.error.title"); //$NON-NLS-1$
+               String title= JavaTemplateMessages.getString("JavaContext.error.title"); //$NON-NLS-1$
                if (e instanceof CoreException)
                        ExceptionHandler.handle((CoreException)e, shell, title, null);
                else if (e instanceof InvocationTargetException)
@@ -256,7 +255,7 @@ return 0;
                }
        }       
 
-       private CompilationUnitCompletion getCompletion() {
+//     private CompilationUnitCompletion getCompletion() {
 //             ICompilationUnit compilationUnit= getCompilationUnit();
 //             if (fCompletion == null) {
 //                     fCompletion= new CompilationUnitCompletion(compilationUnit);
@@ -271,48 +270,95 @@ return 0;
 //             }
 //             
 //             return fCompletion;
-    return null;
-       }
+//     }
 
        /**
         * Returns the name of a guessed local array, <code>null</code> if no local
         * array exists.
         */
-       public String guessArray() {
-               CompilationUnitCompletion completion= getCompletion();
-               LocalVariable[] localArrays= completion.findLocalArrays();
-                               
-               if (localArrays.length > 0)
-                       return localArrays[localArrays.length - 1].name;
-
-               return null;    
+//     public String guessArray() {
+//             return firstOrNull(guessArrays());
+//     }
+       
+       /**
+        * Returns the name of a guessed local array, <code>null</code> if no local
+        * array exists.
+        */
+//     public String[] guessArrays() {
+//             CompilationUnitCompletion completion= getCompletion();
+//             LocalVariable[] localArrays= completion.findLocalArrays();
+//                             
+//             String[] ret= new String[localArrays.length];
+//             for (int i= 0; i < ret.length; i++) {
+//                     ret[ret.length - i - 1]= localArrays[i].name;
+//             }
+//             return ret;
+//     }
+       
+       /**
+        * Returns the name of the type of a local array, <code>null</code> if no local
+        * array exists.
+        */
+//     public String guessArrayType() {
+//             return firstOrNull(guessArrayTypes());
+//     }
+       
+       private String firstOrNull(String[] strings) {
+               if (strings.length > 0)
+                       return strings[0];
+               else
+                       return null;
        }
        
        /**
         * Returns the name of the type of a local array, <code>null</code> if no local
         * array exists.
         */
-       public String guessArrayType() {
-               CompilationUnitCompletion completion= getCompletion();
-               LocalVariable[] localArrays= completion.findLocalArrays();
-                               
-               if (localArrays.length > 0) {
-                       LocalVariable localArray= localArrays[localArrays.length - 1];                  
-
-                       String arrayTypeName= localArray.typeName;
+//     public String[][] guessGroupedArrayTypes() {
+//             CompilationUnitCompletion completion= getCompletion();
+//             LocalVariable[] localArrays= completion.findLocalArrays();
+//             
+//             String[][] ret= new String[localArrays.length][];
+//             
+//             for (int i= 0; i < localArrays.length; i++) {
+//                     String type= getArrayTypeFromLocalArray(completion, localArrays[localArrays.length - i - 1]);
+//                     ret[i]= new String[] {type};
+//             }
+//             
+//             return ret;
+//     }
+       
+       /**
+        * Returns the name of the type of a local array, <code>null</code> if no local
+        * array exists.
+        */
+//     public String[] guessArrayTypes() {
+//             CompilationUnitCompletion completion= getCompletion();
+//             LocalVariable[] localArrays= completion.findLocalArrays();
+//             
+//             List ret= new ArrayList();
+//             
+//             for (int i= 0; i < localArrays.length; i++) {
+//                     String type= getArrayTypeFromLocalArray(completion, localArrays[localArrays.length - i - 1]);
+//                     if (!ret.contains(type))
+//                             ret.add(type);
+//             }
+//             
+//             return (String[]) ret.toArray(new String[ret.size()]);
+//     }
+       
+       private String getArrayTypeFromLocalArray(CompilationUnitCompletion completion, LocalVariable array) {
+                       String arrayTypeName= array.typeName;
                        String typeName= getScalarType(arrayTypeName);
                        int dimension= getArrayDimension(arrayTypeName) - 1;
                        Assert.isTrue(dimension >= 0);
                        
-                       String qualifiedName= createQualifiedTypeName(localArray.typePackageName, typeName);
+                       String qualifiedName= createQualifiedTypeName(array.typePackageName, typeName);
                        String innerTypeName= completion.simplifyTypeName(qualifiedName);
                        
                        return innerTypeName == null
                                ? createArray(typeName, dimension)
                                : createArray(innerTypeName, dimension);
-               }
-               
-               return null;
        }
        
        private static String createArray(String type, int dimension) {
@@ -355,109 +401,212 @@ return 0;
         * Returns a proposal for a variable name of a local array element, <code>null</code>
         * if no local array exists.
         */
-       public String guessArrayElement() {
+//     public String guessArrayElement() {
+//             return firstOrNull(guessArrayElements());
+//     }
+       /**
+        * Returns a proposal for a variable name of a local array element, <code>null</code>
+        * if no local array exists.
+        */
+//     public String[] guessArrayElements() {
+//             ICompilationUnit cu= getCompilationUnit();
+//             if (cu == null) {
+//                     return new String[0];
+//             }
+//             
 //             CompilationUnitCompletion completion= getCompletion();
 //             LocalVariable[] localArrays= completion.findLocalArrays();
 //             
-//             if (localArrays.length > 0) {
-//                     int idx= localArrays.length - 1;
+//             List ret= new ArrayList();
+//             
+//             for (int i= 0; i < localArrays.length; i++) {
+//                     int idx= localArrays.length - i - 1;
 //                     
 //                     LocalVariable var= localArrays[idx];
 //                     
-//                     IJavaProject project= getCompilationUnit().getJavaProject();
+//                     IJavaProject project= cu.getJavaProject();
 //                     String typeName= var.typeName;
 //                     String baseTypeName= typeName.substring(0, typeName.lastIndexOf('['));
 //
-//                     String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, baseTypeName, 0, completion.getLocalVariableNames());
-//                     if (proposals.length > 0) {
-//                             return proposals[0];
+//                     String indexName= getIndex();
+//                     String[] excludedNames= completion.getLocalVariableNames();
+//                     if (indexName != null) {
+//                             ArrayList excludedNamesList= new ArrayList(Arrays.asList(excludedNames));
+//                             excludedNamesList.add(indexName);
+//                             excludedNames= (String[])excludedNamesList.toArray(new String[excludedNamesList.size()]);
+//                     }
+//                     String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, baseTypeName, 0, excludedNames);
+//                     for (int j= 0; j < proposals.length; j++) {
+//                             if (!ret.contains(proposals[j]))
+//                                     ret.add(proposals[j]);
 //                     }
 //             }
+//             
+//             return (String[]) ret.toArray(new String[ret.size()]);
+//     }
 
-               return null;
-       }
+       /**
+        * Returns a proposal for a variable name of a local array element, <code>null</code>
+        * if no local array exists.
+        */
+//     public String[][] guessGroupedArrayElements() {
+//             ICompilationUnit cu= getCompilationUnit();
+//             if (cu == null) {
+//                     return new String[0][];
+//             }
+//             
+//             CompilationUnitCompletion completion= getCompletion();
+//             LocalVariable[] localArrays= completion.findLocalArrays();
+//             
+//             String[][] ret= new String[localArrays.length][];
+//             
+//             for (int i= 0; i < localArrays.length; i++) {
+//                     int idx= localArrays.length - i - 1;
+//                     
+//                     LocalVariable var= localArrays[idx];
+//                     
+//                     IJavaProject project= cu.getJavaProject();
+//                     String typeName= var.typeName;
+//                     int dim= -1; // we expect at least one array
+//                     int lastIndex= typeName.length();
+//                     int bracket= typeName.lastIndexOf('[');
+//                     while (bracket != -1) {
+//                             lastIndex= bracket;
+//                             dim++;
+//                             bracket= typeName.lastIndexOf('[', bracket - 1);
+//                     }
+//                     typeName= typeName.substring(0, lastIndex);
+//                     
+//                     String indexName= getIndex();
+//                     String[] excludedNames= completion.getLocalVariableNames();
+//                     if (indexName != null) {
+//                             ArrayList excludedNamesList= new ArrayList(Arrays.asList(excludedNames));
+//                             excludedNamesList.add(indexName);
+//                             excludedNames= (String[])excludedNamesList.toArray(new String[excludedNamesList.size()]);
+//                     }
+//                     String[] proposals= NamingConventions.suggestLocalVariableNames(project, var.typePackageName, typeName, dim, excludedNames);
+//                     
+//                     ret[i]= proposals;
+//             }
+//             
+//             return ret;
+//     }
 
        /**
         * Returns an array index name. 'i', 'j', 'k' are tried until no name collision with
         * an existing local variable occurs. If all names collide, <code>null</code> is returned.
         */     
-       public String getIndex() {
-               CompilationUnitCompletion completion= getCompletion();
-               String[] proposals= {"i", "j", "k"};  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-               
-               for (int i= 0; i != proposals.length; i++) {
-                       String proposal = proposals[i];
-
-                       if (!completion.existsLocalName(proposal))
-                               return proposal;
-               }
-
-               return null;
-       }
+//     public String getIndex() {
+//             CompilationUnitCompletion completion= getCompletion();
+//             String[] proposals= {"i", "j", "k"};  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//             
+//             for (int i= 0; i != proposals.length; i++) {
+//                     String proposal = proposals[i];
+//
+//                     if (!completion.existsLocalName(proposal))
+//                             return proposal;
+//             }
+//
+//             return null;
+//     }
        
        /**
         * Returns the name of a local collection, <code>null</code> if no local collection
         * exists.
         */
-       public String guessCollection() {
-               CompilationUnitCompletion completion= getCompletion();
-               try {
-                       LocalVariable[] localCollections= completion.findLocalCollections();
-               
-                       if (localCollections.length > 0)
-                               return localCollections[localCollections.length - 1].name;
-
-               } catch (JavaModelException e) {
-                       PHPeclipsePlugin.log(e);
-               }
-
-               return null;
-       }
+//     public String guessCollection() {
+//             return firstOrNull(guessCollections());
+//     }
+       
+       /**
+        * Returns the names of local collections.
+        */
+//     public String[] guessCollections() {
+//             CompilationUnitCompletion completion= getCompletion();
+//             try {
+//                     LocalVariable[] localCollections= completion.findLocalCollections();
+//                     String[] ret= new String[localCollections.length];
+//                     for (int i= 0; i < ret.length; i++) {
+//                             ret[ret.length - i - 1]= localCollections[i].name;
+//                     }
+//                     
+//                     return ret;
+//
+//             } catch (JavaModelException e) {
+//                     JavaPlugin.log(e);
+//             }
+//
+//             return new String[0];
+//     }
+       
 
        /**
         * Returns an iterator name ('iter'). If 'iter' already exists as local variable,
         * <code>null</code> is returned.
         */
-       public String getIterator() {
-               CompilationUnitCompletion completion= getCompletion();          
-               String[] proposals= {"iter"}; //$NON-NLS-1$
-               
-               for (int i= 0; i != proposals.length; i++) {
-                       String proposal = proposals[i];
-
-                       if (!completion.existsLocalName(proposal))
-                               return proposal;
-               }
-
-               return null;
-       }
+//     public String getIterator() {
+//             CompilationUnitCompletion completion= getCompletion();          
+//             String[] proposals= {"iter"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//             
+//             for (int i= 0; i != proposals.length; i++) {
+//                     String proposal = proposals[i];
+//
+//                     if (!completion.existsLocalName(proposal))
+//                             return proposal;
+//             }
+//
+//             return null;
+//     }
 
 
 //     public void addIteratorImport() {
+//             ICompilationUnit cu= getCompilationUnit();
+//             if (cu == null) {
+//                     return;
+//             }
 //     
 //             try {
+//                     Position position= new Position(getCompletionOffset(), getCompletionLength());
+//                     IDocument document= getDocument();
+//                     final String category= "__template_position_importer" + System.currentTimeMillis(); //$NON-NLS-1$
+//                     IPositionUpdater updater= new DefaultPositionUpdater(category);
+//                     document.addPositionCategory(category);
+//                     document.addPositionUpdater(updater);
+//                     document.addPosition(position);
+//
 //                     CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
-//                     ImportsStructure structure= new ImportsStructure(getCompilationUnit(), settings.importOrder, settings.importThreshold, true);
+//                     ImportsStructure structure= new ImportsStructure(cu, settings.importOrder, settings.importThreshold, true);
 //                     structure.addImport("java.util.Iterator"); //$NON-NLS-1$
 //                     structure.create(false, null);
 //
+//                     document.removePosition(position);
+//                     document.removePositionUpdater(updater);
+//                     document.removePositionCategory(category);
+//                     
+//                     setCompletionOffset(position.getOffset());
+//                     setCompletionLength(position.getLength());
+//                     
 //             } catch (CoreException e) {
 //                     handleException(null, e);
+//             } catch (BadLocationException e) {
+//                     handleException(null, e);
+//             } catch (BadPositionCategoryException e) {
+//                     handleException(null, e);
 //             }
 //     }
        
        /**
         * Evaluates a 'java' template in thecontext of a compilation unit
         */
-       public static String evaluateTemplate(Template template, ICompilationUnit compilationUnit, int position) throws CoreException {
+       public static String evaluateTemplate(Template template, ICompilationUnit compilationUnit, int position) throws CoreException, BadLocationException, TemplateException {
 
-               ContextType contextType= ContextTypeRegistry.getInstance().getContextType("php"); //$NON-NLS-1$
+               TemplateContextType contextType= PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType("java"); //$NON-NLS-1$
                if (contextType == null)
-                       throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, PHPTemplateMessages.getString("JavaContext.error.message"), null)); //$NON-NLS-1$
+                       throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, JavaTemplateMessages.getString("JavaContext.error.message"), null)); //$NON-NLS-1$
 
                IDocument document= new Document();
-//             if (compilationUnit != null && compilationUnit.exists())
-//                     document.set(compilationUnit.getSource());
+               if (compilationUnit != null && compilationUnit.exists())
+                       document.set(compilationUnit.getSource());
 
                JavaContext context= new JavaContext(contextType, document, position, 0, compilationUnit);
                context.setForceEvaluation(true);
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaContextType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaContextType.java
new file mode 100644 (file)
index 0000000..db516f7
--- /dev/null
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2000, orporation and others.
+ * 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
+ *     Sebastian Davids: sdavids@gmx.de - see bug 25376
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.core.IJavaProject;
+import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+//import net.sourceforge.phpdt.internal.ui.text.template.contentassist.*;
+//import net.sourceforge.phpdt.internal.ui.text.template.contentassist.MultiVariableGuess;
+
+/**
+ * A context type for java code.
+ */
+public class JavaContextType extends CompilationUnitContextType {
+
+       public static final String NAME= "php"; //$NON-NLS-1$
+
+//     protected static class Array extends TemplateVariableResolver {
+//             public Array() {
+//                     super("array", TemplateMessages.getString("JavaContextType.variable.description.array")); //$NON-NLS-1$ //$NON-NLS-2$
+//             }
+//             protected String[] resolveAll(TemplateContext context) {
+//             return ((JavaContext) context).guessArrays();
+//         }
+//             /*
+//              * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
+//              */
+//             public void resolve(TemplateVariable variable, TemplateContext context) {
+//                     if (variable instanceof MultiVariable) {
+//                             JavaContext jc= (JavaContext) context;
+//                             MultiVariable mv= (MultiVariable) variable;
+//                             String[] bindings= resolveAll(context);
+//                             if (bindings.length > 0) {
+//                                     mv.setValues(bindings);
+//                                     MultiVariableGuess guess= jc.getMultiVariableGuess();
+//                                     if (guess == null) {
+//                                             guess= new MultiVariableGuess(mv);
+//                                             jc.setMultiVariableGuess(guess);
+//                                     }
+//                             }
+//                             if (bindings.length > 1)
+//                                     variable.setUnambiguous(false);
+//                             else
+//                                     variable.setUnambiguous(isUnambiguous(context));
+//                     } else
+//                             super.resolve(variable, context);
+//             }
+//     }
+//
+//     protected static class ArrayType extends TemplateVariableResolver {
+//         public ArrayType() {
+//             super("array_type", TemplateMessages.getString("JavaContextType.variable.description.array.type")); //$NON-NLS-1$ //$NON-NLS-2$
+//         }
+//         protected String[] resolveAll(TemplateContext context) {
+//             
+//             String[] arrayTypes= ((JavaContext) context).guessArrayTypes();
+//             if (arrayTypes != null)
+//                     return arrayTypes;
+//             else
+//                     return super.resolveAll(context);
+//         }
+//         
+//             /*
+//              * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
+//              */
+//             public void resolve(TemplateVariable variable, TemplateContext context) {
+//                     if (variable instanceof MultiVariable) {
+//                             MultiVariable mv= (MultiVariable) variable;
+//                             String[] arrays= ((JavaContext) context).guessArrays();
+//                             String[][] types= ((JavaContext) context).guessGroupedArrayTypes();
+//                             
+//                             for (int i= 0; i < arrays.length; i++) {
+//                                     mv.setValues(arrays[i], types[i]);
+//                             }
+//
+//                             if (arrays.length > 1 || types.length == 1 && types[0].length > 1)
+//                                     variable.setUnambiguous(false);
+//                             else
+//                                     variable.setUnambiguous(isUnambiguous(context));
+//                             
+//                     } else
+//                             super.resolve(variable, context);
+//             }
+//     }
+//
+//     protected static class ArrayElement extends TemplateVariableResolver {
+//         public ArrayElement() {
+//             super("array_element", TemplateMessages.getString("JavaContextType.variable.description.array.element"));       //$NON-NLS-1$ //$NON-NLS-2$    
+//         }
+//         protected String[] resolveAll(TemplateContext context) {
+//             return ((JavaContext) context).guessArrayElements();
+//         }       
+//
+//             /*
+//              * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
+//              */
+//             public void resolve(TemplateVariable variable, TemplateContext context) {
+//                     if (variable instanceof MultiVariable) {
+//                             MultiVariable mv= (MultiVariable) variable;
+//                             String[] arrays= ((JavaContext) context).guessArrays();
+//                             String[][] elems= ((JavaContext) context).guessGroupedArrayElements();
+//                             
+//                             for (int i= 0; i < arrays.length; i++) {
+//                                     mv.setValues(arrays[i], elems[i]);
+//                             }
+//
+//                             if (arrays.length > 1 || elems.length == 1 && elems[0].length > 1)
+//                                     variable.setUnambiguous(false);
+//                             else
+//                                     variable.setUnambiguous(isUnambiguous(context));
+//                             
+//                     } else
+//                             super.resolve(variable, context);
+//             }
+//     }
+//
+//     protected static class Index extends TemplateVariableResolver {
+//         public Index() {
+//             super("index", TemplateMessages.getString("JavaContextType.variable.description.index")); //$NON-NLS-1$ //$NON-NLS-2$
+//         }
+//         protected String resolve(TemplateContext context) {
+//             return ((JavaContext) context).getIndex();
+//         }       
+//     }
+//
+//     protected static class Collection extends TemplateVariableResolver {
+//         public Collection() {
+//                 super("collection", TemplateMessages.getString("JavaContextType.variable.description.collection")); //$NON-NLS-1$ //$NON-NLS-2$
+//             }
+//         
+//             protected String[] resolveAll(TemplateContext context) {
+//             String[] collections= ((JavaContext) context).guessCollections();
+//             if (collections.length > 0)
+//                     return collections;
+//             else
+//                     return super.resolveAll(context);
+//             }
+//     }
+//
+//     protected static class Iterator extends TemplateVariableResolver {
+//
+//         public Iterator() {
+//                 super("iterator", TemplateMessages.getString("JavaContextType.variable.description.iterator")); //$NON-NLS-1$ //$NON-NLS-2$
+//             }
+//         protected String resolve(TemplateContext context) {
+//             JavaContext javaContext= (JavaContext) context;
+//
+//                     if (!context.isReadOnly())
+//                     javaContext.addIteratorImport();
+//             
+//             return javaContext.getIterator();
+//         }       
+//     }
+//     
+       protected static class Todo extends TemplateVariableResolver {
+
+               public Todo() {
+                       super("todo", JavaTemplateMessages.getString("JavaContextType.variable.description.todo")); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+               protected String resolve(TemplateContext context) {
+                       JavaContext javaContext= (JavaContext) context;
+                       ICompilationUnit compilationUnit= javaContext.getCompilationUnit();
+                       if (compilationUnit == null)
+                               return "XXX"; //$NON-NLS-1$
+                       
+                       IJavaProject javaProject= compilationUnit.getJavaProject();
+                       String todoTaskTag= StubUtility.getTodoTaskTag(javaProject);
+                       if (todoTaskTag == null)
+                               return "XXX"; //$NON-NLS-1$
+
+                       return todoTaskTag;
+               }
+       }       
+/*
+       protected static class Arguments extends SimpleVariableResolver {
+           public Arguments() {
+               super("arguments", TemplateMessages.getString("JavaContextType.variable.description.arguments"), "");   
+           }
+       }
+*/     
+
+
+       /**
+        * Creates a java context type.
+        */
+       public JavaContextType() {
+               super(NAME);
+               
+               // global
+               addResolver(new GlobalTemplateVariables.Cursor());
+               addResolver(new GlobalTemplateVariables.WordSelection());
+               addResolver(new GlobalTemplateVariables.LineSelection());
+               addResolver(new GlobalTemplateVariables.Dollar());
+               addResolver(new GlobalTemplateVariables.Date());
+               addResolver(new GlobalTemplateVariables.Year());
+               addResolver(new GlobalTemplateVariables.Time());
+               addResolver(new GlobalTemplateVariables.User());
+               
+               // compilation unit
+               addResolver(new File());
+               addResolver(new PrimaryTypeName());
+               addResolver(new ReturnType());
+               addResolver(new Method());
+               addResolver(new Type());
+               addResolver(new Package());
+               addResolver(new Project());
+               addResolver(new Arguments());
+
+               // java
+//             addResolver(new Array());
+//             addResolver(new ArrayType());
+//             addResolver(new ArrayElement());
+//             addResolver(new Index());
+//             addResolver(new Iterator());
+//             addResolver(new Collection());
+               addResolver(new Todo());
+       }
+       
+
+       /* (non-Javadoc)
+        * @see net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, net.sourceforge.phpdt.core.ICompilationUnit)
+        */
+       public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
+               return new JavaContext(this, document, offset, length, compilationUnit);
+       }
+
+}
@@ -1,23 +1,30 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.corext.template.php;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
-import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
-
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateTranslator;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+
 
 /**
- * A context for phpdoc.
+ * A context for javadoc.
  */
-public class PHPDocContext extends DocumentTemplateContext  {
+public class JavaDocContext extends CompilationUnitContext {
 
        // tags
        private static final char HTML_TAG_BEGIN= '<';
@@ -25,18 +32,18 @@ public class PHPDocContext extends DocumentTemplateContext  {
        private static final char JAVADOC_TAG_BEGIN= '@';       
 
        /**
-        * Creates a phpdoc template context.
+        * Creates a javadoc template context.
         * 
         * @param type   the context type.
         * @param document the document.
-        * @param completionPosition the completion position within the document.
-        * @param unit the compilation unit (may be <code>null</code>).
+        * @param completionOffset the completion offset within the document.
+        * @param completionLength the completion length within the document.
+        * @param compilationUnit the compilation unit (may be <code>null</code>).
         */
-       public PHPDocContext(ContextType type, IDocument document, int completionOffset, int completionLength)
-       //, int completionOffset, int completionLength, ICompilationUnit compilationUnit)
+       public JavaDocContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
+               ICompilationUnit compilationUnit)
        {
-    super(type, document, completionOffset, completionLength);
-//             super(type, document, completionOffset, completionLength, compilationUnit);
+               super(type, document, completionOffset, completionLength, compilationUnit);
        }
 
        /*
@@ -45,12 +52,12 @@ public class PHPDocContext extends DocumentTemplateContext  {
        public boolean canEvaluate(Template template) {
                String key= getKey();
                
-//             if (fForceEvaluation)
-//                     return true;
-    return template.matches(getKey(), getContextType().getName());
-//             return
-//                     template.matches(key, getContextType().getName()) &&
-//                     (key.length() != 0) && template.getName().toLowerCase().startsWith(key.toLowerCase());
+               if (fForceEvaluation)
+                       return true;
+
+               return
+                       template.matches(key, getContextType().getId()) &&
+                       (key.length() != 0) && template.getName().toLowerCase().startsWith(key.toLowerCase());
        }
 
        /*
@@ -72,7 +79,7 @@ public class PHPDocContext extends DocumentTemplateContext  {
                                if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
                                        start--;
                
-                               // include html and phpdoc tags
+                               // include html and javadoc tags
                                if ((start != 0) && (
                                        (document.getChar(start - 1) == HTML_TAG_BEGIN) ||
                                        (document.getChar(start - 1) == JAVADOC_TAG_BEGIN)))
@@ -105,7 +112,7 @@ public class PHPDocContext extends DocumentTemplateContext  {
        }
 
        /*
-        * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getEnd()
+        * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getEnd()
         */
        public int getEnd() {
                
@@ -129,7 +136,7 @@ public class PHPDocContext extends DocumentTemplateContext  {
        }
 
        /*
-        * @see net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext#getKey()
+        * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getKey()
         */
        public String getKey() {
 
@@ -153,11 +160,11 @@ public class PHPDocContext extends DocumentTemplateContext  {
        /*
         * @see TemplateContext#evaluate(Template)
         */
-       public TemplateBuffer evaluate(Template template) throws CoreException {
+       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
                TemplateTranslator translator= new TemplateTranslator();
-               TemplateBuffer buffer= translator.translate(template.getPattern());
+               TemplateBuffer buffer= translator.translate(template);
 
-               getContextType().edit(buffer, this);
+               getContextType().resolve(buffer, this);
                        
                return buffer;
        }
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaDocContextType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaDocContextType.java
new file mode 100644 (file)
index 0000000..c44e026
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.*;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+
+
+/**
+ * A context type for javadoc.
+ */
+public class JavaDocContextType extends CompilationUnitContextType {
+
+       public static final String NAME= "phpdoc"; //$NON-NLS-1$
+
+       /**
+        * Creates a java context type.
+        */
+       public JavaDocContextType() {
+               super(NAME);
+               
+               // global
+               addResolver(new GlobalTemplateVariables.Cursor());
+               addResolver(new GlobalTemplateVariables.LineSelection());
+               addResolver(new GlobalTemplateVariables.WordSelection());
+               addResolver(new GlobalTemplateVariables.Dollar());
+               addResolver(new GlobalTemplateVariables.Date());
+               addResolver(new GlobalTemplateVariables.Year());
+               addResolver(new GlobalTemplateVariables.Time());
+               addResolver(new GlobalTemplateVariables.User());
+               
+               // compilation unit
+               addResolver(new File());
+               addResolver(new PrimaryTypeName());
+               addResolver(new Method());
+               addResolver(new ReturnType());
+               addResolver(new Arguments());
+               addResolver(new Type());
+               addResolver(new Package());
+               addResolver(new Project());
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.corext.template.java.CompilationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.jdt.core.ICompilationUnit)
+        */
+       public CompilationUnitContext createContext(IDocument document, int offset, int length, ICompilationUnit compilationUnit) {
+               return new JavaDocContext(this, document, offset, length, compilationUnit);
+       }       
+       
+}
@@ -1,19 +1,25 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.corext.template.php;
 
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-public class PHPTemplateMessages {
+class JavaTemplateMessages {
 
-       private static final String RESOURCE_BUNDLE= PHPTemplateMessages.class.getName();
+       private static final String RESOURCE_BUNDLE= JavaTemplateMessages.class.getName();
        private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
 
-       private PHPTemplateMessages() {
+       private JavaTemplateMessages() {
        }
 
        public static String getString(String key) {
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaTemplateMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/JavaTemplateMessages.properties
new file mode 100644 (file)
index 0000000..bf31395
--- /dev/null
@@ -0,0 +1,139 @@
+###############################################################################
+# Copyright (c) 2000, 2004 IBM Corporation and others.
+# 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
+###############################################################################
+
+
+ContextType.error.multiple.cursor.variables=Template has multiple cursor variables.
+
+Templates.for_array=iterate over array
+Templates.for_temp=iterate over array with temporary variable
+Templates.for_collection=iterate over collection
+Templates.while_enumeration=iterate with enumeration
+Templates.while_iterator=iterate with iterator
+Templates.do=do while statement
+Templates.switch=switch case statement
+Templates.if=if statement
+Templates.ifelse=if else statement
+Templates.elseif=else if block
+Templates.else=else block
+Templates.try=try catch block
+Templates.catch=catch block
+Templates.main=main method
+Templates.public_method=public method
+Templates.protected_method=protected method
+Templates.private_method=private method
+Templates.private_static_method=private static method
+Templates.instanceof=dynamic type test and cast
+Templates.cast=dynamic cast
+Templates.toarray=convert collection to array
+Templates.test=test method
+Templates.systrace=print current method to standard out
+Templates.sysout=print to standard out
+Templates.syserr=print to standard error
+Templates.code_tag=<code></code>
+Templates.code_tag_null=<code>null</code>
+Templates.pre_tag=<pre></pre>
+Templates.b_tag=<b></b>
+Templates.i_tag=<i></i>
+Templates.author=author name
+Templates.new=create new object
+Templates.lazy=lazy creation
+Templates.while_condition=while loop with condition
+
+# Java Only stuff
+CompilationUnitContextType.variable.description.file=Filename of compilation unit
+CompilationUnitContextType.variable.description.primary.type.name=Filename without extension
+CompilationUnitContextType.variable.description.enclosing.method=Enclosing method name
+CompilationUnitContextType.variable.description.enclosing.type=Enclosing type name
+CompilationUnitContextType.variable.description.enclosing.package=Enclosing package name
+CompilationUnitContextType.variable.description.enclosing.project=Enclosing project name
+CompilationUnitContextType.variable.description.enclosing.method.arguments=Argument names of enclosing method
+CompilationUnitContextType.variable.description.return.type=Enclosing method return type
+
+JavaContextType.variable.description.array=A proposal for an array
+JavaContextType.variable.description.array.type=A proposal for the element type of an array
+JavaContextType.variable.description.array.element=A proposal for the element name of an array
+JavaContextType.variable.description.index=A proposal for an index (int)
+JavaContextType.variable.description.collection=A proposal for a collection (java.util.Collection)
+JavaContextType.variable.description.iterator=A proposal for an iterator (java.util.Iterator)
+JavaContextType.variable.description.todo=Todo task tag
+
+JavaContext.error.title=Template Error
+JavaContext.error.message=Template file incomplete or has errors.  You can load the default templates from the template preferences page (Java>Templates).
+
+CodeTemplateContextType.variable.description.todo=Todo task tag
+CodeTemplateContextType.variable.description.packdeclaration=Package declaration of the new type
+CodeTemplateContextType.variable.description.typedeclaration=Generated type declaration
+CodeTemplateContextType.variable.description.getterfieldname=The name of field to set or get
+CodeTemplateContextType.variable.description.getterfieldtype=The type of the field to set or get
+CodeTemplateContextType.variable.description.fieldname=The name of field
+CodeTemplateContextType.variable.description.fieldtype=The type of the field
+CodeTemplateContextType.variable.description.barefieldname=The name of field to set or get without pre- or suffix
+CodeTemplateContextType.variable.description.param=The parameter passed into the setter method
+CodeTemplateContextType.variable.description.typecomment=Content of code template 'typecomment'
+CodeTemplateContextType.variable.description.exceptiontype=The type of the caught exception
+CodeTemplateContextType.variable.description.exceptionvar=The variable name of the caught exception
+CodeTemplateContextType.variable.description.enclosingtype=The type enclosing this method
+CodeTemplateContextType.variable.description.typename=Name of the current type
+CodeTemplateContextType.variable.description.enclosingmethod=The enclosing method
+CodeTemplateContextType.variable.description.bodystatement=Return statement or super call
+CodeTemplateContextType.variable.description.returntype=Return type of the enclosing method
+CodeTemplateContextType.variable.description.tags=Generated Javadoc tags (@param, @return...)
+CodeTemplateContextType.variable.description.seetag=See tag pointing to the overridden method (@see T#m())
+
+CodeTemplateContextType.variable.description.filename=Name of the enclosing compilation unit
+CodeTemplateContextType.variable.description.packagename=Name of the enclosing package
+CodeTemplateContextType.variable.description.projectname=Name of the enclosing project
+
+CodeTemplateContextType.validate.unknownvariable=Variable ''{0}'' is unknown.
+CodeTemplateContextType.validate.missingvariable=Variable ''{0}'' is required.
+CodeTemplateContextType.validate.invalidcomment=Pattern is not a valid Java comment.
+
+
+
+CodeTemplates.error.title=Error accessing code templates.
+
+# strings in default templates
+CodeTemplates.constructorcomment=Comment for created constructors
+CodeTemplates.typecomment=Comment for created types
+CodeTemplates.fieldcomment=Comment for fields
+CodeTemplates.nonoverridingcomment=Comment for non-overriding methods
+CodeTemplates.overridecomment=Comment for overriding methods
+CodeTemplates.gettercomment=Comment for getter method
+# ! Do not translate ${bare_field_name} !
+CodeTemplates.gettercomment.returntagcontent=Returns the ${bare_field_name}.
+CodeTemplates.settercomment=Comment for setter method
+# ! Do not translate ${bare_field_name} !
+CodeTemplates.settercomment.paramtagcontent=The ${bare_field_name} to set.
+
+CodeTemplates.newfile=Newly created files
+CodeTemplates.catchblock=Code in new catch blocks
+CodeTemplates.methodstub=Code in created method stubs
+CodeTemplates.constructorstub=Code in created constructor stubs
+CodeTemplates.getterstub=Code in created getters
+CodeTemplates.setterstub=Code in created setters
+
+# ! Do not translate @todo !
+CodeTemplates.typecomment.content1=To change the template for this generated type comment go to
+CodeTemplates.typecomment.content2=Window - Preferences - Java - Code Style - Code Templates
+
+# ! Do not translate ${field} !
+CodeTemplates.fieldcomment.content=Comment for <code>${field}</code>
+
+CodeTemplates.overridecomment.nonjd=(non-Javadoc)
+
+# ! Do not translate ${date} !
+CodeTemplates.newfile.content1=Created on ${date}
+CodeTemplates.newfile.content2=To change the template for this generated file go to
+CodeTemplates.newfile.content3=Window - Preferences - Java - Code Style - Code Templates
+
+CodeTemplates.catchblock.tododesc=Auto-generated catch block
+CodeTemplates.methodstub.tododesc=Auto-generated method stub
+CodeTemplates.constructorstub.tododesc=Auto-generated constructor stub
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPContextType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPContextType.java
deleted file mode 100644 (file)
index 608a93a..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.php;
-
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
-
-/**
- * A context type for java code.
- */
-public class PHPContextType extends CompilationUnitContextType {
-/*
-       protected static class Array extends TemplateVariable {
-               public Array() {
-                       super(JavaTemplateMessages.getString("JavaContextType.variable.name.array"), JavaTemplateMessages.getString("JavaContextType.variable.description.array")); //$NON-NLS-1$ //$NON-NLS-2$
-               }
-           public String evaluate(TemplateContext context) {
-               return ((JavaContext) context).guessArray();
-           }
-       }
-
-       protected static class ArrayType extends TemplateVariable {
-           public ArrayType() {
-               super(JavaTemplateMessages.getString("JavaContextType.variable.name.array.type"), JavaTemplateMessages.getString("JavaContextType.variable.description.array.type")); //$NON-NLS-1$ //$NON-NLS-2$
-           }
-           public String evaluate(TemplateContext context) {
-               return ((JavaContext) context).guessArrayType();
-           }
-       }
-
-       protected static class ArrayElement extends TemplateVariable {
-           public ArrayElement() {
-               super(JavaTemplateMessages.getString("JavaContextType.variable.name.array.element"), JavaTemplateMessages.getString("JavaContextType.variable.description.array.element"));     //$NON-NLS-1$ //$NON-NLS-2$    
-           }
-           public String evaluate(TemplateContext context) {
-               return ((JavaContext) context).guessArrayElement();
-           }       
-       }
-
-       protected static class Index extends TemplateVariable {
-           public Index() {
-               super(JavaTemplateMessages.getString("JavaContextType.variable.name.index"), JavaTemplateMessages.getString("JavaContextType.variable.description.index")); //$NON-NLS-1$ //$NON-NLS-2$
-           }
-           public String evaluate(TemplateContext context) {
-               return ((JavaContext) context).getIndex();
-           }       
-       }
-
-       protected static class Collection extends TemplateVariable {
-           public Collection() {
-                   super(JavaTemplateMessages.getString("JavaContextType.variable.name.collection"), JavaTemplateMessages.getString("JavaContextType.variable.description.collection")); //$NON-NLS-1$ //$NON-NLS-2$
-               }
-           public String evaluate(TemplateContext context) {
-               return ((JavaContext) context).guessCollection();
-           }
-       }
-
-       protected static class Iterator extends TemplateVariable {
-           public Iterator() {
-                   super(JavaTemplateMessages.getString("JavaContextType.variable.name.iterator"), JavaTemplateMessages.getString("JavaContextType.variable.description.iterator")); //$NON-NLS-1$ //$NON-NLS-2$
-               }
-           public String evaluate(TemplateContext context) {
-               return ((JavaContext) context).getIterator();
-           }       
-       }
-
-*/     
-
-
-       /**
-        * Creates a java context type.
-        */
-       public PHPContextType() {
-               super("php"); //$NON-NLS-1$
-               
-               // global
-               addVariable(new GlobalVariables.Cursor());
-               addVariable(new GlobalVariables.Dollar());
-               addVariable(new GlobalVariables.Date());
-    addVariable(new GlobalVariables.Year());
-               addVariable(new GlobalVariables.Time());
-               addVariable(new GlobalVariables.User());
-               
-               // compilation unit
-       /*      addVariable(new File());
-               addVariable(new ReturnType());
-               addVariable(new Method());
-               addVariable(new Type());
-               addVariable(new Package());
-               addVariable(new Project());
-               addVariable(new Arguments());
-
-               // java
-               addVariable(new Array());
-               addVariable(new ArrayType());
-               addVariable(new ArrayElement());
-               addVariable(new Index());
-               addVariable(new Iterator());
-               addVariable(new Collection());*/
-       }
-       
-       /*
-        * @see ContextType#createContext()
-        */     
-       public TemplateContext createContext() {
-               return new PHPUnitContext(this, fDocument, fOffset); //, fCompilationUnit);
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPDocContextType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPDocContextType.java
deleted file mode 100644 (file)
index 38a1f49..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.php;
-
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
-
-/**
- * A context type for phpdoc.
- */
-public class PHPDocContextType extends CompilationUnitContextType {
-
-       /**
-        * Creates a php context type.
-        */
-       public PHPDocContextType() {
-               super("phpdoc"); //$NON-NLS-1$
-               
-               // global
-               addVariable(new GlobalVariables.Cursor());
-               addVariable(new GlobalVariables.Dollar());
-               addVariable(new GlobalVariables.Date());
-               addVariable(new GlobalVariables.Year());
-               addVariable(new GlobalVariables.Time());
-               addVariable(new GlobalVariables.User());
-               
-               // compilation unit
-/*             addVariable(new File());
-               addVariable(new Method());
-               addVariable(new ReturnType());
-               addVariable(new Arguments());
-               addVariable(new Type());
-               addVariable(new Package());
-               addVariable(new Project()); */
-       }
-       
-       /*
-        * @see ContextType#createContext()
-        */     
-       public TemplateContext createContext() {
-               return new PHPDocContext(this, fDocument, fOffset, fLength); // , fCompilationUnit);
-       }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.properties
deleted file mode 100644 (file)
index 56b2e96..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#########################################
-# (c) Copyright IBM Corp. 2000, 2001.
-# All Rights Reserved.
-#########################################
-
-GlobalVariables.variable.description.cursor=The cursor position after editing template variables
-GlobalVariables.variable.description.dollar=The dollar symbol
-GlobalVariables.variable.description.date=Current date
-GlobalVariables.variable.description.year=Current year
-GlobalVariables.variable.description.time=Current time
-GlobalVariables.variable.description.user=User name
-
-GlobalVariables.variable.name.cursor=cursor
-GlobalVariables.variable.name.dollar=dollar
-GlobalVariables.variable.name.date=date
-GlobalVariables.variable.name.year=year
-GlobalVariables.variable.name.time=time
-GlobalVariables.variable.name.user=user
-
-# GlobalVariables.variable.description.line=Current line number
-
-CompilationUnitContextType.variable.description.file=Filename of compilation unit
-CompilationUnitContextType.variable.description.enclosing.method=Enclosing method name
-CompilationUnitContextType.variable.description.enclosing.type=Enclosing type name
-CompilationUnitContextType.variable.description.enclosing.package=Enclosing package name
-CompilationUnitContextType.variable.description.enclosing.project=Enclosing project name
-CompilationUnitContextType.variable.description.enclosing.method.arguments=Argument names of enclosing method
-CompilationUnitContextType.variable.description.return.type=Enclosing method return type
-
-CompilationUnitContextType.variable.name.file=file
-CompilationUnitContextType.variable.name.enclosing.method=enclosing_method
-CompilationUnitContextType.variable.name.enclosing.type=enclosing_type
-CompilationUnitContextType.variable.name.enclosing.package=enclosing_package
-CompilationUnitContextType.variable.name.enclosing.project=enclosing_project
-CompilationUnitContextType.variable.name.enclosing.method.arguments=enclosing_method_arguments
-CompilationUnitContextType.variable.name.return.type=return_type
-
-JavaContextType.variable.description.array=A proposal for an array
-JavaContextType.variable.description.array.type=A proposal for the element type of an array
-JavaContextType.variable.description.array.element=A proposal for the element name of an array
-JavaContextType.variable.description.index=A proposal for an index (int)
-JavaContextType.variable.description.collection=A proposal for a collection (java.util.Collection)
-JavaContextType.variable.description.iterator=A proposal for an iterator (java.util.Iterator)
-JavaContextType.variable.description.arguments=Method arguments (evaluates to empty string)
-
-JavaContextType.variable.name.array=array
-JavaContextType.variable.name.array.type=array_type
-JavaContextType.variable.name.array.element=array_element
-JavaContextType.variable.name.index=index
-JavaContextType.variable.name.collection=collection
-JavaContextType.variable.name.iterator=iterator
-JavaContextType.variable.name.arguments=Method arguments (evaluates to empty string)
-
-JavaContext.error.title=Template Error
-JavaContext.error.message=PHP context type missing
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java
deleted file mode 100644 (file)
index 3f27a31..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.php;
-
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
-import net.sourceforge.phpdt.internal.corext.template.ITemplateEditor;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
-import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A compilation unit context.
- */
-public class PHPUnitContext extends DocumentTemplateContext {
-
-  /** The platform default line delimiter. */
-  private static final String PLATFORM_LINE_DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$
-
-  private static final String specialChars = "$";
-  /** The compilation unit, may be <code>null</code>. */
-  //   private final ICompilationUnit fCompilationUnit;
-       protected boolean fForceEvaluation;
-  /**
-   * Creates a compilation unit context.
-   * 
-   * @param type   the context type.
-   * @param document the document.
-   * @param completionPosition the completion position within the document.
-   * @param compilationUnit the compilation unit (may be <code>null</code>).
-   */
-  protected PHPUnitContext(ContextType type, IDocument document, int completionPosition)
-  //,ICompilationUnit compilationUnit)
-  {
-    super(type, document, completionPosition, 0);
-    // fCompilationUnit= compilationUnit;
-  }
-       
-       protected PHPUnitContext(ContextType type, IDocument document, int completionPosition, int completionLength)
-               //,ICompilationUnit compilationUnit)
-               {
-                       super(type, document, completionPosition, completionLength);
-                       //      fCompilationUnit= compilationUnit;
-               }
-               
-  /*
-  * @see TemplateContext#canEvaluate(Template templates)
-  */
-  public boolean canEvaluate(Template template) {
-    // return fForceEvaluation || 
-    return template.matches(getKey(), getContextType().getName());
-  }
-
-  /**
-   * Returns <code>true</code> if template matches the prefix and context,
-   * <code>false</code> otherwise.
-   */
-  public boolean canEvaluate(String identifier) {
-    String prefix = getKey();
-    return
-    //      fEnabled &&
-    //      fContextTypeName.equals(contextTypeName) &&
-//      (prefix.length() != 0) && 
-      identifier.toLowerCase().startsWith(prefix.toLowerCase());
-  }
-
-  /*
-  * @see TemplateContext#evaluate(Template template)
-  */
-  public TemplateBuffer evaluate(Template template) throws CoreException {
-    if (!canEvaluate(template))
-      return null;
-
-    TemplateTranslator translator = new TemplateTranslator();
-    TemplateBuffer buffer = translator.translate(template.getPattern());
-
-    getContextType().edit(buffer, this);
-
-    String lineDelimiter = null;
-    try {
-      lineDelimiter = getDocument().getLineDelimiter(0);
-    } catch (BadLocationException e) {
-    }
-
-    if (lineDelimiter == null)
-      lineDelimiter = PLATFORM_LINE_DELIMITER;
-
-//    ITemplateEditor formatter= new PHPFormatter(lineDelimiter);
-//    formatter.edit(buffer, this);
-
-    return buffer;
-  }
-
-  /*
-   * @see DocumentTemplateContext#getCompletionPosition();
-   */
-  public int getStart() {
-    IDocument document = getDocument();
-    try {
-      int start = getCompletionOffset();
-
-         if ( ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) {
-               return --start;
-         }
-         
-      while (((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
-        || ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) {
-        start--;
-      }
-
-      if (((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
-        || ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) {
-        start--;
-      }
-
-      return start;
-
-    } catch (BadLocationException e) {
-      return getCompletionOffset();
-    }
-  }
-
-  /**
-   * Returns the character before start position of completion.
-   */
-  public char getCharacterBeforeStart() {
-    int start = getStart();
-
-    try {
-      return start == 0 ? ' ' : getDocument().getChar(start - 1);
-
-    } catch (BadLocationException e) {
-      return ' ';
-    }
-  }
-  
-  /**
-   * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
-   */
-  //   public final ICompilationUnit getCompilationUnit() {
-  //           return fCompilationUnit;
-  //   }
-
-  /**
-   * Returns the enclosing element of a particular element type, <code>null</code>
-   * if no enclosing element of that type exists.
-   */
-  //   public IJavaElement findEnclosingElement(int elementType) {
-  //           if (fCompilationUnit == null)
-  //                   return null;
-  //
-  //           try {
-  //                   IJavaElement element= fCompilationUnit.getElementAt(getStart());
-  //                   while (element != null && element.getElementType() != elementType)
-  //                           element= element.getParent();
-  //                   
-  //                   return element;
-  //
-  //           } catch (JavaModelException e) {
-  //                   return null;
-  //           }       
-  //   }
-
-  /**
-   * @param b
-   */
-  public void setForceEvaluation(boolean b) {
-    fForceEvaluation = b;
-  }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/TemplateSet.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/TemplateSet.java
new file mode 100644 (file)
index 0000000..74353e0
--- /dev/null
@@ -0,0 +1,401 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateException;
+
+/**
+ * <code>TemplateSet</code> manages a collection of templates and makes them
+ * persistent.
+ * 
+ * @deprecated use TemplateStore instead
+ * @since 3.0
+ */
+public class TemplateSet {
+
+       private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
+       private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
+       private static final String CONTEXT_ATTRIBUTE= "context"; //$NON-NLS-1$
+
+       private List fTemplates= new ArrayList();
+       private String fTemplateTag;
+       
+       private static final int TEMPLATE_PARSE_EXCEPTION= 10002;
+       private static final int TEMPLATE_IO_EXCEPTION= 10005;
+       private ContextTypeRegistry fRegistry;
+       
+       public TemplateSet(String templateTag, ContextTypeRegistry registry) {
+               fTemplateTag= templateTag;
+               fRegistry= registry;
+       }
+       
+       /**
+        * Convenience method for reading templates from a file.
+        * 
+        * @param file
+        * @param allowDuplicates
+        * @param bundle
+        * @see #addFromStream(InputStream, boolean, boolean, ResourceBundle)
+        * @throws CoreException
+        */
+       public void addFromFile(File file, boolean allowDuplicates, ResourceBundle bundle) throws CoreException {
+               InputStream stream= null;
+
+               try {
+                       stream= new FileInputStream(file);
+                       addFromStream(stream, allowDuplicates, false, bundle);
+
+               } catch (IOException e) {
+                       throwReadException(e);
+
+               } finally {
+                       try {
+                               if (stream != null)
+                                       stream.close();
+                       } catch (IOException e) {}
+               }               
+       }
+       
+       public String getTemplateTag() {
+               return fTemplateTag;
+       }
+       
+
+       /**
+        * Reads templates from a XML stream and adds them to the templates
+        * 
+        * @param stream
+        * @param allowDuplicates
+        * @param bundle
+        * @param doTranslations
+        * @see #addFromStream(InputStream, boolean, boolean, ResourceBundle)
+        * @throws CoreException
+        */     
+       public void addFromStream(InputStream stream, boolean allowDuplicates, boolean doTranslations, ResourceBundle bundle) throws CoreException {
+               try {
+                       DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
+                       DocumentBuilder parser= factory.newDocumentBuilder();           
+                       Document document= parser.parse(new InputSource(stream));
+                       
+                       NodeList elements= document.getElementsByTagName(getTemplateTag());
+                       
+                       int count= elements.getLength();
+                       for (int i= 0; i != count; i++) {
+                               Node node= elements.item(i);                                    
+                               NamedNodeMap attributes= node.getAttributes();
+
+                               if (attributes == null)
+                                       continue;
+
+                               String name= getAttributeValue(attributes, NAME_ATTRIBUTE);
+                               String description= getAttributeValue(attributes, DESCRIPTION_ATTRIBUTE);
+                               if (name == null || description == null)
+                                       continue;
+                               
+                               if (doTranslations) {
+                                       description= translateString(description, bundle);
+                               } 
+                               String context= getAttributeValue(attributes, CONTEXT_ATTRIBUTE);
+
+                               if (name == null || description == null || context == null)
+                                       throw new SAXException(JavaTemplateMessages.getString("TemplateSet.error.missing.attribute")); //$NON-NLS-1$
+
+                               StringBuffer buffer= new StringBuffer();
+                               NodeList children= node.getChildNodes();
+                               for (int j= 0; j != children.getLength(); j++) {
+                                       String value= children.item(j).getNodeValue();
+                                       if (value != null)
+                                               buffer.append(value);
+                               }
+                               String pattern= buffer.toString().trim();
+                               if (doTranslations) {
+                                       pattern= translateString(pattern, bundle);
+                               }                               
+
+                               Template template= new Template(name, description, context, pattern);
+                               
+                               String message= validateTemplate(template);
+                               if (message == null) {
+                                       if (!allowDuplicates) {
+                                               Template[] templates= getTemplates(name);
+                                               for (int k= 0; k < templates.length; k++) {
+                                                       remove(templates[k]);
+                                               }
+                                       }
+                                       add(template);                                  
+                               } else {
+                                       throwReadException(null);
+                               }
+                       }
+               } catch (ParserConfigurationException e) {
+                       throwReadException(e);
+               } catch (IOException e) {
+                       throwReadException(e);
+               } catch (SAXException e) {
+                       throwReadException(e);
+               }
+       }
+       
+       private String translateString(String str, ResourceBundle bundle) {
+               int idx= str.indexOf('%');
+               if (idx == -1) {
+                       return str;
+               }
+               StringBuffer buf= new StringBuffer();
+               int k= 0;
+               while (idx != -1) {
+                       buf.append(str.substring(k, idx));
+                       for (k= idx + 1; k < str.length() && !Character.isWhitespace(str.charAt(k)); k++) {
+                               // loop
+                       }
+                       String key= str.substring(idx + 1, k);
+                       buf.append(getBundleString(key, bundle));
+                       idx= str.indexOf('%', k);
+               }
+               buf.append(str.substring(k));
+               return buf.toString();
+       }
+       
+       private String getBundleString(String key, ResourceBundle bundle) {
+               if (bundle != null) {
+                       try {
+                               return bundle.getString(key);
+                       } catch (MissingResourceException e) {
+                               return '!' + key + '!';
+                       }
+               } else
+                       return JavaTemplateMessages.getString(key); // default messages
+       }
+
+       protected String validateTemplate(Template template) {
+               TemplateContextType type= fRegistry.getContextType(template.getContextTypeId());
+               if (type == null) {
+                       return "Unknown context type: " + template.getContextTypeId(); //$NON-NLS-1$
+               }
+               try {
+                       type.validate(template.getPattern());
+                       return null;
+               } catch (TemplateException e) {
+                       return e.getMessage();
+               }
+       }
+       
+       private String getAttributeValue(NamedNodeMap attributes, String name) {
+               Node node= attributes.getNamedItem(name);
+
+               return node == null
+                       ? null
+                       : node.getNodeValue();
+       }
+
+       /**
+        * Convenience method for saving to a file.
+        * 
+        * @see #saveToStream(OutputStream)
+        */
+       public void saveToFile(File file) throws CoreException {
+               OutputStream stream= null;
+
+               try {
+                       stream= new FileOutputStream(file);
+                       saveToStream(stream);
+
+               } catch (IOException e) {
+                       throwWriteException(e);
+
+               } finally {
+                       try {
+                               if (stream != null)
+                                       stream.close();
+                       } catch (IOException e) {}
+               }
+       }
+               
+       /**
+        * Saves the template set as XML.
+        */
+       public void saveToStream(OutputStream stream) throws CoreException {
+               try {
+                       DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
+                       DocumentBuilder builder= factory.newDocumentBuilder();          
+                       Document document= builder.newDocument();
+
+                       Node root= document.createElement("templates"); //$NON-NLS-1$
+                       document.appendChild(root);
+                       
+                       for (int i= 0; i != fTemplates.size(); i++) {
+                               Template template= (Template) fTemplates.get(i);
+                               
+                               Node node= document.createElement(getTemplateTag());
+                               root.appendChild(node);
+                               
+                               NamedNodeMap attributes= node.getAttributes();
+                               
+                               Attr name= document.createAttribute(NAME_ATTRIBUTE);
+                               name.setValue(template.getName());
+                               attributes.setNamedItem(name);
+       
+                               Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
+                               description.setValue(template.getDescription());
+                               attributes.setNamedItem(description);
+       
+                               Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);
+                               context.setValue(template.getContextTypeId());
+                               attributes.setNamedItem(context);                       
+
+                               Text pattern= document.createTextNode(template.getPattern());
+                               node.appendChild(pattern);                      
+                       }               
+                       
+                       
+                       Transformer transformer=TransformerFactory.newInstance().newTransformer();
+                       transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+                       transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+                       DOMSource source = new DOMSource(document);
+                       StreamResult result = new StreamResult(stream);
+
+                       transformer.transform(source, result);
+
+               } catch (ParserConfigurationException e) {
+                       throwWriteException(e);
+               } catch (TransformerException e) {
+                       throwWriteException(e);
+               }               
+       }
+
+       private static void throwReadException(Throwable t) throws CoreException {
+               int code;
+               if (t instanceof SAXException)
+                       code= TEMPLATE_PARSE_EXCEPTION;
+               else
+                       code= TEMPLATE_IO_EXCEPTION;
+//             IStatus status= JavaUIStatus.createError(code, TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$
+//             throw new JavaUIException(status);
+               throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jface.text", code, JavaTemplateMessages.getString("TemplateSet.error.read"), t)); //$NON-NLS-1$ //$NON-NLS-2$
+       }
+       
+       private static void throwWriteException(Throwable t) throws CoreException {
+//             IStatus status= JavaUIStatus.createError(IJavaStatusConstants.TEMPLATE_IO_EXCEPTION,
+//                     TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$
+//             throw new JavaUIException(status);
+               throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jface.text", TEMPLATE_IO_EXCEPTION, JavaTemplateMessages.getString("TemplateSet.error.write"), t)); //$NON-NLS-1$ //$NON-NLS-2$
+       }
+
+       /**
+        * Adds a template to the set.
+        */
+       public void add(Template template) {
+               if (exists(template))
+                       return; // ignore duplicate
+               
+               fTemplates.add(template);
+       }
+
+       private boolean exists(Template template) {
+               for (Iterator iterator = fTemplates.iterator(); iterator.hasNext();) {
+                       Template anotherTemplate = (Template) iterator.next();
+
+                       if (template.equals(anotherTemplate))
+                               return true;
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Removes a template to the set.
+        */     
+       public void remove(Template template) {
+               fTemplates.remove(template);
+       }
+
+       /**
+        * Empties the set.
+        */             
+       public void clear() {
+               fTemplates.clear();
+       }
+       
+       /**
+        * Returns all templates.
+        */
+       public Template[] getTemplates() {
+               return (Template[]) fTemplates.toArray(new Template[fTemplates.size()]);
+       }
+       
+       /**
+        * Returns all templates with a given name.
+        */
+       public Template[] getTemplates(String name) {
+               ArrayList res= new ArrayList();
+               for (Iterator iterator= fTemplates.iterator(); iterator.hasNext();) {
+                       Template curr= (Template) iterator.next();
+                       if (curr.getName().equals(name)) {
+                               res.add(curr);
+                       }
+               }
+               return (Template[]) res.toArray(new Template[res.size()]);
+       }
+       
+       /**
+        * Returns the first templates with the given name.
+        */
+       public Template getFirstTemplate(String name) {
+               for (Iterator iterator= fTemplates.iterator(); iterator.hasNext();) {
+                       Template curr= (Template) iterator.next();
+                       if (curr.getName().equals(name)) {
+                               return curr;
+                       }
+               }
+               return null;
+       }       
+       
+}
+
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/Templates.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/Templates.java
new file mode 100644 (file)
index 0000000..e316f14
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ResourceBundle;
+
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+
+/**
+ * <code>Templates</code> gives access to the available templates.
+ * 
+ * @deprecated As of 3.0, replaced by {@link org.eclipse.jface.text.templates.persistence.TemplateStore}
+ */
+public class Templates extends net.sourceforge.phpdt.internal.corext.template.php.TemplateSet {
+
+       private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$
+       private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$
+       private static final ResourceBundle fgResourceBundle= ResourceBundle.getBundle(JavaTemplateMessages.class.getName());
+
+       /** Singleton. */
+       private static Templates fgTemplates;
+
+       /**
+        * Returns an instance of templates.
+        * 
+        * @deprecated As of 3.0, replaced by {@link net.sourceforge.phpdt.internal.ui.JavaPlugin#getTemplateStore()}
+        */
+       public static Templates getInstance() {
+               if (fgTemplates == null)
+                       fgTemplates= new Templates();
+               
+               return fgTemplates;
+       }
+       
+       public Templates() {
+               super("template", PHPeclipsePlugin.getDefault().getTemplateContextRegistry()); //$NON-NLS-1$
+               create();
+       }
+       
+
+       private void create() {
+
+               try {
+                       File templateFile= getTemplateFile();
+                       if (templateFile.exists()) {
+                               addFromFile(templateFile, true, fgResourceBundle);
+                       }
+
+               } catch (CoreException e) {
+                 PHPeclipsePlugin.log(e);
+                       clear();
+               }
+
+       }       
+       
+       /**
+        * Resets the template set.
+        */
+       public void reset() throws CoreException {
+               clear();
+               addFromFile(getTemplateFile(), true, fgResourceBundle);
+       }
+
+       /**
+        * Resets the template set with the default templates.
+        */
+       public void restoreDefaults() throws CoreException {
+               clear();
+               addFromStream(getDefaultsAsStream(), true, true, fgResourceBundle);
+       }
+
+       /**
+        * Saves the template set.
+        */
+       public void save() throws CoreException {                                       
+               saveToFile(getTemplateFile());
+       }
+
+       private static InputStream getDefaultsAsStream() {
+               return Templates.class.getResourceAsStream(DEFAULT_FILE);
+       }
+
+       private static File getTemplateFile() {
+               IPath path= PHPeclipsePlugin.getDefault().getStateLocation();
+               path= path.append(TEMPLATE_FILE);
+               
+               return path.toFile();
+       }
+}
+
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/AbortFormatting.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/AbortFormatting.java
new file mode 100644 (file)
index 0000000..c92546d
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 International Business Machines Corp. and others.
+ * 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
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.formatter;
+
+/**
+ * Unchecked exception wrapping invalid input checked exception which may occur
+ * when scanning original formatted source. 
+ * 
+ * @since 2.1
+ */
+public class AbortFormatting extends RuntimeException {
+
+       Throwable nestedException;
+       
+       public AbortFormatting(String message) {
+               super(message);
+       }
+       public AbortFormatting(Throwable nestedException) {
+               super(nestedException.getMessage());
+               this.nestedException = nestedException;
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/OptimizedReplaceEdit.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/OptimizedReplaceEdit.java
new file mode 100644 (file)
index 0000000..f745158
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 International Business Machines Corp. and others.
+ * 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
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.formatter;
+
+class OptimizedReplaceEdit {
+       
+       int offset;
+       int length;
+       String replacement;
+       
+       OptimizedReplaceEdit(int offset, int length, String replacement) {
+               this.offset = offset;
+               this.length = length;
+               this.replacement = replacement;
+       }
+       
+       public String toString() {
+               return "(" + this.offset + ", length " + this.length + " :>" + this.replacement + "<"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+       }
+}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/align/AlignmentException.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/align/AlignmentException.java
new file mode 100644 (file)
index 0000000..5b4b667
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 International Business Machines Corp. and others.
+ * 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
+ ******************************************************************************/
+package net.sourceforge.phpdt.internal.formatter.align;
+
+/**
+ * Exception used to backtrack and break available alignments
+ * When the exception is thrown, it is assumed that some alignment will be changed.
+ *
+ * @since 2.1
+ */
+public class AlignmentException extends RuntimeException {
+       
+       public static final int LINE_TOO_LONG = 1;
+       public static final int ALIGN_TOO_SMALL = 2;
+       
+       int reason;
+       int value;
+       public int relativeDepth;
+       
+       public AlignmentException(int reason, int relativeDepth) {
+               this(reason, 0, relativeDepth);
+       }
+
+       public AlignmentException(int reason, int value, int relativeDepth) {
+               this.reason = reason;
+               this.value = value;
+               this.relativeDepth = relativeDepth;
+       }
+       
+       public String toString(){
+               StringBuffer buffer = new StringBuffer(10);
+               switch(this.reason){
+                       case LINE_TOO_LONG :
+                               buffer.append("LINE_TOO_LONG"); //$NON-NLS-1$
+                               break;
+                       case ALIGN_TOO_SMALL :
+                               buffer.append("ALIGN_TOO_SMALL");       //$NON-NLS-1$
+                               break;
+               }
+               buffer
+                       .append("<relativeDepth: ")     //$NON-NLS-1$
+                       .append(this.relativeDepth)
+                       .append(">\n"); //$NON-NLS-1$
+               return buffer.toString();
+       }
+}
index 7a33214..cbd80ba 100644 (file)
@@ -1,7 +1,13 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.ui.preferences;
 
 import java.util.ArrayList;
@@ -9,23 +15,19 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
 import net.sourceforge.phpdt.internal.ui.dialogs.StatusDialog;
 import net.sourceforge.phpdt.internal.ui.dialogs.StatusInfo;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateVariableProcessor;
+import net.sourceforge.phpdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
 import net.sourceforge.phpdt.internal.ui.util.SWTUtil;
+import net.sourceforge.phpdt.ui.IContextMenuConstants;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpdt.ui.text.JavaTextTools;
-import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
-import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
 
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.GroupMarker;
 import org.eclipse.jface.action.IAction;
@@ -34,47 +36,44 @@ import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.text.Document;
 import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
 import org.eclipse.jface.text.ITextListener;
 import org.eclipse.jface.text.ITextOperationTarget;
 import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
 import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.help.WorkbenchHelp;
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.IUpdate;
 
@@ -83,81 +82,17 @@ import org.eclipse.ui.texteditor.IUpdate;
  */
 public class EditTemplateDialog extends StatusDialog {
 
-       private static class SimpleJavaSourceViewerConfiguration extends PHPSourceViewerConfiguration {
-
-               private final IContentAssistProcessor fProcessor;
-
-       //      SimpleJavaSourceViewerConfiguration(JavaTextTools tools, ITextEditor editor, IContentAssistProcessor processor) {
-               SimpleJavaSourceViewerConfiguration(JavaTextTools tools, IContentAssistProcessor processor) {   
-      super(tools, null, IPHPPartitions.PHP_PARTITIONING);
-                       fProcessor= processor;
-               }
-               
-               /*
-                * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
-                */
-               public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
-
-                       IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
-
-                       ContentAssistant assistant= new ContentAssistant();
-                       assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
-                               // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
-//                     assistant.setContentAssistProcessor(fProcessor, JavaPartitionScanner.PHP_STRING);
-//                     assistant.setContentAssistProcessor(fProcessor, JavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT);
-//                     
-//                     assistant.setContentAssistProcessor(fProcessor, JavaPartitionScanner.JAVA_DOC);
-
-//                     assistant.enableAutoInsert(store.getBoolean(ContentAssistPreference.AUTOINSERT));
-//                     assistant.enableAutoActivation(store.getBoolean(ContentAssistPreference.AUTOACTIVATION));
-//                     assistant.setAutoActivationDelay(store.getInt(ContentAssistPreference.AUTOACTIVATION_DELAY));
-                       assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
-                       assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
-//                     assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
-
-                       Display display= sourceViewer.getTextWidget().getDisplay();
-                       
-                       Color background= createColor(store, IPreferenceConstants.PROPOSALS_BACKGROUND, display);                       
-                       assistant.setContextInformationPopupBackground(background);
-                       assistant.setContextSelectorBackground(background);
-                       assistant.setProposalSelectorBackground(background);
-
-                       Color foreground= createColor(store, IPreferenceConstants.PROPOSALS_FOREGROUND, display);
-                       assistant.setContextInformationPopupForeground(foreground);
-                       assistant.setContextSelectorForeground(foreground);
-                       assistant.setProposalSelectorForeground(foreground);
-                       
-                       return assistant;
-               }       
-
-               /**
-                * Creates a color from the information stored in the given preference store.
-                * Returns <code>null</code> if there is no such information available.
-                */
-               private Color createColor(IPreferenceStore store, String key, Display display) {
-               
-                       RGB rgb= null;          
-                       
-                       if (store.contains(key)) {
-                               
-                               if (store.isDefault(key))
-                                       rgb= PreferenceConverter.getDefaultColor(store, key);
-                               else
-                                       rgb= PreferenceConverter.getColor(store, key);
-                       
-                               if (rgb != null)
-                                       return new Color(display, rgb);
-                       }
-                       
-                       return null;
-               }       
-       }
-
        private static class TextViewerAction extends Action implements IUpdate {
        
                private int fOperationCode= -1;
                private ITextOperationTarget fOperationTarget;
        
+               /** 
+                * Creates a new action.
+                * 
+                * @param viewer the viewer
+                * @param operationCode the opcode
+                */
                public TextViewerAction(ITextViewer viewer, int operationCode) {
                        fOperationCode= operationCode;
                        fOperationTarget= viewer.getTextOperationTarget();
@@ -198,33 +133,73 @@ public class EditTemplateDialog extends StatusDialog {
        private Combo fContextCombo;
        private SourceViewer fPatternEditor;    
        private Button fInsertVariableButton;
+       private boolean fIsNameModifiable;
 
-       private TemplateTranslator fTranslator= new TemplateTranslator();       
+       private StatusInfo fValidationStatus;
        private boolean fSuppressError= true; // #4354  
        private Map fGlobalActions= new HashMap(10);
        private List fSelectionActions = new ArrayList(3);      
-       private Vector fContextTypes= new Vector();
+       private String[][] fContextTypes;
        
-       private final TemplateVariableProcessor fProcessor= new TemplateVariableProcessor();
+       private ContextTypeRegistry fContextTypeRegistry; 
+       
+       private final TemplateVariableProcessor fTemplateProcessor= new TemplateVariableProcessor();
                
-       public EditTemplateDialog(Shell parent, Template template, boolean edit) {
+       /**
+        * Creates a new dialog.
+        * 
+        * @param parent the shell parent of the dialog
+        * @param template the template to edit
+        * @param edit whether this is a new template or an existing being edited
+        * @param isNameModifiable whether the name of the template may be modified
+        * @param registry the context type registry to use
+        */
+       public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) {
                super(parent);
                
                setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE);
                
                String title= edit
-                       ? TemplateMessages.getString("EditTemplateDialog.title.edit") //$NON-NLS-1$
-                       : TemplateMessages.getString("EditTemplateDialog.title.new"); //$NON-NLS-1$
+                       ? PreferencesMessages.getString("EditTemplateDialog.title.edit") //$NON-NLS-1$
+                       : PreferencesMessages.getString("EditTemplateDialog.title.new"); //$NON-NLS-1$
                setTitle(title);
 
                fTemplate= template;
+               fIsNameModifiable= isNameModifiable;
                
-               ContextTypeRegistry registry= ContextTypeRegistry.getInstance();
-               for (Iterator iterator= registry.iterator(); iterator.hasNext(); )
-                       fContextTypes.add(iterator.next());
-
-               if (fContextTypes.size() > 0)
-                       fProcessor.setContextType(ContextTypeRegistry.getInstance().getContextType((String) fContextTypes.get(0)));
+               // XXX workaround for bug 63313 - disabling prefix until fixed.
+//             String delim= new Document().getLegalLineDelimiters()[0];
+               
+               List contexts= new ArrayList();
+               for (Iterator it= registry.contextTypes(); it.hasNext();) {
+                       TemplateContextType type= (TemplateContextType) it.next();
+//                     if (type.getId().equals("javadoc")) //$NON-NLS-1$
+//                             contexts.add(new String[] { type.getId(), type.getName(), "/**" + delim }); //$NON-NLS-1$
+//                     else
+                               contexts.add(new String[] { type.getId(), type.getName(), "" }); //$NON-NLS-1$
+               }
+               fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]);
+                               
+               fValidationStatus= new StatusInfo();
+               
+               fContextTypeRegistry= registry;
+               
+               TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
+               fTemplateProcessor.setContextType(type);
+       }
+       
+       /*
+        * @see net.sourceforge.phpdt.internal.ui.dialogs.StatusDialog#create()
+        */
+       public void create() {
+               super.create();
+               // update initial ok button to be disabled for new templates 
+               boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
+               if (!valid) {
+                       StatusInfo status = new StatusInfo();
+                       status.setError(PreferencesMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$
+                       updateButtonsEnableState(status);
+               }
        }
        
        /*
@@ -237,50 +212,63 @@ public class EditTemplateDialog extends StatusDialog {
                parent.setLayout(layout);
                parent.setLayoutData(new GridData(GridData.FILL_BOTH));
                
-               createLabel(parent, TemplateMessages.getString("EditTemplateDialog.name")); //$NON-NLS-1$       
-               
-               Composite composite= new Composite(parent, SWT.NONE);
-               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-               layout= new GridLayout();               
-               layout.numColumns= 3;
-               layout.marginWidth= 0;
-               layout.marginHeight= 0;
-               composite.setLayout(layout);
-
-               fNameText= createText(composite);
-               fNameText.addModifyListener(new ModifyListener() {
+               ModifyListener listener= new ModifyListener() {
                        public void modifyText(ModifyEvent e) {
-                               if (fSuppressError && (fNameText.getText().trim().length() != 0))
-                                       fSuppressError= false;
-
-                               updateButtons();
+                               doTextWidgetChanged(e.widget);
                        }
-               });
-
-               createLabel(composite, TemplateMessages.getString("EditTemplateDialog.context")); //$NON-NLS-1$         
-               fContextCombo= new Combo(composite, SWT.READ_ONLY);
-
-               for (Iterator iterator= fContextTypes.iterator(); iterator.hasNext(); )
-                       fContextCombo.add((String) iterator.next());
-
-               fContextCombo.addModifyListener(new ModifyListener() {
-                       public void modifyText(ModifyEvent e) {
-                               String name= fContextCombo.getText();
-                               fProcessor.setContextType(ContextTypeRegistry.getInstance().getContextType(name));                              
+               };
+               
+               if (fIsNameModifiable) {
+                       createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.name")); //$NON-NLS-1$    
+                       
+                       Composite composite= new Composite(parent, SWT.NONE);
+                       composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+                       layout= new GridLayout();               
+                       layout.numColumns= 3;
+                       layout.marginWidth= 0;
+                       layout.marginHeight= 0;
+                       composite.setLayout(layout);
+                       
+                       fNameText= createText(composite);
+                       fNameText.addFocusListener(new FocusListener() {
+                               
+                               public void focusGained(FocusEvent e) {
+                               }
+                               
+                               public void focusLost(FocusEvent e) {
+                                       if (fSuppressError) {
+                                               fSuppressError= false;
+                                               updateButtons();
+                                       }
+                               }
+                       });
+                       
+                       createLabel(composite, PreferencesMessages.getString("EditTemplateDialog.context")); //$NON-NLS-1$              
+                       fContextCombo= new Combo(composite, SWT.READ_ONLY);
+       
+                       for (int i= 0; i < fContextTypes.length; i++) {
+                               fContextCombo.add(fContextTypes[i][1]);
                        }
-               });
+       
+                       fContextCombo.addModifyListener(listener);
+               }
+               
+               createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.description")); //$NON-NLS-1$             
+               
+               int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
+               fDescriptionText= new Text(parent, descFlags );
+               fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 
                
-               createLabel(parent, TemplateMessages.getString("EditTemplateDialog.description")); //$NON-NLS-1$                
-               fDescriptionText= createText(parent);
+               fDescriptionText.addModifyListener(listener);
 
-               Label patternLabel= createLabel(parent, TemplateMessages.getString("EditTemplateDialog.pattern")); //$NON-NLS-1$
+               Label patternLabel= createLabel(parent, PreferencesMessages.getString("EditTemplateDialog.pattern")); //$NON-NLS-1$
                patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
                fPatternEditor= createEditor(parent);
                
                Label filler= new Label(parent, SWT.NONE);              
                filler.setLayoutData(new GridData());
                
-               composite= new Composite(parent, SWT.NONE);
+               Composite composite= new Composite(parent, SWT.NONE);
                layout= new GridLayout();               
                layout.marginWidth= 0;
                layout.marginHeight= 0;
@@ -289,7 +277,7 @@ public class EditTemplateDialog extends StatusDialog {
                
                fInsertVariableButton= new Button(composite, SWT.NONE);
                fInsertVariableButton.setLayoutData(getButtonGridData(fInsertVariableButton));
-               fInsertVariableButton.setText(TemplateMessages.getString("EditTemplateDialog.insert.variable")); //$NON-NLS-1$
+               fInsertVariableButton.setText(PreferencesMessages.getString("EditTemplateDialog.insert.variable")); //$NON-NLS-1$
                fInsertVariableButton.addSelectionListener(new SelectionListener() {
                        public void widgetSelected(SelectionEvent e) {
                                fPatternEditor.getTextWidget().setFocus();
@@ -299,18 +287,70 @@ public class EditTemplateDialog extends StatusDialog {
                        public void widgetDefaultSelected(SelectionEvent e) {}
                });
 
-               fNameText.setText(fTemplate.getName());
                fDescriptionText.setText(fTemplate.getDescription());
-               fContextCombo.select(getIndex(fTemplate.getContextTypeName()));
-
+               if (fIsNameModifiable) {
+                       fNameText.setText(fTemplate.getName());
+                       fNameText.addModifyListener(listener);
+                       fContextCombo.select(getIndex(fTemplate.getContextTypeId()));
+               } else {
+                       fPatternEditor.getControl().setFocus();
+               }
                initializeActions();
 
+               applyDialogFont(parent);
                return composite;
        }
+       
+       protected void doTextWidgetChanged(Widget w) {
+               if (w == fNameText) {
+                       fSuppressError= false;
+                       String name= fNameText.getText();
+                       fTemplate.setName(name);
+                       updateButtons();                        
+               } else if (w == fContextCombo) {
+                       String name= fContextCombo.getText();
+                       String contextId= getContextId(name);
+                       fTemplate.setContextTypeId(contextId);
+                       fTemplateProcessor.setContextType(fContextTypeRegistry.getContextType(contextId));
+               } else if (w == fDescriptionText) {
+                       String desc= fDescriptionText.getText();
+                       fTemplate.setDescription(desc);
+               }       
+       }
+       
+       private String getContextId(String name) {
+               if (name == null)
+                       return name;
+               
+               for (int i= 0; i < fContextTypes.length; i++) {
+                       if (name.equals(fContextTypes[i][1])) {
+                               return fContextTypes[i][0];     
+                       }
+               }
+               return name;
+       }
+
+       protected void doSourceChanged(IDocument document) {
+               String text= document.get();
+               String prefix= getPrefix();
+               fTemplate.setPattern(text.substring(prefix.length(), text.length()));
+               fValidationStatus.setOK();
+               TemplateContextType contextType= fContextTypeRegistry.getContextType(fTemplate.getContextTypeId());
+               if (contextType != null) {
+                       try {
+                               contextType.validate(text);
+                       } catch (TemplateException e) {
+                               fValidationStatus.setError(e.getLocalizedMessage());
+                       }
+               }
+
+               updateUndoAction();
+               updateButtons();
+       }       
 
        private static GridData getButtonGridData(Button button) {
                GridData data= new GridData(GridData.FILL_HORIZONTAL);
-               data.heightHint= SWTUtil.getButtonHeigthHint(button);
+               data.heightHint= SWTUtil.getButtonHeightHint(button);
        
                return data;
        }
@@ -331,36 +371,40 @@ public class EditTemplateDialog extends StatusDialog {
        }
 
        private SourceViewer createEditor(Composite parent) {
-               SourceViewer viewer= new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
-         JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
-               IDocument document= new Document(fTemplate.getPattern());
-               IDocumentPartitioner partitioner= tools.createDocumentPartitioner();
-               document.setDocumentPartitioner(partitioner);
-               partitioner.connect(document);          
-       //      viewer.configure(new SimpleJavaSourceViewerConfiguration(tools, null, fProcessor));
-               viewer.configure(new SimpleJavaSourceViewerConfiguration(tools, fProcessor));
-    viewer.setEditable(true);
+               String prefix= getPrefix();
+               IDocument document= new Document(prefix + fTemplate.getPattern());
+               JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+               tools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
+               IPreferenceStore store= PHPeclipsePlugin.getDefault().getCombinedPreferenceStore();
+               SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+               TemplateEditorSourceViewerConfiguration configuration= new TemplateEditorSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               viewer.configure(configuration);
+               viewer.setEditable(true);
+               // XXX workaround for bug 63313 - disabling prefix until fixed.
+//             viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length());
                viewer.setDocument(document);
                
-               Font font= JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
                viewer.getTextWidget().setFont(font);
+               new JavaSourcePreviewerUpdater(viewer, configuration, store);
                
+               int nLines= document.getNumberOfLines();
+               if (nLines < 5) {
+                       nLines= 5;
+               } else if (nLines > 12) {
+                       nLines= 12;     
+               }
+                               
                Control control= viewer.getControl();
                GridData data= new GridData(GridData.FILL_BOTH);
-               data.widthHint= convertWidthInCharsToPixels(60);
-               data.heightHint= convertHeightInCharsToPixels(5);
+               data.widthHint= convertWidthInCharsToPixels(80);
+               data.heightHint= convertHeightInCharsToPixels(nLines);
                control.setLayoutData(data);
                
                viewer.addTextListener(new ITextListener() {
                        public void textChanged(TextEvent event) {
-                           try {
-                                       fTranslator.translate(event.getDocumentEvent().getDocument().get());
-                           } catch (CoreException e) {
-                               PHPeclipsePlugin.log(e);
-                           }
-                               
-                               updateUndoAction();
-                               updateButtons();
+                               if (event .getDocumentEvent() != null)
+                                       doSourceChanged(event.getDocumentEvent().getDocument());
                        }
                });
 
@@ -370,46 +414,31 @@ public class EditTemplateDialog extends StatusDialog {
                        }
                });
 
-               if (viewer instanceof ITextViewerExtension) {
-                        ((ITextViewerExtension) viewer).prependVerifyKeyListener(new VerifyKeyListener() {
-                               public void verifyKey(VerifyEvent event) {
-                                       handleVerifyKeyPressed(event);
-                               }
-                       });
-               } else {                        
-                       viewer.getTextWidget().addKeyListener(new KeyListener() {
-                               public void keyPressed(KeyEvent e) {
-                                       handleKeyPressed(e);
-                               }
-       
-                               public void keyReleased(KeyEvent e) {}
-                       });
-               }
+               viewer.prependVerifyKeyListener(new VerifyKeyListener() {
+                       public void verifyKey(VerifyEvent event) {
+                               handleVerifyKeyPressed(event);
+                       }
+               });
                
                return viewer;
        }
-
-       private void handleKeyPressed(KeyEvent event) {
-               if (event.stateMask != SWT.CTRL)
-                       return;
-                       
-               switch (event.character) {
-                       case ' ':
-                               fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
-                               break;
-
-                       // CTRL-Z
-                       case (int) 'z' - (int) 'a' + 1:
-                               fPatternEditor.doOperation(ITextOperationTarget.UNDO);
-                               break;                          
-               }
+       
+       private String getPrefix() {
+               String prefix;
+               int idx= getIndex(fTemplate.getContextTypeId());
+               if (idx != -1)
+                       prefix= fContextTypes[idx][2];
+               else
+                       prefix= ""; //$NON-NLS-1$
+
+               return prefix;
        }
 
        private void handleVerifyKeyPressed(VerifyEvent event) {
                if (!event.doit)
                        return;
 
-               if (event.stateMask != SWT.CTRL)
+               if (event.stateMask != SWT.MOD1)
                        return;
                        
                switch (event.character) {
@@ -419,7 +448,7 @@ public class EditTemplateDialog extends StatusDialog {
                                break;
 
                        // CTRL-Z
-                       case (int) 'z' - (int) 'a' + 1:
+                       case 'z' - 'a' + 1:
                                fPatternEditor.doOperation(ITextOperationTarget.UNDO);
                                event.doit= false;
                                break;                          
@@ -428,27 +457,27 @@ public class EditTemplateDialog extends StatusDialog {
 
        private void initializeActions() {
                TextViewerAction action= new TextViewerAction(fPatternEditor, SourceViewer.UNDO);
-               action.setText(TemplateMessages.getString("EditTemplateDialog.undo")); //$NON-NLS-1$
+               action.setText(PreferencesMessages.getString("EditTemplateDialog.undo")); //$NON-NLS-1$
                fGlobalActions.put(ITextEditorActionConstants.UNDO, action);
 
                action= new TextViewerAction(fPatternEditor, SourceViewer.CUT);
-               action.setText(TemplateMessages.getString("EditTemplateDialog.cut")); //$NON-NLS-1$
+               action.setText(PreferencesMessages.getString("EditTemplateDialog.cut")); //$NON-NLS-1$
                fGlobalActions.put(ITextEditorActionConstants.CUT, action);
 
                action= new TextViewerAction(fPatternEditor, SourceViewer.COPY);
-               action.setText(TemplateMessages.getString("EditTemplateDialog.copy")); //$NON-NLS-1$
+               action.setText(PreferencesMessages.getString("EditTemplateDialog.copy")); //$NON-NLS-1$
                fGlobalActions.put(ITextEditorActionConstants.COPY, action);
 
                action= new TextViewerAction(fPatternEditor, SourceViewer.PASTE);
-               action.setText(TemplateMessages.getString("EditTemplateDialog.paste")); //$NON-NLS-1$
+               action.setText(PreferencesMessages.getString("EditTemplateDialog.paste")); //$NON-NLS-1$
                fGlobalActions.put(ITextEditorActionConstants.PASTE, action);
 
                action= new TextViewerAction(fPatternEditor, SourceViewer.SELECT_ALL);
-               action.setText(TemplateMessages.getString("EditTemplateDialog.select.all")); //$NON-NLS-1$
+               action.setText(PreferencesMessages.getString("EditTemplateDialog.select.all")); //$NON-NLS-1$
                fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);
 
                action= new TextViewerAction(fPatternEditor, SourceViewer.CONTENTASSIST_PROPOSALS);
-               action.setText(TemplateMessages.getString("EditTemplateDialog.content.assist")); //$NON-NLS-1$
+               action.setText(PreferencesMessages.getString("EditTemplateDialog.content.assist")); //$NON-NLS-1$
                fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$
 
                fSelectionActions.add(ITextEditorActionConstants.CUT);
@@ -479,8 +508,8 @@ public class EditTemplateDialog extends StatusDialog {
                menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.PASTE));
                menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
 
-       //      menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
-       //      menu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, (IAction) fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$
+               menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+               menu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, (IAction) fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$
        }
 
        protected void updateSelectionDependentActions() {
@@ -501,39 +530,35 @@ public class EditTemplateDialog extends StatusDialog {
                        ((IUpdate) action).update();
        }
 
-       private int getIndex(String context) {
-               ContextTypeRegistry registry= ContextTypeRegistry.getInstance();
-               registry.getContextType(context);
+       private int getIndex(String contextid) {
                
-               if (context == null)
+               if (contextid == null)
                        return -1;
-                       
-               return fContextTypes.indexOf(context);
+               
+               for (int i= 0; i < fContextTypes.length; i++) {
+                       if (contextid.equals(fContextTypes[i][0])) {
+                               return i;       
+                       }
+               }
+               return -1;
        }
        
        protected void okPressed() {
-               fTemplate.setName(fNameText.getText());
-               fTemplate.setDescription(fDescriptionText.getText());
-               fTemplate.setContext(fContextCombo.getText());
-               fTemplate.setPattern(fPatternEditor.getTextWidget().getText());
-               
                super.okPressed();
        }
        
        private void updateButtons() {          
-               boolean valid= fNameText.getText().trim().length() != 0;
+               StatusInfo status;
 
-               StatusInfo status= new StatusInfo();
-               
+               boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
                if (!valid) {
-                       if (fSuppressError)
-                               status.setError(""); //$NON-NLS-1$                                                      
-                       else
-                               status.setError(TemplateMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$
-               } else if (fTranslator.getErrorMessage() != null) {
-                       status.setError(fTranslator.getErrorMessage()); 
-               }
-
+                       status = new StatusInfo();
+                       if (!fSuppressError) {
+                               status.setError(PreferencesMessages.getString("EditTemplateDialog.error.noname")); //$NON-NLS-1$
+                       }
+               } else {
+                       status= fValidationStatus; 
+               }
                updateStatus(status);
        }
 
@@ -542,8 +567,8 @@ public class EditTemplateDialog extends StatusDialog {
         */
        protected void configureShell(Shell newShell) {
                super.configureShell(newShell);
-//             WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.EDIT_TEMPLATE_DIALOG);
+               WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.EDIT_TEMPLATE_DIALOG);
        }
 
 
-}
\ No newline at end of file
+}
index 261ba23..89a22b3 100644 (file)
@@ -54,6 +54,7 @@ import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.RGB;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -91,70 +92,38 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
   public final OverlayPreferenceStore.OverlayKey[] fKeys;
 
   private final String[][] fSyntaxColorListModel = new String[][] {
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
-      // PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
-      // PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$
-      //               { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"),
-      // PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$
-      //               { PreferencesMessages.getString("JavaEditorPreferencePage.strings"),
-      // PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"),
-      // PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$
-      //               { PreferencesMessages.getString("JavaEditorPreferencePage.operators"),
-      // PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$
-      //               { PreferencesMessages.getString("JavaEditorPreferencePage.others"),
-      // PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"),
-      // PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"),
-      // PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"),
-      // PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"),
-      // PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$
-      //               {
-      // PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"),
-      // PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.multiLineComment"),
+      { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"),
           PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.singleLineComment"),
+      { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"),
           PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.tags"), PreferenceConstants.EDITOR_PHP_TAG_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
-      { PreferencesMessages.getString("PHPEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.functionNames"), PreferenceConstants.EDITOR_PHP_FUNCTIONNAME_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.variables"), PreferenceConstants.EDITOR_PHP_VARIABLE_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.constants"), PreferenceConstants.EDITOR_PHP_CONSTANT_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.types"), PreferenceConstants.EDITOR_PHP_TYPE_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
+      { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$
       { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_PHP_OPERATOR_COLOR },
       //$NON-NLS-1$
       { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"),
           PreferenceConstants.EDITOR_PHP_KEYWORD_RETURN_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
+      { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR },
       //$NON-NLS-1$
-      { PreferencesMessages.getString("PHPEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
+      { PreferencesMessages.getString("JavaEditorPreferencePage.phpDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$
   };
 
   private final String[][] fAppearanceColorListModel = new String[][] {
@@ -728,16 +697,17 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
         new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
 
     fPreviewViewer = new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
-
-    fPreviewViewer.configure(new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING));
-    //         Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
-    //         fPreviewViewer.getTextWidget().setFont(font);
-    fPreviewViewer.getTextWidget().setFont(JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT));
-    //         new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
-    fPreviewViewer.setEditable(false);
+    JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+       PHPSourceViewerConfiguration configuration= new PHPSourceViewerConfiguration(tools.getColorManager(), store, null, IPHPPartitions.PHP_PARTITIONING);
+//    PHPSourceViewerConfiguration configuration =new PHPSourceViewerConfiguration(fJavaTextTools, null, IPHPPartitions.PHP_PARTITIONING);
+    fPreviewViewer.configure(configuration);
+     
+    Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+       fPreviewViewer.getTextWidget().setFont(font);
+    new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);
+       fPreviewViewer.setEditable(false);
     String content = loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
     IDocument document = new Document(content);
-    //    fJavaTextTools.setupJavaDocumentPartitioner(document, ".php", null); //IJavaPartitions.JAVA_PARTITIONING);
     fJavaTextTools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
     fPreviewViewer.setDocument(document);
     return fPreviewViewer.getControl();
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaSourcePreviewerUpdater.java
new file mode 100644 (file)
index 0000000..c462288
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Font;
+//import net.sourceforge.phpdt.ui.text.JavaSourceViewerConfiguration;
+
+/**
+ * Handles Java editor font changes for Java source preview viewers.
+ * 
+ * @since 3.0
+ */
+class JavaSourcePreviewerUpdater {
+       
+       /**
+        * Creates a Java source preview updater for the given viewer, configuration and preference store.
+        *
+        * @param viewer the viewer
+        * @param configuration the configuration
+        * @param preferenceStore the preference store
+        */
+       JavaSourcePreviewerUpdater(final SourceViewer viewer, final PHPSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) {
+               Assert.isNotNull(viewer);
+               Assert.isNotNull(configuration);
+               Assert.isNotNull(preferenceStore);
+               final IPropertyChangeListener fontChangeListener= new IPropertyChangeListener() {
+                       /*
+                        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+                        */
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
+                                       Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+                                       viewer.getTextWidget().setFont(font);
+                               }
+                       }
+               };
+               final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
+                       /*
+                        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+                        */
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (configuration.affectsTextPresentation(event)) {
+                                       configuration.handlePropertyChangeEvent(event);
+                                       viewer.invalidateTextPresentation();
+                               }
+                       }
+               };
+               viewer.getTextWidget().addDisposeListener(new DisposeListener() {
+                       /*
+                        * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+                        */
+                       public void widgetDisposed(DisposeEvent e) {
+                               preferenceStore.removePropertyChangeListener(propertyChangeListener);
+                               JFaceResources.getFontRegistry().removeListener(fontChangeListener);
+                       }
+               });
+               JFaceResources.getFontRegistry().addListener(fontChangeListener);
+               preferenceStore.addPropertyChangeListener(propertyChangeListener);
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaTemplatePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/JavaTemplatePreferencePage.java
new file mode 100644 (file)
index 0000000..3ad0e25
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import net.sourceforge.phpdt.internal.ui.IJavaHelpContextIds;
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
+import net.sourceforge.phpdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.JavaSourceViewer;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.help.WorkbenchHelp;
+import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
+
+public class JavaTemplatePreferencePage extends TemplatePreferencePage implements IWorkbenchPreferencePage {
+
+       private TemplateVariableProcessor fTemplateProcessor;
+       
+       public JavaTemplatePreferencePage() {
+               setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
+               setTemplateStore(PHPeclipsePlugin.getDefault().getTemplateStore());
+               setContextTypeRegistry(PHPeclipsePlugin.getDefault().getTemplateContextRegistry());
+               fTemplateProcessor= new TemplateVariableProcessor();
+       }
+       
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
+       }
+
+
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       public boolean performOk() {
+               boolean ok= super.performOk();
+
+               PHPeclipsePlugin.getDefault().savePluginPreferences();
+               
+               return ok;
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#getFormatterPreferenceKey()
+        */
+       protected String getFormatterPreferenceKey() {
+               return PreferenceConstants.TEMPLATES_USE_CODEFORMATTER;
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createTemplateEditDialog(org.eclipse.jface.text.templates.Template, boolean, boolean)
+        */
+       protected Dialog createTemplateEditDialog(Template template, boolean edit, boolean isNameModifiable) {
+               return new EditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry());
+       }
+       
+       
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite)
+        */
+       protected SourceViewer createViewer(Composite parent) {
+               Label label= new Label(parent, SWT.NONE);
+               label.setText(PreferencesMessages.getString("CodeTemplateBlock.preview")); //$NON-NLS-1$
+               GridData data= new GridData();
+               label.setLayoutData(data);
+               
+               IDocument document= new Document();
+               JavaTextTools tools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+               tools.setupJavaDocumentPartitioner(document, IPHPPartitions.PHP_PARTITIONING);
+               IPreferenceStore store= PHPeclipsePlugin.getDefault().getCombinedPreferenceStore();
+               SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+               TemplateEditorSourceViewerConfiguration configuration= new TemplateEditorSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               viewer.configure(configuration);
+               viewer.setEditable(false);
+               viewer.setDocument(document);
+       
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               viewer.getTextWidget().setFont(font);
+               new JavaSourcePreviewerUpdater(viewer, configuration, store);
+               
+               Control control= viewer.getControl();
+               data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+               control.setLayoutData(data);
+               
+               return viewer;
+       }
+       
+       
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#updateViewerInput()
+        */
+       protected void updateViewerInput() {
+               IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();
+               SourceViewer viewer= getViewer();
+               
+               if (selection.size() == 1 && selection.getFirstElement() instanceof TemplatePersistenceData) {
+                       TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
+                       Template template= data.getTemplate();
+                       String contextId= template.getContextTypeId();
+                       TemplateContextType type= PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(contextId);
+                       fTemplateProcessor.setContextType(type);
+                       
+                       IDocument doc= viewer.getDocument();
+                       
+                       String start= null;
+                       if ("javadoc".equals(contextId)) { //$NON-NLS-1$
+                               start= "/**" + doc.getLegalLineDelimiters()[0]; //$NON-NLS-1$
+                       } else
+                               start= ""; //$NON-NLS-1$
+                       
+                       doc.set(start + template.getPattern());
+                       int startLen= start.length();
+                       viewer.setDocument(doc, startLen, doc.getLength() - startLen);
+
+               } else {
+                       viewer.getDocument().set(""); //$NON-NLS-1$
+               }               
+       }
+}
index 15ce377..4997e09 100644 (file)
@@ -96,19 +96,25 @@ TextEditorPreferencePage.annotations.highlightInText= &Highlight in text
 JavaEditorPreferencePage.annotations.showInOverviewRuler= Show in overview &ruler
 JavaEditorPreferencePage.annotations.showInVerticalRuler= Show in vertical r&uler
 JavaEditorPreferencePage.annotations.color= C&olor:
+JavaEditorPreferencePage.tags=PHP tags
 JavaEditorPreferencePage.multiLineComment=Multi-line comment
 JavaEditorPreferencePage.singleLineComment=Single-line comment
 JavaEditorPreferencePage.returnKeyword= Keyword 'return'
 JavaEditorPreferencePage.keywords=Keywords excluding 'return'
+JavaEditorPreferencePage.functionNames=Predefined function names 
+JavaEditorPreferencePage.variables=Variables
+JavaEditorPreferencePage.constants=Constants
+JavaEditorPreferencePage.types=Types
 JavaEditorPreferencePage.strings=Strings
 JavaEditorPreferencePage.others=Others
 JavaEditorPreferencePage.methodNames=Method names
 JavaEditorPreferencePage.operators=Operators and brackets
 JavaEditorPreferencePage.javaCommentTaskTags=Task Tags
-JavaEditorPreferencePage.javaDocKeywords=PHPdoc keywords
-JavaEditorPreferencePage.javaDocHtmlTags=PHPdoc HTML tags
-JavaEditorPreferencePage.javaDocLinks=PHPdoc links
-JavaEditorPreferencePage.javaDocOthers=PHPdoc others
+JavaEditorPreferencePage.phpDocKeywords=PHPDoc keywords
+JavaEditorPreferencePage.phpDocHtmlTags=PHPDoc HTML tags
+JavaEditorPreferencePage.phpDocLinks=PHPDoc links
+JavaEditorPreferencePage.phpDocOthers=PHPDoc others
+
 JavaEditorPreferencePage.backgroundColor=Background color
 JavaEditorPreferencePage.systemDefault=S&ystem Default
 JavaEditorPreferencePage.custom=C&ustom:
@@ -679,21 +685,23 @@ JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE=Underline
 JavaEditorPreferencePage.AnnotationDecoration.BOX=Box
 JavaEditorPreferencePage.AnnotationDecoration.IBEAM=IBeam
 
-
-PHPEditorPreferencePage.multiLineComment=Multi-line comment
-PHPEditorPreferencePage.singleLineComment=Single-line comment
-PHPEditorPreferencePage.tags=PHP/Smarty tags
-PHPEditorPreferencePage.keywords=Keywords
-PHPEditorPreferencePage.functionNames=Predefined function names 
-PHPEditorPreferencePage.variables=Variables
-PHPEditorPreferencePage.constants=Constants
-PHPEditorPreferencePage.types=Types
-PHPEditorPreferencePage.strings=Strings
-PHPEditorPreferencePage.others=Others
-PHPEditorPreferencePage.phpDocKeywords=PHPDoc keywords
-PHPEditorPreferencePage.phpDocHtmlTags=PHPDoc HTML tags
-PHPEditorPreferencePage.phpDocLinks=PHPDoc links
-PHPEditorPreferencePage.phpDocOthers=PHPDoc others
+# edit template dialog
+EditTemplateDialog.error.noname=Template name cannot be empty.
+EditTemplateDialog.title.new=New Template
+EditTemplateDialog.title.edit=Edit Template
+
+EditTemplateDialog.name=&Name:
+EditTemplateDialog.description=&Description:
+EditTemplateDialog.context=&Context:
+EditTemplateDialog.pattern=&Pattern:
+EditTemplateDialog.insert.variable=Insert &Variable...
+
+EditTemplateDialog.undo=&Undo
+EditTemplateDialog.cut=Cu&t
+EditTemplateDialog.copy=&Copy
+EditTemplateDialog.paste=&Paste
+EditTemplateDialog.select.all=Select &All
+EditTemplateDialog.content.assist=Insert &Variable...
 
 JavaEditorPreferencePage.folding.title= &Folding
 
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplateEditorSourceViewerConfiguration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplateEditorSourceViewerConfiguration.java
new file mode 100644 (file)
index 0000000..129292b
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.preferences;
+
+import java.util.Iterator;
+
+import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
+import net.sourceforge.phpdt.internal.ui.text.JavaWordFinder;
+import net.sourceforge.phpdt.internal.ui.text.template.preferences.TemplateVariableProcessor;
+import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpdt.ui.text.IColorManager;
+import net.sourceforge.phpdt.ui.text.JavaTextTools;
+import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+public class TemplateEditorSourceViewerConfiguration extends PHPSourceViewerConfiguration {
+
+       private static class TemplateVariableTextHover implements ITextHover {
+
+               private TemplateVariableProcessor fProcessor;
+
+               /**
+                * @param type
+                */
+               public TemplateVariableTextHover(TemplateVariableProcessor processor) {
+                       fProcessor= processor;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+                */
+               public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
+                       try {
+                               IDocument doc= textViewer.getDocument();
+                               int offset= subject.getOffset();
+                               if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
+                                       String varName= doc.get(offset, subject.getLength());
+                                       TemplateContextType contextType= fProcessor.getContextType();
+                                       if (contextType != null) {
+                                               Iterator iter= contextType.resolvers();
+                                               while (iter.hasNext()) {
+                                                       TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
+                                                       if (varName.equals(var.getType())) {
+                                                               return var.getDescription();
+                                                       }
+                                               }
+                                       }
+                               }                               
+                       } catch (BadLocationException e) {
+                       }
+                       return null;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
+                */
+               public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+                       if (textViewer != null) {
+                               return JavaWordFinder.findWord(textViewer.getDocument(), offset);
+                       }
+                       return null;    
+               }
+               
+       } 
+       
+       private final TemplateVariableProcessor fProcessor;
+
+       public TemplateEditorSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor, TemplateVariableProcessor processor) {
+               super(colorManager, store, editor, IPHPPartitions.PHP_PARTITIONING);
+               fProcessor= processor;
+       }
+       
+       /*
+        * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
+        */
+       public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+
+               IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore();
+               JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+               IColorManager manager= textTools.getColorManager();                                     
+               
+
+               ContentAssistant assistant= new ContentAssistant();
+               assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+                       // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
+               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_STRING_DQ);
+               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_STRING_SQ);
+               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_SINGLELINE_COMMENT);
+               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_MULTILINE_COMMENT);
+               assistant.setContentAssistProcessor(fProcessor, IPHPPartitions.PHP_PHPDOC_COMMENT);
+
+               assistant.enableAutoInsert(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOINSERT));
+               assistant.enableAutoActivation(store.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION));
+               assistant.setAutoActivationDelay(store.getInt(PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY));
+               assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
+               assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
+               assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
+
+               Color background= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);                        
+               assistant.setContextInformationPopupBackground(background);
+               assistant.setContextSelectorBackground(background);
+               assistant.setProposalSelectorBackground(background);
+
+               Color foreground= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
+               assistant.setContextInformationPopupForeground(foreground);
+               assistant.setContextSelectorForeground(foreground);
+               assistant.setProposalSelectorForeground(foreground);
+               
+               return assistant;
+       }       
+
+       private Color getColor(IPreferenceStore store, String key, IColorManager manager) {
+               RGB rgb= PreferenceConverter.getColor(store, key);
+               return manager.getColor(rgb);
+       }
+       
+       /*
+        * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
+        * @since 2.1
+        */
+       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+               return new TemplateVariableTextHover(fProcessor);
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/TemplatePreferencePage.java
deleted file mode 100644 (file)
index f375353..0000000
+++ /dev/null
@@ -1,655 +0,0 @@
-package net.sourceforge.phpdt.internal.ui.preferences;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.TemplateSet;
-import net.sourceforge.phpdt.internal.corext.template.Templates;
-import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateContentProvider;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateLabelProvider;
-import net.sourceforge.phpdt.internal.ui.util.SWTUtil;
-import net.sourceforge.phpdt.ui.text.JavaTextTools;
-import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-public class TemplatePreferencePage
-  extends PreferencePage
-  implements IWorkbenchPreferencePage {
-
-  // preference store keys
-  private static final String PREF_FORMAT_TEMPLATES = PHPeclipsePlugin.PLUGIN_ID + ".template.format"; //$NON-NLS-1$
-
-  private Templates fTemplates;
-
-  private CheckboxTableViewer fTableViewer;
-  private Button fAddButton;
-  private Button fEditButton;
-  private Button fImportButton;
-  private Button fExportButton;
-  private Button fExportAllButton;
-  private Button fRemoveButton;
-  private Button fEnableAllButton;
-  private Button fDisableAllButton;
-
-  private SourceViewer fPatternViewer;
-  //   private Button fFormatButton;
-
-  public TemplatePreferencePage() {
-    super();
-
-    setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore());
-    setDescription(TemplateMessages.getString("TemplatePreferencePage.message")); //$NON-NLS-1$
-
-    fTemplates = Templates.getInstance();
-  }
-
-  /*
-   * @see PreferencePage#createContents(Composite)
-   */
-  protected Control createContents(Composite ancestor) {
- //   PHPEditorEnvironment.connect(this);
-    Composite parent = new Composite(ancestor, SWT.NONE);
-    GridLayout layout = new GridLayout();
-    layout.numColumns = 2;
-    layout.marginHeight = 0;
-    layout.marginWidth = 0;
-    parent.setLayout(layout);
-
-    Composite innerParent = new Composite(parent, SWT.NONE);
-    GridLayout innerLayout = new GridLayout();
-    innerLayout.numColumns = 2;
-    innerLayout.marginHeight = 0;
-    innerLayout.marginWidth = 0;
-    innerParent.setLayout(innerLayout);
-    GridData gd = new GridData(GridData.FILL_BOTH);
-    gd.horizontalSpan = 2;
-    innerParent.setLayoutData(gd);
-
-    Table table =
-      new Table(
-        innerParent,
-        SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
-
-    GridData data = new GridData(GridData.FILL_BOTH);
-    data.widthHint = convertWidthInCharsToPixels(3);
-    data.heightHint = convertHeightInCharsToPixels(10);
-    table.setLayoutData(data);
-
-    table.setHeaderVisible(true);
-    table.setLinesVisible(true);
-
-    TableLayout tableLayout = new TableLayout();
-    table.setLayout(tableLayout);
-
-    TableColumn column1 = new TableColumn(table, SWT.NONE);
-    column1.setText(TemplateMessages.getString("TemplatePreferencePage.column.name")); //$NON-NLS-1$
-
-    TableColumn column2 = new TableColumn(table, SWT.NONE);
-    column2.setText(TemplateMessages.getString("TemplatePreferencePage.column.context")); //$NON-NLS-1$
-
-    TableColumn column3 = new TableColumn(table, SWT.NONE);
-    column3.setText(TemplateMessages.getString("TemplatePreferencePage.column.description")); //$NON-NLS-1$
-
-    fTableViewer = new CheckboxTableViewer(table);
-    fTableViewer.setLabelProvider(new TemplateLabelProvider());
-    fTableViewer.setContentProvider(new TemplateContentProvider());
-
-    fTableViewer.setSorter(new ViewerSorter() {
-      public int compare(Viewer viewer, Object object1, Object object2) {
-        if ((object1 instanceof Template) && (object2 instanceof Template)) {
-          Template left = (Template) object1;
-          Template right = (Template) object2;
-          int result = left.getName().compareToIgnoreCase(right.getName());
-          if (result != 0)
-            return result;
-          return left.getDescription().compareToIgnoreCase(
-            right.getDescription());
-        }
-        return super.compare(viewer, object1, object2);
-      }
-
-      public boolean isSorterProperty(Object element, String property) {
-        return true;
-      }
-    });
-
-    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
-      public void doubleClick(DoubleClickEvent e) {
-        edit();
-      }
-    });
-
-    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-      public void selectionChanged(SelectionChangedEvent e) {
-        selectionChanged1();
-      }
-    });
-
-    fTableViewer.addCheckStateListener(new ICheckStateListener() {
-      public void checkStateChanged(CheckStateChangedEvent event) {
-        Template template = (Template) event.getElement();
-        template.setEnabled(event.getChecked());
-      }
-    });
-
-    Composite buttons = new Composite(innerParent, SWT.NONE);
-    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-    layout = new GridLayout();
-    layout.marginHeight = 0;
-    layout.marginWidth = 0;
-    buttons.setLayout(layout);
-
-    fAddButton = new Button(buttons, SWT.PUSH);
-    fAddButton.setText(TemplateMessages.getString("TemplatePreferencePage.new")); //$NON-NLS-1$
-    fAddButton.setLayoutData(getButtonGridData(fAddButton));
-    fAddButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        add();
-      }
-    });
-
-    fEditButton = new Button(buttons, SWT.PUSH);
-    fEditButton.setText(TemplateMessages.getString("TemplatePreferencePage.edit")); //$NON-NLS-1$
-    fEditButton.setLayoutData(getButtonGridData(fEditButton));
-    fEditButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        edit();
-      }
-    });
-
-    fRemoveButton = new Button(buttons, SWT.PUSH);
-    fRemoveButton.setText(TemplateMessages.getString("TemplatePreferencePage.remove")); //$NON-NLS-1$
-    fRemoveButton.setLayoutData(getButtonGridData(fRemoveButton));
-    fRemoveButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        remove();
-      }
-    });
-
-    fImportButton = new Button(buttons, SWT.PUSH);
-    fImportButton.setText(TemplateMessages.getString("TemplatePreferencePage.import")); //$NON-NLS-1$
-    fImportButton.setLayoutData(getButtonGridData(fImportButton));
-    fImportButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        import_();
-      }
-    });
-
-    fExportButton = new Button(buttons, SWT.PUSH);
-    fExportButton.setText(TemplateMessages.getString("TemplatePreferencePage.export")); //$NON-NLS-1$
-    fExportButton.setLayoutData(getButtonGridData(fExportButton));
-    fExportButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        export();
-      }
-    });
-
-    fExportAllButton = new Button(buttons, SWT.PUSH);
-    fExportAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.export.all")); //$NON-NLS-1$
-    fExportAllButton.setLayoutData(getButtonGridData(fExportAllButton));
-    fExportAllButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        exportAll();
-      }
-    });
-
-    fEnableAllButton = new Button(buttons, SWT.PUSH);
-    fEnableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.enable.all")); //$NON-NLS-1$
-    fEnableAllButton.setLayoutData(getButtonGridData(fEnableAllButton));
-    fEnableAllButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        enableAll(true);
-      }
-    });
-
-    fDisableAllButton = new Button(buttons, SWT.PUSH);
-    fDisableAllButton.setText(TemplateMessages.getString("TemplatePreferencePage.disable.all")); //$NON-NLS-1$
-    fDisableAllButton.setLayoutData(getButtonGridData(fDisableAllButton));
-    fDisableAllButton.addListener(SWT.Selection, new Listener() {
-      public void handleEvent(Event e) {
-        enableAll(false);
-      }
-    });
-
-    fPatternViewer = createViewer(parent);
-
-    //         fFormatButton= new Button(parent, SWT.CHECK);
-    //         fFormatButton.setText(ObfuscatorMessages.getString("TemplatePreferencePage.use.code.formatter")); //$NON-NLS-1$
-    //        GridData gd1= new GridData();
-    //        gd1.horizontalSpan= 2;
-    //        fFormatButton.setLayoutData(gd1);
-
-    fTableViewer.setInput(fTemplates);
-    fTableViewer.setAllChecked(false);
-    fTableViewer.setCheckedElements(getEnabledTemplates());
-
-    IPreferenceStore prefs = PHPeclipsePlugin.getDefault().getPreferenceStore();
-    // fFormatButton.setSelection(prefs.getBoolean(PREF_FORMAT_TEMPLATES));
-
-    updateButtons();
-    configureTableResizing(
-      innerParent,
-      buttons,
-      table,
-      column1,
-      column2,
-      column3);
-
-    // WorkbenchHelp.setHelp(parent, IJavaHelpContextIds.TEMPLATE_PREFERENCE_PAGE);
-
-    return parent;
-  }
-
-  /**
-  * Correctly resizes the table so no phantom columns appear
-  */
-  private static void configureTableResizing(
-    final Composite parent,
-    final Composite buttons,
-    final Table table,
-    final TableColumn column1,
-    final TableColumn column2,
-    final TableColumn column3) {
-    parent.addControlListener(new ControlAdapter() {
-      public void controlResized(ControlEvent e) {
-        Rectangle area = parent.getClientArea();
-        Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-        int width = area.width - 2 * table.getBorderWidth();
-        if (preferredSize.y > area.height) {
-          // Subtract the scrollbar width from the total column width
-          // if a vertical scrollbar will be required
-          Point vBarSize = table.getVerticalBar().getSize();
-          width -= vBarSize.x;
-        }
-        width -= buttons.getSize().x;
-        Point oldSize = table.getSize();
-        if (oldSize.x > width) {
-          // table is getting smaller so make the columns
-          // smaller first and then resize the table to
-          // match the client area width
-          column1.setWidth(width / 4);
-          column2.setWidth(width / 4);
-          column3.setWidth(width - (column1.getWidth() + column2.getWidth()));
-          table.setSize(width, area.height);
-        } else {
-          // table is getting bigger so make the table
-          // bigger first and then make the columns wider
-          // to match the client area width
-          table.setSize(width, area.height);
-          column1.setWidth(width / 4);
-          column2.setWidth(width / 4);
-          column3.setWidth(width - (column1.getWidth() + column2.getWidth()));
-        }
-      }
-    });
-  }
-
-  private Template[] getEnabledTemplates() {
-    Template[] templates = fTemplates.getTemplates();
-
-    List list = new ArrayList(templates.length);
-
-    for (int i = 0; i != templates.length; i++)
-      if (templates[i].isEnabled())
-        list.add(templates[i]);
-
-    return (Template[]) list.toArray(new Template[list.size()]);
-  }
-
-  private SourceViewer createViewer(Composite parent) {
-    Label label = new Label(parent, SWT.NONE);
-    label.setText(TemplateMessages.getString("TemplatePreferencePage.preview")); //$NON-NLS-1$
-    GridData data = new GridData();
-    data.horizontalSpan = 2;
-    label.setLayoutData(data);
-
-    SourceViewer viewer =
-      new SourceViewer(parent, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
-    JavaTextTools tools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    IDocument document = new Document();
-    IDocumentPartitioner partitioner = tools.createDocumentPartitioner();
-    document.setDocumentPartitioner(partitioner);
-    partitioner.connect(document);
-
-    viewer.configure(new PHPSourceViewerConfiguration(tools, null, IPHPPartitions.PHP_PARTITIONING));
-    // (tools, null));
-    viewer.setEditable(false);
-    viewer.setDocument(document);
-    viewer.getTextWidget().setBackground(
-      getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
-
-    Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
-    viewer.getTextWidget().setFont(font);
-
-    Control control = viewer.getControl();
-    data = new GridData(GridData.FILL_BOTH);
-    data.horizontalSpan = 2;
-    data.heightHint = convertHeightInCharsToPixels(5);
-    control.setLayoutData(data);
-
-    return viewer;
-  }
-
-  private static GridData getButtonGridData(Button button) {
-    GridData data = new GridData(GridData.FILL_HORIZONTAL);
-    data.widthHint = SWTUtil.getButtonWidthHint(button);
-    data.heightHint = SWTUtil.getButtonHeigthHint(button);
-
-    return data;
-  }
-
-  private void selectionChanged1() {
-    IStructuredSelection selection =
-      (IStructuredSelection) fTableViewer.getSelection();
-
-    if (selection.size() == 1) {
-      Template template = (Template) selection.getFirstElement();
-      fPatternViewer.getTextWidget().setText(template.getPattern());
-    } else {
-      fPatternViewer.getTextWidget().setText(""); //$NON-NLS-1$
-    }
-
-    updateButtons();
-  }
-
-  private void updateButtons() {
-    int selectionCount =
-      ((IStructuredSelection) fTableViewer.getSelection()).size();
-    int itemCount = fTableViewer.getTable().getItemCount();
-
-    fEditButton.setEnabled(selectionCount == 1);
-    fExportButton.setEnabled(selectionCount > 0);
-    fRemoveButton.setEnabled(selectionCount > 0 && selectionCount <= itemCount);
-    fEnableAllButton.setEnabled(itemCount > 0);
-    fDisableAllButton.setEnabled(itemCount > 0);
-  }
-
-  private void add() {
-
-    Template template = new Template();
-
-    ContextTypeRegistry registry = ContextTypeRegistry.getInstance();
-    ContextType type = registry.getContextType("php"); //$NON-NLS-1$
-
-    String contextTypeName;
-    if (type != null)
-      contextTypeName = type.getName();
-    else {
-      Iterator iterator = registry.iterator();
-      contextTypeName = (String) iterator.next();
-    }
-    template.setContext(contextTypeName); //$NON-NLS-1$
-
-    EditTemplateDialog dialog =
-      new EditTemplateDialog(getShell(), template, false);
-    if (dialog.open() == EditTemplateDialog.OK) {
-      fTemplates.add(template);
-      fTableViewer.refresh();
-      fTableViewer.setChecked(template, template.isEnabled());
-      fTableViewer.setSelection(new StructuredSelection(template));
-    }
-  }
-
-  private void edit() {
-    IStructuredSelection selection =
-      (IStructuredSelection) fTableViewer.getSelection();
-
-    Object[] objects = selection.toArray();
-    if ((objects == null) || (objects.length != 1))
-      return;
-
-    Template template = (Template) selection.getFirstElement();
-    edit(template);
-  }
-
-  private void edit(Template template) {
-    Template newTemplate = new Template(template);
-    EditTemplateDialog dialog =
-      new EditTemplateDialog(getShell(), newTemplate, true);
-    if (dialog.open() == EditTemplateDialog.OK) {
-
-      if (!newTemplate.getName().equals(template.getName()) && MessageDialog.openQuestion(getShell(), TemplateMessages.getString("TemplatePreferencePage.question.create.new.title"), //$NON-NLS-1$
-      TemplateMessages.getString("TemplatePreferencePage.question.create.new.message"))) //$NON-NLS-1$
-        {
-        template = newTemplate;
-        fTemplates.add(template);
-        fTableViewer.refresh();
-      } else {
-        template.setName(newTemplate.getName());
-        template.setDescription(newTemplate.getDescription());
-        template.setContext(newTemplate.getContextTypeName());
-        template.setPattern(newTemplate.getPattern());
-        fTableViewer.refresh(template);
-      }
-      fTableViewer.setChecked(template, template.isEnabled());
-      fTableViewer.setSelection(new StructuredSelection(template));
-    }
-  }
-
-  private void import_() {
-    FileDialog dialog = new FileDialog(getShell());
-    dialog.setText(TemplateMessages.getString("TemplatePreferencePage.import.title")); //$NON-NLS-1$
-    dialog.setFilterExtensions(new String[] { TemplateMessages.getString("TemplatePreferencePage.import.extension")}); //$NON-NLS-1$
-    String path = dialog.open();
-
-    if (path == null)
-      return;
-
-    try {
-      fTemplates.addFromFile(new File(path));
-
-      fTableViewer.refresh();
-      fTableViewer.setAllChecked(false);
-      fTableViewer.setCheckedElements(getEnabledTemplates());
-
-    } catch (CoreException e) {
-      openReadErrorDialog(e);
-    }
-  }
-
-  private void exportAll() {
-    export(fTemplates);
-  }
-
-  private void export() {
-    IStructuredSelection selection =
-      (IStructuredSelection) fTableViewer.getSelection();
-    Object[] templates = selection.toArray();
-
-    TemplateSet templateSet = new TemplateSet();
-    for (int i = 0; i != templates.length; i++)
-      templateSet.add((Template) templates[i]);
-
-    export(templateSet);
-  }
-
-  private void export(TemplateSet templateSet) {
-    FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
-    dialog.setText(TemplateMessages.getFormattedString("TemplatePreferencePage.export.title", new Integer(templateSet.getTemplates().length))); //$NON-NLS-1$
-    dialog.setFilterExtensions(new String[] { TemplateMessages.getString("TemplatePreferencePage.export.extension")}); //$NON-NLS-1$
-    dialog.setFileName(TemplateMessages.getString("TemplatePreferencePage.export.filename")); //$NON-NLS-1$
-    String path = dialog.open();
-
-    if (path == null)
-      return;
-
-    File file = new File(path);
-
-    if (!file.exists() || confirmOverwrite(file)) {
-      try {
-        templateSet.saveToFile(file);
-      } catch (CoreException e) {
-        PHPeclipsePlugin.log(e);
-        openWriteErrorDialog(e);
-      }
-    }
-  }
-
-  private boolean confirmOverwrite(File file) {
-    return MessageDialog.openQuestion(getShell(), TemplateMessages.getString("TemplatePreferencePage.export.exists.title"), //$NON-NLS-1$
-    TemplateMessages.getFormattedString("TemplatePreferencePage.export.exists.message", file.getAbsolutePath())); //$NON-NLS-1$
-  }
-
-  private void remove() {
-    IStructuredSelection selection =
-      (IStructuredSelection) fTableViewer.getSelection();
-
-    Iterator elements = selection.iterator();
-    while (elements.hasNext()) {
-      Template template = (Template) elements.next();
-      fTemplates.remove(template);
-    }
-
-    fTableViewer.refresh();
-  }
-
-  private void enableAll(boolean enable) {
-    Template[] templates = fTemplates.getTemplates();
-    for (int i = 0; i != templates.length; i++)
-      templates[i].setEnabled(enable);
-
-    fTableViewer.setAllChecked(enable);
-  }
-
-  /*
-   * @see IWorkbenchPreferencePage#init(IWorkbench)
-   */
-  public void init(IWorkbench workbench) {
-  }
-
-  /*
-   * @see Control#setVisible(boolean)
-   */
-  public void setVisible(boolean visible) {
-    super.setVisible(visible);
-    if (visible)
-      setTitle(TemplateMessages.getString("TemplatePreferencePage.title")); //$NON-NLS-1$
-  }
-
-  /*
-   * @see PreferencePage#performDefaults()
-   */
-  protected void performDefaults() {
-    IPreferenceStore prefs = PHPeclipsePlugin.getDefault().getPreferenceStore();
-    // fFormatButton.setSelection(prefs.getDefaultBoolean(PREF_FORMAT_TEMPLATES));
-
-    try {
-      fTemplates.restoreDefaults();
-    } catch (CoreException e) {
-      PHPeclipsePlugin.log(e);
-      openReadErrorDialog(e);
-    }
-
-    // refresh
-    fTableViewer.refresh();
-    fTableViewer.setAllChecked(false);
-    fTableViewer.setCheckedElements(getEnabledTemplates());
-  }
-
-  /*
-   * @see PreferencePage#performOk()
-   */
-  public boolean performOk() {
-    IPreferenceStore prefs = PHPeclipsePlugin.getDefault().getPreferenceStore();
-    // prefs.setValue(PREF_FORMAT_TEMPLATES, fFormatButton.getSelection());
-
-    try {
-      fTemplates.save();
-    } catch (CoreException e) {
-      PHPeclipsePlugin.log(e);
-      openWriteErrorDialog(e);
-    }
-
-    PHPeclipsePlugin.getDefault().savePluginPreferences();
- //   PHPEditorEnvironment.disconnect(this);
-    return super.performOk();
-  }
-
-  /*
-   * @see PreferencePage#performCancel()
-   */
-  public boolean performCancel() {
-    try {
-      fTemplates.reset();
-    } catch (CoreException e) {
-      PHPeclipsePlugin.log(e);
-      openReadErrorDialog(e);
-    }
-
-   // PHPEditorEnvironment.disconnect(this);
-    return super.performCancel();
-  }
-
-  /**
-   * Initializes the default values of this page in the preference bundle.
-   * Will be called on startup of the PHPeclipsePlugin
-   */
-  public static void initDefaults(IPreferenceStore prefs) {
-    prefs.setDefault(PREF_FORMAT_TEMPLATES, true);
-  }
-
-  //   public static boolean useCodeFormatter() {
-  //           IPreferenceStore prefs= PHPeclipsePlugin.getDefault().getPreferenceStore();
-  //           return prefs.getBoolean(PREF_FORMAT_TEMPLATES);
-  //   }
-
-  private void openReadErrorDialog(CoreException e) {
-    ErrorDialog.openError(getShell(), TemplateMessages.getString("TemplatePreferencePage.error.read.title"), //$NON-NLS-1$
-    null, e.getStatus());
-  }
-
-  private void openWriteErrorDialog(CoreException e) {
-    ErrorDialog.openError(getShell(), TemplateMessages.getString("TemplatePreferencePage.error.write.title"), //$NON-NLS-1$
-    null, e.getStatus());
-  }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaHeuristicScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/JavaHeuristicScanner.java
new file mode 100644 (file)
index 0000000..ebeef70
--- /dev/null
@@ -0,0 +1,801 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+
+/**
+ * Utility methods for heuristic based Java manipulations in an incomplete Java source file.
+ * 
+ * <p>An instance holds some internal position in the document and is therefore not threadsafe.</p>
+ * 
+ * @since 3.0
+ */
+public class JavaHeuristicScanner implements Symbols {
+       /** 
+        * Returned by all methods when the requested position could not be found, or if a 
+        * {@link BadLocationException} was thrown while scanning.
+        */
+       public static final int NOT_FOUND= -1;
+
+       /** 
+        * Special bound parameter that means either -1 (backward scanning) or 
+        * <code>fDocument.getLength()</code> (forward scanning).
+        */
+       public static final int UNBOUND= -2;
+
+
+       /* character constants */
+       private static final char LBRACE= '{';
+       private static final char RBRACE= '}';
+       private static final char LPAREN= '(';
+       private static final char RPAREN= ')';
+       private static final char SEMICOLON= ';';
+       private static final char COLON= ':';
+       private static final char COMMA= ',';
+       private static final char LBRACKET= '[';
+       private static final char RBRACKET= ']';
+       private static final char QUESTIONMARK= '?';
+       private static final char EQUAL= '=';
+
+       /**
+        * Specifies the stop condition, upon which the <code>scanXXX</code> methods will decide whether
+        * to keep scanning or not. This interface may implemented by clients.
+        */
+       public interface StopCondition {
+               /**
+                * Instructs the scanner to return the current position.
+                * 
+                * @param ch the char at the current position
+                * @param position the current position
+                * @param forward the iteration direction 
+                * @return <code>true</code> if the stop condition is met.
+                */
+               boolean stop(char ch, int position, boolean forward);
+       }
+       
+       /**
+        * Stops upon a non-whitespace (as defined by {@link Character#isWhitespace(char)}) character. 
+        */
+       private static class NonWhitespace implements StopCondition {
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
+                */
+               public boolean stop(char ch, int position, boolean forward) {
+                       return !Character.isWhitespace(ch);
+               }
+       }
+       
+       /**
+        * Stops upon a non-whitespace character in the default partition.
+        * 
+        * @see NonWhitespace 
+        */
+       private class NonWhitespaceDefaultPartition extends NonWhitespace {
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
+                */
+               public boolean stop(char ch, int position, boolean forward) {
+                       return super.stop(ch, position, true) && isDefaultPartition(position);
+               }
+       }
+       
+       /**
+        * Stops upon a non-java identifier (as defined by {@link Character#isJavaIdentifierPart(char)}) character. 
+        */
+       private static class NonJavaIdentifierPart implements StopCondition {
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
+                */
+               public boolean stop(char ch, int position, boolean forward) {
+                       return !Character.isJavaIdentifierPart(ch);
+               }
+       }
+       
+       /**
+        * Stops upon a non-java identifier character in the default partition.
+        * 
+        * @see NonJavaIdentifierPart 
+        */
+       private class NonJavaIdentifierPartDefaultPartition extends NonJavaIdentifierPart {
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char)
+                */
+               public boolean stop(char ch, int position, boolean forward) {
+                       return super.stop(ch, position, true) || !isDefaultPartition(position);
+               }
+       }
+       
+       /**
+        * Stops upon a character in the default partition that matches the given character list. 
+        */
+       private class CharacterMatch implements StopCondition {
+               private final char[] fChars;
+                
+               /**
+                * Creates a new instance.
+                * @param ch the single character to match 
+                */
+               public CharacterMatch(char ch) {
+                       this(new char[] {ch});
+               }
+               
+               /**
+                * Creates a new instance.
+                * @param chars the chars to match.
+                */
+               public CharacterMatch(char[] chars) {
+                       Assert.isNotNull(chars);
+                       Assert.isTrue(chars.length > 0);
+                       fChars= chars;
+                       Arrays.sort(chars);
+               }
+               
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char, int)
+                */
+               public boolean stop(char ch, int position, boolean forward) {
+                       return Arrays.binarySearch(fChars, ch) >= 0 && isDefaultPartition(position);
+               }
+       }
+       
+       /**
+        * Acts like character match, but skips all scopes introduced by parenthesis, brackets, and 
+        * braces. 
+        */
+       protected class SkippingScopeMatch extends CharacterMatch {
+               private char fOpening, fClosing;
+               private int fDepth= 0;
+               
+               /**
+                * Creates a new instance.
+                * @param ch the single character to match
+                */
+               public SkippingScopeMatch(char ch) {
+                       super(ch);
+               }
+               
+               /**
+                * Creates a new instance.
+                * @param chars the chars to match.
+                */
+               public SkippingScopeMatch(char[] chars) {
+                       super(chars);
+               }
+
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.StopCondition#stop(char, int)
+                */
+               public boolean stop(char ch, int position, boolean forward) {
+                       
+                       if (fDepth == 0 && super.stop(ch, position, true))
+                               return true;
+                       else if (ch == fOpening)
+                               fDepth++;
+                       else if (ch == fClosing) {
+                               fDepth--;
+                               if (fDepth == 0) {
+                                       fOpening= 0;
+                                       fClosing= 0;
+                               }
+                       } else if (fDepth == 0) {
+                               fDepth= 1;
+                               if (forward) {
+                                       
+                                       switch (ch) {
+                                               case LBRACE:
+                                                       fOpening= LBRACE;
+                                                       fClosing= RBRACE;
+                                                       break;
+                                               case LPAREN:
+                                                       fOpening= LPAREN;
+                                                       fClosing= RPAREN;
+                                                       break;
+                                               case LBRACKET:
+                                                       fOpening= LBRACKET;
+                                                       fClosing= RBRACKET;
+                                                       break;
+                                       }
+                                       
+                               } else {
+                                       switch (ch) {
+                                               case RBRACE:
+                                                       fOpening= RBRACE;
+                                                       fClosing= LBRACE;
+                                                       break;
+                                               case RPAREN:
+                                                       fOpening= RPAREN;
+                                                       fClosing= LPAREN;
+                                                       break;
+                                               case RBRACKET:
+                                                       fOpening= RBRACKET;
+                                                       fClosing= LBRACKET;
+                                                       break;
+                                       }
+                                       
+                               }
+                       }
+                       
+                       return false;
+                       
+               }
+
+       }
+       
+       /** The document being scanned. */
+       private IDocument fDocument;
+       /** The partitioning being used for scanning. */
+       private String fPartitioning;
+       /** The partition to scan in. */
+       private String fPartition;
+
+       /* internal scan state */       
+       
+       /** the most recently read character. */
+       private char fChar;
+       /** the most recently read position. */
+       private int fPos;
+       
+       /* preset stop conditions */
+       private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition();
+       private final static StopCondition fNonWS= new NonWhitespace();
+       private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition();
+
+       /**
+        * Creates a new instance.
+        * 
+        * @param document the document to scan
+        * @param partitioning the partitioning to use for scanning
+        * @param partition the partition to scan in
+        */
+       public JavaHeuristicScanner(IDocument document, String partitioning, String partition) {
+               Assert.isNotNull(document);
+               Assert.isNotNull(partitioning);
+               Assert.isNotNull(partition);
+               fDocument= document;
+               fPartitioning= partitioning;
+               fPartition= partition;
+       }
+       
+       /**
+        * Calls <code>this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>.
+        * 
+        * @param document the document to scan.
+        */
+       public JavaHeuristicScanner(IDocument document) {
+               this(document, IPHPPartitions.PHP_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE);
+       }
+       
+       /**
+        * Returns the most recent internal scan position.
+        * 
+        * @return the most recent internal scan position.
+        */
+       public int getPosition() {
+               return fPos;
+       }
+       
+       /**
+        * Returns the next token in forward direction, starting at <code>start</code>, and not extending
+        * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}.
+        * After a call, {@link #getPosition()} will return the position just after the scanned token
+        * (i.e. the next position that will be scanned). 
+        * 
+        * @param start the first character position in the document to consider
+        * @param bound the first position not to consider any more
+        * @return a constant from {@link Symbols} describing the next token
+        */
+       public int nextToken(int start, int bound) {
+               int pos= scanForward(start, bound, fNonWSDefaultPart);
+               if (pos == NOT_FOUND)
+                       return TokenEOF;
+
+               fPos++;
+                       
+               switch (fChar) {
+                       case LBRACE:
+                               return TokenLBRACE;
+                       case RBRACE:
+                               return TokenRBRACE;
+                       case LBRACKET:
+                               return TokenLBRACKET;
+                       case RBRACKET:
+                               return TokenRBRACKET;
+                       case LPAREN:
+                               return TokenLPAREN;
+                       case RPAREN:
+                               return TokenRPAREN;
+                       case SEMICOLON:
+                               return TokenSEMICOLON;
+                       case COMMA:
+                               return TokenCOMMA;
+                       case QUESTIONMARK:
+                               return TokenQUESTIONMARK;
+                       case EQUAL:
+                               return TokenEQUAL;
+               }
+               
+               // else
+               if (Character.isJavaIdentifierPart(fChar)) {
+                       // assume an ident or keyword
+                       int from= pos, to;
+                       pos= scanForward(pos + 1, bound, fNonIdent);
+                       if (pos == NOT_FOUND)
+                               to= bound == UNBOUND ? fDocument.getLength() : bound;
+                       else
+                               to= pos;
+                       
+                       String identOrKeyword;
+                       try {
+                               identOrKeyword= fDocument.get(from, to - from);
+                       } catch (BadLocationException e) {
+                               return TokenEOF;
+                       }
+                       
+                       return getToken(identOrKeyword);
+                       
+                       
+               } else {
+                       // operators, number literals etc
+                       return TokenOTHER;
+               }
+       }
+       
+       /**
+        * Returns the next token in backward direction, starting at <code>start</code>, and not extending
+        * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}.
+        * After a call, {@link #getPosition()} will return the position just before the scanned token
+        * starts (i.e. the next position that will be scanned). 
+        * 
+        * @param start the first character position in the document to consider
+        * @param bound the first position not to consider any more
+        * @return a constant from {@link Symbols} describing the previous token
+        */
+       public int previousToken(int start, int bound) {
+               int pos= scanBackward(start, bound, fNonWSDefaultPart);
+               if (pos == NOT_FOUND)
+                       return TokenEOF;
+               
+               fPos--;
+                       
+               switch (fChar) {
+                       case LBRACE:
+                               return TokenLBRACE;
+                       case RBRACE:
+                               return TokenRBRACE;
+                       case LBRACKET:
+                               return TokenLBRACKET;
+                       case RBRACKET:
+                               return TokenRBRACKET;
+                       case LPAREN:
+                               return TokenLPAREN;
+                       case RPAREN:
+                               return TokenRPAREN;
+                       case SEMICOLON:
+                               return TokenSEMICOLON;
+                       case COLON:
+                               return TokenCOLON;
+                       case COMMA:
+                               return TokenCOMMA;
+                       case QUESTIONMARK:
+                               return TokenQUESTIONMARK;
+                       case EQUAL:
+                               return TokenEQUAL;
+               }
+               
+               // else
+               if (Character.isJavaIdentifierPart(fChar)) {
+                       // assume an ident or keyword
+                       int from, to= pos + 1;
+                       pos= scanBackward(pos - 1, bound, fNonIdent);
+                       if (pos == NOT_FOUND)
+                               from= bound == UNBOUND ? 0 : bound + 1;
+                       else
+                               from= pos + 1;
+                       
+                       String identOrKeyword;
+                       try {
+                               identOrKeyword= fDocument.get(from, to - from);
+                       } catch (BadLocationException e) {
+                               return TokenEOF;
+                       }
+                       
+                       return getToken(identOrKeyword);
+                       
+                       
+               } else {
+                       // operators, number literals etc
+                       return TokenOTHER;
+               }
+               
+       }
+
+       /**
+        * Returns one of the keyword constants or <code>TokenIDENT</code> for a scanned identifier.
+        * 
+        * @param s a scanned identifier
+        * @return one of the constants defined in {@link Symbols}
+        */
+       private int getToken(String s) {
+               Assert.isNotNull(s);
+               
+               switch (s.length()) {
+                       case 2:
+                               if ("if".equals(s)) //$NON-NLS-1$
+                                       return TokenIF;
+                               if ("do".equals(s)) //$NON-NLS-1$
+                                       return TokenDO;
+                               break;
+                       case 3:
+                               if ("for".equals(s)) //$NON-NLS-1$
+                                       return TokenFOR;
+                               if ("try".equals(s)) //$NON-NLS-1$
+                                       return TokenTRY;
+                               if ("new".equals(s)) //$NON-NLS-1$
+                                       return TokenNEW;
+                               break;
+                       case 4:
+                               if ("case".equals(s)) //$NON-NLS-1$
+                                       return TokenCASE;
+                               if ("else".equals(s)) //$NON-NLS-1$
+                                       return TokenELSE;
+                               if ("goto".equals(s)) //$NON-NLS-1$
+                                       return TokenGOTO;
+                               break;
+                       case 5:
+                               if ("break".equals(s)) //$NON-NLS-1$
+                                       return TokenBREAK;
+                               if ("catch".equals(s)) //$NON-NLS-1$
+                                       return TokenCATCH;
+                               if ("while".equals(s)) //$NON-NLS-1$
+                                       return TokenWHILE;
+                               break;
+                       case 6:
+                               if ("return".equals(s)) //$NON-NLS-1$
+                                       return TokenRETURN;
+                               if ("static".equals(s)) //$NON-NLS-1$
+                                       return TokenSTATIC;
+                               if ("switch".equals(s)) //$NON-NLS-1$
+                                       return TokenSWITCH;
+                               break;
+                       case 7:
+                               if ("default".equals(s)) //$NON-NLS-1$
+                                       return TokenDEFAULT;
+                               if ("finally".equals(s)) //$NON-NLS-1$
+                                       return TokenFINALLY;
+                               break;
+                       case 12:
+                               if ("synchronized".equals(s)) //$NON-NLS-1$
+                                       return TokenSYNCHRONIZED;
+                               break;
+               }
+               return TokenIDENT;
+       }
+
+       /**
+        * Returns the position of the closing peer character (forward search). Any scopes introduced by opening peers
+        * are skipped. All peers accounted for must reside in the default partition.
+        * 
+        * <p>Note that <code>start</code> must not point to the opening peer, but to the first
+        * character being searched.</p>
+        * 
+        * @param start the start position
+        * @param openingPeer the opening peer character (e.g. '{')
+        * @param closingPeer the closing peer character (e.g. '}')
+        * @return the matching peer character position, or <code>NOT_FOUND</code>
+        */
+       public int findClosingPeer(int start, final char openingPeer, final char closingPeer) {
+               Assert.isNotNull(fDocument);
+               Assert.isTrue(start >= 0);
+               
+               try {
+                       int depth= 1;
+                       start -= 1;
+                       while (true) {
+                               start= scanForward(start + 1, UNBOUND, new CharacterMatch(new char[] {openingPeer, closingPeer}));
+                               if (start == NOT_FOUND)
+                                       return NOT_FOUND;
+                                       
+                               if (fDocument.getChar(start) == openingPeer)
+                                       depth++;
+                               else
+                                       depth--;
+                               
+                               if (depth == 0)
+                                       return start;
+                       }
+
+               } catch (BadLocationException e) {
+                       return NOT_FOUND;
+               }
+       }
+
+       /**
+        * Returns the position of the opening peer character (backward search). Any scopes introduced by closing peers
+        * are skipped. All peers accounted for must reside in the default partition.
+        * 
+        * <p>Note that <code>start</code> must not point to the closing peer, but to the first
+        * character being searched.</p>
+        * 
+        * @param start the start position
+        * @param openingPeer the opening peer character (e.g. '{')
+        * @param closingPeer the closing peer character (e.g. '}')
+        * @return the matching peer character position, or <code>NOT_FOUND</code>
+        */
+       public int findOpeningPeer(int start, char openingPeer, char closingPeer) {
+               Assert.isTrue(start < fDocument.getLength());
+
+               try {
+                       int depth= 1;
+                       start += 1;
+                       while (true) {
+                               start= scanBackward(start - 1, UNBOUND, new CharacterMatch(new char[] {openingPeer, closingPeer}));
+                               if (start == NOT_FOUND)
+                                       return NOT_FOUND;
+                                       
+                               if (fDocument.getChar(start) == closingPeer)
+                                       depth++;
+                               else
+                                       depth--;
+                               
+                               if (depth == 0)
+                                       return start;
+                       }
+
+               } catch (BadLocationException e) {
+                       return NOT_FOUND;
+               }
+       }
+
+       /**
+        * Computes the surrounding block around <code>offset</code>. The search is started at the
+        * beginning of <code>offset</code>, i.e. an opening brace at <code>offset</code> will not be
+        * part of the surrounding block, but a closing brace will.
+        * 
+        * @param offset the offset for which the surrounding block is computed
+        * @return a region describing the surrounding block, or <code>null</code> if none can be found
+        */
+       public IRegion findSurroundingBlock(int offset) {
+               if (offset < 1 || offset >= fDocument.getLength())
+                       return null;
+                       
+               int begin= findOpeningPeer(offset - 1, LBRACE, RBRACE);
+               int end= findClosingPeer(offset, LBRACE, RBRACE);
+               if (begin == NOT_FOUND || end == NOT_FOUND)
+                       return null;
+               return new Region(begin, end + 1 - begin);
+       }
+
+       /**
+        * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>
+        * and the position is in the default partition.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int findNonWhitespaceForward(int position, int bound) {
+               return scanForward(position, bound, fNonWSDefaultPart);
+       }
+
+       /**
+        * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>), or <code>NOT_FOUND</code> if none can be found
+        */
+       public int findNonWhitespaceForwardInAnyPartition(int position, int bound) {
+               return scanForward(position, bound, fNonWS);
+       }
+
+       /**
+        * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
+        * and &gt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>
+        * and the position is in the default partition.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
+        * @return the highest position of a non-whitespace character in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int findNonWhitespaceBackward(int position, int bound) {         
+               return scanBackward(position, bound, fNonWSDefaultPart);
+       }
+
+       /**
+        * Finds the lowest position <code>p</code> in <code>fDocument</code> such that <code>start</code> &lt;= p &lt;
+        * <code>bound</code> and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>.
+        * 
+        * @param start the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>start</code>, or <code>UNBOUND</code>
+        * @param condition the <code>StopCondition</code> to check
+        * @return the lowest position in [<code>start</code>, <code>bound</code>) for which <code>condition</code> holds, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanForward(int start, int bound, StopCondition condition) {
+               Assert.isTrue(start >= 0);
+
+               if (bound == UNBOUND)
+                       bound= fDocument.getLength();
+               
+               Assert.isTrue(bound <= fDocument.getLength());
+               
+               try {
+                       fPos= start;
+                       while (fPos < bound) {
+
+                               fChar= fDocument.getChar(fPos);
+                               if (condition.stop(fChar, fPos, true))
+                                       return fPos;
+
+                               fPos++;
+                       }
+               } catch (BadLocationException e) {
+               }
+               return NOT_FOUND;
+       }
+       
+
+       /**
+        * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code>
+        * and the position is in the default partition.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @param ch the <code>char</code> to search for
+        * @return the lowest position of <code>ch</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanForward(int position, int bound, char ch) {
+               return scanForward(position, bound, new CharacterMatch(ch));
+       }
+
+       /**
+        * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
+        * ch in <code>chars</code> and the position is in the default partition.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @param chars an array of <code>char</code> to search for
+        * @return the lowest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanForward(int position, int bound, char[] chars) {
+               return scanForward(position, bound, new CharacterMatch(chars));
+       }
+       
+       /**
+        * Finds the highest position <code>p</code> in <code>fDocument</code> such that <code>bound</code> &lt; <code>p</code> &lt;= <code>start</code>
+        * and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>.
+        * 
+        * @param start the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
+        * @param condition the <code>StopCondition</code> to check
+        * @return the highest position in (<code>bound</code>, <code>start</code> for which <code>condition</code> holds, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanBackward(int start, int bound, StopCondition condition) {
+               if (bound == UNBOUND)
+                       bound= -1;
+               
+               Assert.isTrue(bound >= -1);
+               Assert.isTrue(start < fDocument.getLength() );
+               
+               try {
+                       fPos= start;
+                       while (fPos > bound) {
+                               
+                               fChar= fDocument.getChar(fPos);
+                               if (condition.stop(fChar, fPos, false))
+                                       return fPos;
+
+                               fPos--;
+                       }
+               } catch (BadLocationException e) {
+               }
+               return NOT_FOUND;
+       }
+       
+       /**
+        * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
+        * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
+        * ch in <code>chars</code> and the position is in the default partition.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
+        * @param ch the <code>char</code> to search for
+        * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanBackward(int position, int bound, char ch) {
+               return scanBackward(position, bound, new CharacterMatch(ch));
+       }
+       
+       /**
+        * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
+        * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
+        * ch in <code>chars</code> and the position is in the default partition.   
+        * 
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
+        * @param chars an array of <code>char</code> to search for
+        * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a Java partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanBackward(int position, int bound, char[] chars) {
+               return scanBackward(position, bound, new CharacterMatch(chars));
+       }
+       
+       /**
+        * Checks whether <code>position</code> resides in a default (Java) partition of <code>fDocument</code>.
+        * 
+        * @param position the position to be checked
+        * @return <code>true</code> if <code>position</code> is in the default partition of <code>fDocument</code>, <code>false</code> otherwise
+        */
+       public boolean isDefaultPartition(int position) {
+               Assert.isTrue(position >= 0);
+               Assert.isTrue(position <= fDocument.getLength());
+               
+               try {
+                       ITypedRegion region= TextUtilities.getPartition(fDocument, fPartitioning, position, false);
+                       return region.getType().equals(fPartition);
+                       
+               } catch (BadLocationException e) {
+               }
+               
+               return false;
+       }
+
+       /**
+        * Checks if the line seems to be an open condition not followed by a block (i.e. an if, while, 
+        * or for statement with just one following statement, see example below). 
+        * 
+        * <pre>
+        * if (condition)
+        *     doStuff();
+        * </pre>
+        * 
+        * <p>Algorithm: if the last non-WS, non-Comment code on the line is an if (condition), while (condition),
+        * for( expression), do, else, and there is no statement after that </p> 
+        * 
+        * @param position the insert position of the new character
+        * @param bound the lowest position to consider
+        * @return <code>true</code> if the code is a conditional statement or loop without a block, <code>false</code> otherwise
+        */
+       public boolean isBracelessBlockStart(int position, int bound) {
+               if (position < 1)
+                       return false;
+               
+               switch (previousToken(position, bound)) {
+                       case TokenDO:
+                       case TokenELSE:
+                               return true;
+                       case TokenRPAREN:
+                               position= findOpeningPeer(fPos, LPAREN, RPAREN);
+                               if (position > 0) {
+                                       switch (previousToken(position - 1, bound)) {
+                                               case TokenIF:
+                                               case TokenFOR:
+                                               case TokenWHILE:
+                                                       return true;
+                                       }
+                               }
+               }
+               
+               return false;
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/Symbols.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/Symbols.java
new file mode 100644 (file)
index 0000000..22e1a42
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text;
+
+/**
+ * Symbols for the heuristic java scanner.
+ * 
+ * @since 3.0
+ */
+public interface Symbols {
+       int TokenEOF= -1;
+       int TokenLBRACE= 1;
+       int TokenRBRACE= 2;
+       int TokenLBRACKET= 3;
+       int TokenRBRACKET= 4;
+       int TokenLPAREN= 5;
+       int TokenRPAREN= 6;
+       int TokenSEMICOLON= 7;
+       int TokenOTHER= 8;
+       int TokenCOLON= 9;
+       int TokenQUESTIONMARK= 10;
+       int TokenCOMMA= 11;
+       int TokenEQUAL= 12;
+       int TokenIF= 109;
+       int TokenDO= 1010;
+       int TokenFOR= 1011;
+       int TokenTRY= 1012;
+       int TokenCASE= 1013;
+       int TokenELSE= 1014;
+       int TokenBREAK= 1015;
+       int TokenCATCH= 1016;
+       int TokenWHILE= 1017;
+       int TokenRETURN= 1018;
+       int TokenSTATIC= 1019;
+       int TokenSWITCH= 1020;
+       int TokenFINALLY= 1021;
+       int TokenSYNCHRONIZED= 1022;
+       int TokenGOTO= 1023;
+       int TokenDEFAULT= 1024;
+       int TokenNEW= 1025;
+       int TokenIDENT= 2000;
+}
index 5f0d2be..fe1f77d 100644 (file)
@@ -8,11 +8,12 @@ package net.sourceforge.phpdt.internal.ui.text.phpdoc;
 import java.util.Arrays;
 import java.util.Comparator;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
+import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpdt.internal.ui.text.java.PHPCompletionProposalComparator;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine;
+import net.sourceforge.phpdt.internal.ui.text.template.contentassist.TemplateEngine;
+import net.sourceforge.phpdt.ui.IWorkingCopyManager;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextViewer;
@@ -20,165 +21,175 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
 import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.ui.IEditorPart;
 
 /**
  * Simple PHPDoc completion processor.
  */
 public class PHPDocCompletionProcessor implements IContentAssistProcessor {
-       
-       private static class PHPDocCompletionProposalComparator implements Comparator {
-               public int compare(Object o1, Object o2) {
-                       ICompletionProposal c1= (ICompletionProposal) o1;
-                       ICompletionProposal c2= (ICompletionProposal) o2;
-                       return c1.getDisplayString().compareTo(c2.getDisplayString());
-               }
-       };
-       
-//     private IEditorPart fEditor;
-//     private IWorkingCopyManager fManager;
-       private char[] fProposalAutoActivationSet;
-       private PHPCompletionProposalComparator fComparator;
-       private TemplateEngine fTemplateEngine;
-       
-       private boolean fRestrictToMatchingCase;
-       
-       
-       public PHPDocCompletionProcessor() {// (IEditorPart editor) {
-       
-//             fEditor= editor;
-//             fManager= JavaPlugin.getDefault().getWorkingCopyManager();
-               ContextType contextType= ContextTypeRegistry.getInstance().getContextType("phpdoc"); //$NON-NLS-1$
-               if (contextType != null)
-                       fTemplateEngine= new TemplateEngine(contextType);
-               fRestrictToMatchingCase= false;
-               
-               fComparator= new PHPCompletionProposalComparator();
-       }
-       
-       /**
-        * Tells this processor to order the proposals alphabetically.
-        * 
-        * @param order <code>true</code> if proposals should be ordered.
-        */
-       public void orderProposalsAlphabetically(boolean order) {
-               fComparator.setOrderAlphabetically(order);
-       }
-       
-       /**
-        * Tells this processor to restrict is proposals to those
-        * starting with matching cases.
-        * 
-        * @param restrict <code>true</code> if proposals should be restricted
-        */
-       public void restrictProposalsToMatchingCases(boolean restrict) {
-               fRestrictToMatchingCase= restrict;
-       }
-       
-       /**
-        * @see IContentAssistProcessor#getErrorMessage()
-        */
-       public String getErrorMessage() {
-               return null;
-       }
-
-       /**
-        * @see IContentAssistProcessor#getContextInformationValidator()
-        */
-       public IContextInformationValidator getContextInformationValidator() {
-               return null;
-       }
-
-       /**
-        * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
-        */
-       public char[] getContextInformationAutoActivationCharacters() {
-               return null;
-       }
-
-       /**
-        * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
-        */
-       public char[] getCompletionProposalAutoActivationCharacters() {
-               return fProposalAutoActivationSet;
-       }
-       
-       /**
-        * Sets this processor's set of characters triggering the activation of the
-        * completion proposal computation.
-        * 
-        * @param activationSet the activation set
-        */
-       public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
-               fProposalAutoActivationSet= activationSet;
-       }
-
-       /**
-        * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
-        */
-       public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
-               return null;
-       }
-
-       /**
-        * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
-        */
-       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
-       //      ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput());
-               IDocument document= viewer.getDocument();
-
-               IPHPCompletionProposal[] results= new IPHPCompletionProposal[0];
-
-//             try {
-//                     if (unit != null) {
-//                             
-//                             int offset= documentOffset;
-//                             int length= 0;
-//                             
-//                             Point selection= viewer.getSelectedRange();
-//                             if (selection.y > 0) {
-//                                     offset= selection.x;
-//                                     length= selection.y;
-//                             }
-//                             
-//                             JavaDocCompletionEvaluator evaluator= new JavaDocCompletionEvaluator(unit, document, offset, length);
-//                             evaluator.restrictProposalsToMatchingCases(fRestrictToMatchingCase);
-//                             results= evaluator.computeProposals();
-//                     }
-//             } catch (JavaModelException e) {
-//                     JavaPlugin.log(e);
-//             }
-
-               if (fTemplateEngine != null) {
-       //              try {
-                               fTemplateEngine.reset();
-                               fTemplateEngine.complete(viewer, documentOffset); //, unit);
-//                     } catch (JavaModelException x) {
-//                     }                               
-                       
-                       IPHPCompletionProposal[] templateResults= fTemplateEngine.getResults();
-                       if (results.length == 0) {
-                               results= templateResults;
-                       } else {
-                               // concatenate arrays
-                               IPHPCompletionProposal[] total= new IPHPCompletionProposal[results.length + templateResults.length];
-                               System.arraycopy(templateResults, 0, total, 0, templateResults.length);
-                               System.arraycopy(results, 0, total, templateResults.length, results.length);
-                               results= total;
-                       }
-               }
-
-               /*
-                * Order here and not in result collector to make sure that the order
-                * applies to all proposals and not just those of the compilation unit. 
-                */
-               return order(results);
-       }
-       
-       /**
-        * Order the given proposals.
-        */
-       private IPHPCompletionProposal[] order(IPHPCompletionProposal[] proposals) {
-               Arrays.sort(proposals, fComparator);
-               return proposals;       
-       }
+
+  private static class PHPDocCompletionProposalComparator implements Comparator {
+    public int compare(Object o1, Object o2) {
+      ICompletionProposal c1 = (ICompletionProposal) o1;
+      ICompletionProposal c2 = (ICompletionProposal) o2;
+      return c1.getDisplayString().compareTo(c2.getDisplayString());
+    }
+  };
+
+  //   private IEditorPart fEditor;
+  //   private IWorkingCopyManager fManager;
+  private char[] fProposalAutoActivationSet;
+
+  private PHPCompletionProposalComparator fComparator;
+
+  private TemplateEngine fTemplateEngine;
+
+  private boolean fRestrictToMatchingCase;
+
+  private IEditorPart fEditor;
+
+  protected IWorkingCopyManager fManager;
+
+  public PHPDocCompletionProcessor(IEditorPart editor) {
+    fEditor = editor;
+    fManager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
+
+    //         fEditor= editor;
+    //         fManager= JavaPlugin.getDefault().getWorkingCopyManager();
+    TemplateContextType contextType = PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType("phpdoc"); //$NON-NLS-1$
+    if (contextType != null)
+      fTemplateEngine = new TemplateEngine(contextType);
+    fRestrictToMatchingCase = false;
+
+    fComparator = new PHPCompletionProposalComparator();
+  }
+
+  /**
+   * Tells this processor to order the proposals alphabetically.
+   * 
+   * @param order
+   *          <code>true</code> if proposals should be ordered.
+   */
+  public void orderProposalsAlphabetically(boolean order) {
+    fComparator.setOrderAlphabetically(order);
+  }
+
+  /**
+   * Tells this processor to restrict is proposals to those starting with matching cases.
+   * 
+   * @param restrict
+   *          <code>true</code> if proposals should be restricted
+   */
+  public void restrictProposalsToMatchingCases(boolean restrict) {
+    fRestrictToMatchingCase = restrict;
+  }
+
+  /**
+   * @see IContentAssistProcessor#getErrorMessage()
+   */
+  public String getErrorMessage() {
+    return null;
+  }
+
+  /**
+   * @see IContentAssistProcessor#getContextInformationValidator()
+   */
+  public IContextInformationValidator getContextInformationValidator() {
+    return null;
+  }
+
+  /**
+   * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
+   */
+  public char[] getContextInformationAutoActivationCharacters() {
+    return null;
+  }
+
+  /**
+   * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
+   */
+  public char[] getCompletionProposalAutoActivationCharacters() {
+    return fProposalAutoActivationSet;
+  }
+
+  /**
+   * Sets this processor's set of characters triggering the activation of the completion proposal computation.
+   * 
+   * @param activationSet
+   *          the activation set
+   */
+  public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
+    fProposalAutoActivationSet = activationSet;
+  }
+
+  /**
+   * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
+   */
+  public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+    return null;
+  }
+
+  /**
+   * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
+   */
+  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
+    ICompilationUnit unit = fManager.getWorkingCopy(fEditor.getEditorInput());
+    IDocument document = viewer.getDocument();
+
+    IPHPCompletionProposal[] results = new IPHPCompletionProposal[0];
+
+    //         try {
+    //                 if (unit != null) {
+    //                         
+    //                         int offset= documentOffset;
+    //                         int length= 0;
+    //                         
+    //                         Point selection= viewer.getSelectedRange();
+    //                         if (selection.y > 0) {
+    //                                 offset= selection.x;
+    //                                 length= selection.y;
+    //                         }
+    //                         
+    //                         JavaDocCompletionEvaluator evaluator= new JavaDocCompletionEvaluator(unit, document, offset, length);
+    //                         evaluator.restrictProposalsToMatchingCases(fRestrictToMatchingCase);
+    //                         results= evaluator.computeProposals();
+    //                 }
+    //         } catch (JavaModelException e) {
+    //                 JavaPlugin.log(e);
+    //         }
+
+    if (fTemplateEngine != null) {
+      //               try {
+      fTemplateEngine.reset();
+      fTemplateEngine.complete(viewer, documentOffset, unit);
+      //                       } catch (JavaModelException x) {
+      //                       }
+
+      IPHPCompletionProposal[] templateResults = fTemplateEngine.getResults();
+      if (results.length == 0) {
+        results = templateResults;
+      } else {
+        // concatenate arrays
+        IPHPCompletionProposal[] total = new IPHPCompletionProposal[results.length + templateResults.length];
+        System.arraycopy(templateResults, 0, total, 0, templateResults.length);
+        System.arraycopy(results, 0, total, templateResults.length, results.length);
+        results = total;
+      }
+    }
+
+    /*
+     * Order here and not in result collector to make sure that the order applies to all proposals and not just those of the
+     * compilation unit.
+     */
+    return order(results);
+  }
+
+  /**
+   * Order the given proposals.
+   */
+  private IPHPCompletionProposal[] order(IPHPCompletionProposal[] proposals) {
+    Arrays.sort(proposals, fComparator);
+    return proposals;
+  }
 }
\ No newline at end of file
index b1b8104..c6e0c51 100644 (file)
@@ -6,9 +6,10 @@ package net.sourceforge.phpdt.internal.ui.text.template;
 
 import java.util.ArrayList;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
+import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPElement;
@@ -25,7 +26,7 @@ import org.eclipse.swt.graphics.Point;
 public class BuiltInEngine {
 
   /** The context type. */
-  private ContextType fContextType;
+  private JavaContextType fContextType;
   /** The result proposals. */
   private ArrayList fProposals = new ArrayList();
 
@@ -33,7 +34,7 @@ public class BuiltInEngine {
    * Creates the template engine for a particular context type.
    * See <code>TemplateContext</code> for supported context types.
    */
-  public BuiltInEngine(ContextType contextType) {
+  public BuiltInEngine(JavaContextType contextType) {
     // Assert.isNotNull(contextType);
     fContextType = contextType;
   }
@@ -62,8 +63,7 @@ public class BuiltInEngine {
    * @param completionPosition the context position in the document of the text viewer
    * @param compilationUnit the compilation unit (may be <code>null</code>)
    */
-  public void complete(ITextViewer viewer, int completionPosition, ArrayList identifiers)
-  //,ICompilationUnit compilationUnit)
+  public void complete(ITextViewer viewer, int completionPosition, ArrayList identifiers,ICompilationUnit compilationUnit)
   //hrows JavaModelException
   {
     IDocument document = viewer.getDocument();
@@ -84,9 +84,10 @@ public class BuiltInEngine {
       }
     }
 
-    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y); //mpilationUnit);
-
-    PHPUnitContext context = (PHPUnitContext) fContextType.createContext();
+//    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y); //mpilationUnit);
+//    JavaContext context = (JavaContext) fContextType.createContext();
+    JavaContext context = (JavaContext) fContextType.createContext(document, completionPosition,selection.y,compilationUnit);
+    context.setVariable("selection", selectedText); //$NON-NLS-1$
     int start = context.getStart();
     int end = context.getEnd();
     IRegion region = new Region(start, end - start);
index 87d481d..6f3485b 100644 (file)
@@ -3,10 +3,8 @@
  * All Rights Reserved.
  */
 package net.sourceforge.phpdt.internal.ui.text.template;
-
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
@@ -18,6 +16,7 @@ import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateContext;
 import org.eclipse.swt.graphics.Image;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI;
@@ -137,8 +136,8 @@ public class BuiltInProposal extends AbstractProposal { // implements IPHPComple
    */
   public int getRelevance() {
 
-    if (fContext instanceof PHPUnitContext) {
-      PHPUnitContext context = (PHPUnitContext) fContext;
+    if (fContext instanceof JavaContext) {
+      JavaContext context = (JavaContext) fContext;
       switch (context.getCharacterBeforeStart()) {
         // high relevance after whitespace
         case ' ' :
index 9ff8886..56274cd 100644 (file)
@@ -8,10 +8,11 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.SortedMap;
 
+import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation;
@@ -29,7 +30,7 @@ import org.eclipse.swt.graphics.Point;
 public class DeclarationEngine {
 
   /** The context type. */
-  private ContextType fContextType;
+  private JavaContextType fContextType;
   /** The result proposals. */
   private ArrayList fProposals = new ArrayList();
   /** Token determines last which declarations are allowed for proposal */
@@ -43,7 +44,7 @@ public class DeclarationEngine {
    * Creates the template engine for a particular context type.
    * See <code>TemplateContext</code> for supported context types.
    */
-  public DeclarationEngine(IProject project, ContextType contextType, int lastSignificantToken, IFile file) {
+  public DeclarationEngine(IProject project, JavaContextType contextType, int lastSignificantToken, IFile file) {
     // Assert.isNotNull(contextType);
     fProject = project;
     fContextType = contextType;
@@ -81,7 +82,7 @@ public class DeclarationEngine {
    * @param completionPosition the context position in the document of the text viewer
    * @param compilationUnit the compilation unit (may be <code>null</code>)
    */
-  public void complete(ITextViewer viewer, int completionPosition, SortedMap map) {
+  public void complete(ITextViewer viewer, int completionPosition, SortedMap map, ICompilationUnit compilationUnit) {
     IDocument document = viewer.getDocument();
 
     if (!(fContextType instanceof CompilationUnitContextType))
@@ -99,9 +100,12 @@ public class DeclarationEngine {
       }
     }
 
-    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y);
+//    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y);
+
+//    CompilationUnitContext context = (CompilationUnitContext) fContextType.createContext();
+    JavaContext context = (JavaContext) fContextType.createContext(document, completionPosition,selection.y,compilationUnit);
+    context.setVariable("selection", selectedText); //$NON-NLS-1$
 
-    PHPUnitContext context = (PHPUnitContext) fContextType.createContext();
     int start = context.getStart();
     int end = context.getEnd();
     String prefix = context.getKey();
index 76da3b3..f14a31c 100644 (file)
@@ -5,9 +5,8 @@
 package net.sourceforge.phpdt.internal.ui.text.template;
 
 import net.sourceforge.phpdt.internal.corext.phpdoc.PHPDocUtil;
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
@@ -20,6 +19,7 @@ import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateContext;
 import org.eclipse.swt.graphics.Image;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI;
@@ -208,8 +208,8 @@ public class DeclarationProposal extends AbstractProposal { //implements IPHPCom
    */
   public int getRelevance() {
 
-    if (fContext instanceof PHPUnitContext) {
-      PHPUnitContext context = (PHPUnitContext) fContext;
+    if (fContext instanceof JavaContext) {
+      JavaContext context = (JavaContext) fContext;
       switch (context.getCharacterBeforeStart()) {
         // high relevance after whitespace
         case ' ' :
index 570c0fa..78df545 100644 (file)
@@ -6,9 +6,10 @@ package net.sourceforge.phpdt.internal.ui.text.template;
 
 import java.util.ArrayList;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
+import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
@@ -24,7 +25,7 @@ import org.eclipse.swt.graphics.Point;
 public class IdentifierEngine {
 
   /** The context type. */
-  private ContextType fContextType;
+  private JavaContextType fContextType;
   /** The result proposals. */
   private ArrayList fProposals = new ArrayList();
 
@@ -32,7 +33,7 @@ public class IdentifierEngine {
    * Creates the template engine for a particular context type.
    * See <code>TemplateContext</code> for supported context types.
    */
-  public IdentifierEngine(ContextType contextType) {
+  public IdentifierEngine(JavaContextType contextType) {
     // Assert.isNotNull(contextType);
     fContextType = contextType;
   }
@@ -61,8 +62,7 @@ public class IdentifierEngine {
    * @param completionPosition the context position in the document of the text viewer
    * @param compilationUnit the compilation unit (may be <code>null</code>)
    */
-  public void complete(ITextViewer viewer, int completionPosition, Object[] identifiers)
-  //,ICompilationUnit compilationUnit)
+  public void complete(ITextViewer viewer, int completionPosition, Object[] identifiers,ICompilationUnit compilationUnit)
   //hrows JavaModelException
   {
     IDocument document = viewer.getDocument();
@@ -80,9 +80,12 @@ public class IdentifierEngine {
       }
     }
 
-    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y); //mpilationUnit);
+//    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y); //mpilationUnit);
 
-    PHPUnitContext context = (PHPUnitContext) fContextType.createContext();
+//    JavaContext context = (JavaContext) fContextType.createContext();
+    JavaContext context = (JavaContext) fContextType.createContext(document, completionPosition,selection.y,compilationUnit);
+    context.setVariable("selection", selectedText); //$NON-NLS-1$
+    
     int start = context.getStart();
     int end = context.getEnd();
     IRegion region = new Region(start, end - start);
index 32769cb..92d05eb 100644 (file)
@@ -3,17 +3,18 @@
  * All Rights Reserved.
  */
 package net.sourceforge.phpdt.internal.ui.text.template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateContext;
 import org.eclipse.swt.graphics.Image;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
 //import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI;
@@ -131,8 +132,8 @@ public class IdentifierProposal extends AbstractProposal { //implements
    * @see IJavaCompletionProposal#getRelevance()
    */
   public int getRelevance() {
-    if (fContext instanceof PHPUnitContext) {
-      PHPUnitContext context = (PHPUnitContext) fContext;
+    if (fContext instanceof JavaContext) {
+      JavaContext context = (JavaContext) fContext;
       switch (context.getCharacterBeforeStart()) {
         // high relevance after whitespace
         case ' ' :
index 605de48..66cd62c 100644 (file)
@@ -3,7 +3,6 @@
  * All Rights Reserved.
  */
 package net.sourceforge.phpdt.internal.ui.text.template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
@@ -13,6 +12,7 @@ import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateContext;
 import org.eclipse.swt.graphics.Image;
 /**
  * A PHP identifier proposal.
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateContentProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateContentProvider.java
deleted file mode 100644 (file)
index b42b7aa..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.ui.text.template;
-
-import net.sourceforge.phpdt.internal.corext.template.TemplateSet;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class TemplateContentProvider implements IStructuredContentProvider {
-
-       private TemplateSet fTemplateSet;       
-
-       /*
-        * @see IStructuredContentProvider#getElements(Object)
-        */     
-       public Object[] getElements(Object input) {
-               return fTemplateSet.getTemplates();
-       }
-
-       /*
-        * @see IContentProvider#inputChanged(Viewer, Object, Object)
-        */
-       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               fTemplateSet= (TemplateSet) newInput;
-       }
-
-       /*
-        * @see IContentProvider#dispose()
-        */
-       public void dispose() {
-               fTemplateSet= null;
-       }
-       
-}
-
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateEngine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateEngine.java
deleted file mode 100644 (file)
index 11dee2d..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.ui.text.template;
-
-import java.util.ArrayList;
-
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.Templates;
-import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
-import net.sourceforge.phpdt.internal.ui.PHPUiImages;
-import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.swt.graphics.Point;
-//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
-
-public class TemplateEngine {
-
-  /** The context type. */
-  private ContextType fContextType;
-  /** The result proposals. */
-  private ArrayList fProposals = new ArrayList();
-
-  /**
-   * Creates the template engine for a particular context type.
-   * See <code>TemplateContext</code> for supported context types.
-   */
-  public TemplateEngine(ContextType contextType) {
-    // Assert.isNotNull(contextType);
-    fContextType = contextType;
-  }
-
-  /**
-   * Empties the collector.
-   * 
-   * @param viewer the text viewer  
-   * @param unit   the compilation unit (may be <code>null</code>)
-   */
-  public void reset() {
-    fProposals.clear();
-  }
-
-  /**
-   * Returns the array of matching templates.
-   */
-  public IPHPCompletionProposal[] getResults() {
-    return (IPHPCompletionProposal[]) fProposals.toArray(new IPHPCompletionProposal[fProposals.size()]);
-  }
-
-  /**
-   * Inspects the context of the compilation unit around <code>completionPosition</code>
-   * and feeds the collector with proposals.
-   * @param viewer the text viewer
-   * @param completionPosition the context position in the document of the text viewer
-   * @param compilationUnit the compilation unit (may be <code>null</code>)
-   */
-  public void complete(ITextViewer viewer, int completionPosition)
-  //,ICompilationUnit compilationUnit)
-  //hrows JavaModelException
-  {
-    IDocument document = viewer.getDocument();
-
-    if (!(fContextType instanceof CompilationUnitContextType))
-      return;
-
-    Point selection = viewer.getSelectedRange();
-    // remember selected text
-    String selectedText = null;
-    if (selection.y != 0) {
-      try {
-        selectedText = document.get(selection.x, selection.y);
-      } catch (BadLocationException e) {
-      }
-    }
-
-    ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition, selection.y); //mpilationUnit);
-    DocumentTemplateContext context = (DocumentTemplateContext) fContextType.createContext();
-    int start = context.getStart();
-    int end = context.getEnd();
-    IRegion region = new Region(start, end - start);
-
-    Template[] templates = Templates.getInstance().getTemplates();
-    int maxProposals = PHPeclipsePlugin.MAX_PROPOSALS;
-
-    for (int i = 0; i != templates.length; i++)
-      if (context.canEvaluate(templates[i])) {
-        if (maxProposals-- < 0) {
-          return;
-        }
-        fProposals.add(new TemplateProposal(templates[i], context, region, viewer, PHPUiImages.get(PHPUiImages.IMG_OBJS_TEMPLATE)));
-      }
-  }
-
-}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateLabelProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateLabelProvider.java
deleted file mode 100644 (file)
index c8eb433..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.ui.text.template;
-
-import net.sourceforge.phpdt.internal.corext.template.Template;
-
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class TemplateLabelProvider implements ITableLabelProvider {
-
-       /*
-        * @see ITableLabelProvider#getColumnImage(Object, int)
-        */
-       public Image getColumnImage(Object element, int columnIndex) {
-               return null;
-       }
-
-       /*
-        * @see ITableLabelProvider#getColumnText(Object, int)
-        */
-       public String getColumnText(Object element, int columnIndex) {
-               Template template = (Template) element;
-               
-               switch (columnIndex) {
-                       case 0:
-                               return template.getName();
-                       case 1:
-                               return template.getContextTypeName();
-                       case 2:
-                               return template.getDescription();
-                       default:
-                               return null;
-               }
-       }
-
-       /*
-        * @see IBaseLabelProvider#addListener(ILabelProviderListener)
-        */
-       public void addListener(ILabelProviderListener listener) {
-       }
-
-       /*
-        * @see IBaseLabelProvider#dispose()
-        */
-       public void dispose() {
-       }
-
-       /*
-        * @see IBaseLabelProvider#isLabelProperty(Object, String)
-        */
-       public boolean isLabelProperty(Object element, String property) {
-               return false;
-       }
-
-       /*
-        * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
-        */
-       public void removeListener(ILabelProviderListener listener) {
-       }
-
-}
-
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateProposal.java
deleted file mode 100644 (file)
index 5f9911c..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.ui.text.template;
-
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
-import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
-import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.TemplatePosition;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPTemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
-import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
-import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionUI;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager;
-//import org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI;
-//import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
-
-/**
- * A template proposal.
- */
-public class TemplateProposal extends AbstractProposal {
-  private final TemplateContext fContext;
-  private final Image fImage;
-  private String fOldText;
-  private final IRegion fRegion;
-
-  private final Template fTemplate;
-
-  private TemplateBuffer fTemplateBuffer;
-
-  /**
-   * Creates a template proposal with a template and its context.
-   * @param template  the template
-   * @param context   the context in which the template was requested.
-   * @param image     the icon of the proposal.
-   */
-  public TemplateProposal(Template template, TemplateContext context, IRegion region, ITextViewer viewer, Image image) {
-    super(viewer);
-
-    fTemplate = template;
-    fContext = context;
-    //    fViewer = viewer;
-    fImage = image;
-    fRegion = region;
-  }
-
-  private static int getCaretOffset(TemplateBuffer buffer) {
-    TemplatePosition[] variables = buffer.getVariables();
-    for (int i = 0; i != variables.length; i++) {
-      TemplatePosition variable = variables[i];
-
-      if (variable.getName().equals(PHPTemplateMessages.getString("GlobalVariables.variable.name.cursor"))) //$NON-NLS-1$
-        return variable.getOffsets()[0];
-    }
-
-    return buffer.getString().length();
-  }
-
-  /*
-   * @see ICompletionProposal#apply(IDocument)
-   */
-  public void apply(IDocument document) {
-    try {
-      if (fTemplateBuffer == null)
-        fTemplateBuffer = fContext.evaluate(fTemplate);
-
-      int start = fRegion.getOffset();
-      int end = fRegion.getOffset() + fRegion.getLength();
-
-      // insert template string
-      String templateString = fTemplateBuffer.getString();
-      document.replace(start, end - start, templateString);
-
-      // translate positions
-      LinkedPositionManager manager = new LinkedPositionManager(document);
-      TemplatePosition[] variables = fTemplateBuffer.getVariables();
-      for (int i = 0; i != variables.length; i++) {
-        TemplatePosition variable = variables[i];
-
-        if (variable.isResolved())
-          continue;
-
-        int[] offsets = variable.getOffsets();
-        int length = variable.getLength();
-
-        for (int j = 0; j != offsets.length; j++)
-          manager.addPosition(offsets[j] + start, length);
-      }
-
-      LinkedPositionUI editor = new LinkedPositionUI(fViewer, manager);
-      editor.setFinalCaretOffset(getCaretOffset(fTemplateBuffer) + start);
-      editor.enter();
-
-      fSelectedRegion = editor.getSelectedRegion();
-
-    } catch (BadLocationException e) {
-      PHPeclipsePlugin.log(e);
-      openErrorDialog(e);
-
-    } catch (CoreException e) {
-      handleException(e);
-    }
-  }
-
-  /*
-   * @see ICompletionProposal#getAdditionalProposalInfo()
-   */
-  public String getAdditionalProposalInfo() {
-    try {
-      if (fTemplateBuffer == null)
-        fTemplateBuffer = fContext.evaluate(fTemplate);
-
-      return textToHTML(fTemplateBuffer.getString());
-
-    } catch (CoreException e) {
-      handleException(e);
-      return null;
-    }
-  }
-
-  /*
-   * @see ICompletionProposal#getContextInformation()
-   */
-  public IContextInformation getContextInformation() {
-    return null;
-  }
-
-  /*
-   * @see ICompletionProposal#getDisplayString()
-   */
-  public String getDisplayString() {
-    return fTemplate.getName() + TemplateMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); // $NON-NLS-1$ //$NON-NLS-1$
-  }
-
-  /*
-   * @see ICompletionProposal#getImage()
-   */
-  public Image getImage() {
-    return fImage;
-  }
-
-  /*
-   * @see IJavaCompletionProposal#getRelevance()
-   */
-  public int getRelevance() {
-
-    if (fContext instanceof PHPUnitContext) {
-      PHPUnitContext context = (PHPUnitContext) fContext;
-      switch (context.getCharacterBeforeStart()) {
-        // high relevance after whitespace
-        case ' ' :
-        case '\r' :
-        case '\n' :
-        case '\t' :
-          return 85;
-
-        default :
-          return 0;
-      }
-    } else {
-      return 90;
-    }
-  }
-
-}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/InclusivePositionUpdater.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/InclusivePositionUpdater.java
new file mode 100644 (file)
index 0000000..c88cb9f
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.Position;
+
+/**
+ * Position updater that takes any change in [position.offset, position.offset + position.length] as
+ * belonging to the position.
+ * 
+ * @since 3.0
+ */
+class InclusivePositionUpdater implements IPositionUpdater {
+
+       /** The position category. */
+       private final String fCategory;
+
+       /**
+        * Creates a new updater for the given <code>category</code>.
+        * 
+        * @param category the new category.
+        */
+       public InclusivePositionUpdater(String category) {
+               fCategory= category;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void update(DocumentEvent event) {
+
+               int eventOffset= event.getOffset();
+               int eventOldLength= event.getLength();
+               int eventNewLength= event.getText() == null ? 0 : event.getText().length();
+               int deltaLength= eventNewLength - eventOldLength;
+
+               try {
+                       Position[] positions= event.getDocument().getPositions(fCategory);
+
+                       for (int i= 0; i != positions.length; i++) {
+
+                               Position position= positions[i];
+
+                               if (position.isDeleted())
+                                       continue;
+
+                               int offset= position.getOffset();
+                               int length= position.getLength();
+                               int end= offset + length;
+
+                               if (offset > eventOffset + eventOldLength) 
+                                       // position comes way
+                                       // after change - shift
+                                       position.setOffset(offset + deltaLength);
+                               else if (end < eventOffset) {
+                                       // position comes way before change -
+                                       // leave alone
+                               } else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
+                                       // event completely internal to the position - adjust length
+                                       position.setLength(length + deltaLength);
+                               } else if (offset < eventOffset) {
+                                       // event extends over end of position - adjust length
+                                       int newEnd= eventOffset + eventNewLength;
+                                       position.setLength(newEnd - offset);
+                               } else if (end > eventOffset + eventOldLength) {
+                                       // event extends from before position into it - adjust offset
+                                       // and length
+                                       // offset becomes end of event, length ajusted acordingly
+                                       // we want to recycle the overlapping part
+                                       position.setOffset(eventOffset);
+                                       int deleted= eventOffset + eventOldLength - offset;
+                                       position.setLength(length - deleted + eventNewLength);
+                               } else {
+                                       // event consumes the position - delete it
+                                       position.delete();
+                               }
+                       }
+               } catch (BadPositionCategoryException e) {
+                       // ignore and return
+               }
+       }
+
+       /**
+        * Returns the position category.
+        * 
+        * @return the position category
+        */
+       public String getCategory() {
+               return fCategory;
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/MultiVariable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/MultiVariable.java
new file mode 100644 (file)
index 0000000..c9a6572
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.templates.TemplateVariable;
+
+
+/**
+ * 
+ */
+public class MultiVariable extends TemplateVariable {
+       private final Map fValueMap= new HashMap();
+       private Object fSet;
+       private Object fDefaultKey= null;
+       
+       public MultiVariable(String type, String defaultValue, int[] offsets) {
+               super(type, defaultValue, offsets);
+               fValueMap.put(fDefaultKey, new String[] { defaultValue });
+               fSet= getDefaultValue();
+       }
+       
+       /**
+        * Sets the values of this variable under a specific set.
+        * 
+        * @param set the set identifier for which the values are valid
+        * @param values the possible values of this variable
+        */
+       public void setValues(Object set, String[] values) {
+               Assert.isNotNull(set);
+               Assert.isTrue(values.length > 0);
+               fValueMap.put(set, values);
+               if (fDefaultKey == null) {
+                       fDefaultKey= set;
+                       fSet= getDefaultValue();
+               }
+       }
+       
+       
+       /*
+        * @see org.eclipse.jface.text.templates.TemplateVariable#setValues(java.lang.String[])
+        */
+       public void setValues(String[] values) {
+               if (fValueMap != null) {
+                       Assert.isNotNull(values);
+                       Assert.isTrue(values.length > 0);
+                       fValueMap.put(fDefaultKey, values);
+                       fSet= getDefaultValue();
+               }
+       }
+       
+       
+       /*
+        * @see org.eclipse.jface.text.templates.TemplateVariable#getValues()
+        */
+       public String[] getValues() {
+               return (String[]) fValueMap.get(fDefaultKey);
+       }
+       
+       /**
+        * Returns the choices for the set identified by <code>set</code>.
+        * 
+        * @param set the set identifier
+        * @return the choices for this variable and the given set, or
+        *         <code>null</code> if the set is not defined.
+        */
+       public String[] getValues(Object set) {
+               return (String[]) fValueMap.get(set);
+       }
+
+       /**
+        * @return
+        */
+       public Object getSet() {
+               return fSet;
+       }
+       
+       public void setSet(Object set) {
+               fSet= set;
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/MultiVariableGuess.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/MultiVariableGuess.java
new file mode 100644 (file)
index 0000000..673e4b9
--- /dev/null
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+
+/**
+ * Global state for templates. Selecting a proposal for the master template variable
+ * will cause the value (and the proposals) for the slave variables to change.
+ * 
+ * @see MultiVariable
+ */
+public class MultiVariableGuess {
+       
+       /**
+        * Implementation of the <code>ICompletionProposal</code> interface and extension.
+        */
+       class Proposal implements ICompletionProposal, ICompletionProposalExtension2 {
+               
+               /** The string to be displayed in the completion proposal popup */
+               private String fDisplayString;
+               /** The replacement string */
+               String fReplacementString;
+               /** The replacement offset */
+               private int fReplacementOffset;
+               /** The replacement length */
+               private int fReplacementLength;
+               /** The cursor position after this proposal has been applied */
+               private int fCursorPosition;
+               /** The image to be displayed in the completion proposal popup */
+               private Image fImage;
+               /** The context information of this proposal */
+               private IContextInformation fContextInformation;
+               /** The additional info of this proposal */
+               private String fAdditionalProposalInfo;
+
+               /**
+                * Creates a new completion proposal based on the provided information.  The replacement string is
+                * considered being the display string too. All remaining fields are set to <code>null</code>.
+                *
+                * @param replacementString the actual string to be inserted into the document
+                * @param replacementOffset the offset of the text to be replaced
+                * @param replacementLength the length of the text to be replaced
+                * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+                */
+               public Proposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition) {
+                       this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null);
+               }
+
+               /**
+                * Creates a new completion proposal. All fields are initialized based on the provided information.
+                *
+                * @param replacementString the actual string to be inserted into the document
+                * @param replacementOffset the offset of the text to be replaced
+                * @param replacementLength the length of the text to be replaced
+                * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+                * @param image the image to display for this proposal
+                * @param displayString the string to be displayed for the proposal
+                * @param contextInformation the context information associated with this proposal
+                * @param additionalProposalInfo the additional information associated with this proposal
+                */
+               public Proposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
+                       Assert.isNotNull(replacementString);
+                       Assert.isTrue(replacementOffset >= 0);
+                       Assert.isTrue(replacementLength >= 0);
+                       Assert.isTrue(cursorPosition >= 0);
+                       
+                       fReplacementString= replacementString;
+                       fReplacementOffset= replacementOffset;
+                       fReplacementLength= replacementLength;
+                       fCursorPosition= cursorPosition;
+                       fImage= image;
+                       fDisplayString= displayString;
+                       fContextInformation= contextInformation;
+                       fAdditionalProposalInfo= additionalProposalInfo;
+               }
+
+               /*
+                * @see ICompletionProposal#apply(IDocument)
+                */
+               public void apply(IDocument document) {
+                       try {
+                               document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
+                       } catch (BadLocationException x) {
+                               // ignore
+                       }
+               }
+               
+               /*
+                * @see ICompletionProposal#getSelection(IDocument)
+                */
+               public Point getSelection(IDocument document) {
+                       return new Point(fReplacementOffset + fCursorPosition, 0);
+               }
+
+               /*
+                * @see ICompletionProposal#getContextInformation()
+                */
+               public IContextInformation getContextInformation() {
+                       return fContextInformation;
+               }
+
+               /*
+                * @see ICompletionProposal#getImage()
+                */
+               public Image getImage() {
+                       return fImage;
+               }
+
+               /*
+                * @see ICompletionProposal#getDisplayString()
+                */
+               public String getDisplayString() {
+                       if (fDisplayString != null)
+                               return fDisplayString;
+                       return fReplacementString;
+               }
+
+               /*
+                * @see ICompletionProposal#getAdditionalProposalInfo()
+                */
+               public String getAdditionalProposalInfo() {
+                       return fAdditionalProposalInfo;
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
+                */
+               public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+                       apply(viewer.getDocument());
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
+                */
+               public void selected(ITextViewer viewer, boolean smartToggle) {
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
+                */
+               public void unselected(ITextViewer viewer) {
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+                */
+               public boolean validate(IDocument document, int offset, DocumentEvent event) {
+                       try {
+                               String content= document.get(fReplacementOffset, fReplacementLength);
+                               if (content.startsWith(fReplacementString))
+                                       return true;
+                       } catch (BadLocationException e) {
+                               // ignore concurrently modified document
+                       }
+                       return false;
+               }
+       }
+       
+       private final List fSlaves= new ArrayList();
+       
+       private MultiVariable fMaster;
+
+       /**
+        * @param mv
+        */
+       public MultiVariableGuess(MultiVariable mv) {
+               fMaster= mv;
+       }
+
+       /**
+        * @param variable
+        * @return
+        */
+       public ICompletionProposal[] getProposals(MultiVariable variable, int offset, int length) {
+               if (variable.equals(fMaster)) {
+                       String[] choices= variable.getValues();
+                       
+                       ICompletionProposal[] ret= new ICompletionProposal[choices.length];
+                       for (int i= 0; i < ret.length; i++) {
+                               ret[i]= new Proposal(choices[i], offset, length, offset + length) {
+                                       
+                                       /*
+                                        * @see org.eclipse.jface.text.link.MultiVariableGuess.Proposal#apply(org.eclipse.jface.text.IDocument)
+                                        */
+                                       public void apply(IDocument document) {
+                                               super.apply(document);
+
+                                               try {
+                                                       Object old= fMaster.getSet();
+                                                       fMaster.setSet(fReplacementString);
+                                                       if (!fReplacementString.equals(old)) {
+                                                               for (Iterator it= fSlaves.iterator(); it.hasNext();) {
+                                                                       VariablePosition pos= (VariablePosition) it.next();
+                                                                       String[] values= pos.getVariable().getValues(fReplacementString);
+                                                                       if (values != null)
+                                                                               document.replace(pos.getOffset(), pos.getLength(), values[0]);
+                                                               }
+                                                       }
+                                               } catch (BadLocationException e) {
+                                                       // ignore and continue
+                                               }
+
+                                       }
+                               };
+                       }
+                       
+                       return ret;
+                       
+               } else {
+               
+                       String[] choices= variable.getValues(fMaster.getSet());
+                       
+                       if (choices == null || choices.length < 2)
+                               return null;
+                       
+                       ICompletionProposal[] ret= new ICompletionProposal[choices.length];
+                       for (int i= 0; i < ret.length; i++) {
+                               ret[i]= new Proposal(choices[i], offset, length, offset + length);
+                       }
+                       
+                       return ret;
+               }
+       }
+
+       /**
+        * @param position
+        */
+       public void addSlave(VariablePosition position) {
+               fSlaves.add(position);
+       }
+
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/PositionBasedCompletionProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/PositionBasedCompletionProposal.java
new file mode 100644 (file)
index 0000000..dd9d5c1
--- /dev/null
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+
+/**
+ * An enhanced implementation of the <code>ICompletionProposal</code> interface implementing all the extension interfaces.
+ * It uses a position to track its replacement offset and length. The position must be set up externally.
+ */
+public class PositionBasedCompletionProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2 {
+       
+       /** The string to be displayed in the completion proposal popup */
+       private String fDisplayString;
+       /** The replacement string */
+       private String fReplacementString;
+       /** The replacement position. */
+       private Position fReplacementPosition;
+       /** The cursor position after this proposal has been applied */
+       private int fCursorPosition;
+       /** The image to be displayed in the completion proposal popup */
+       private Image fImage;
+       /** The context information of this proposal */
+       private IContextInformation fContextInformation;
+       /** The additional info of this proposal */
+       private String fAdditionalProposalInfo;
+       
+       /**
+        * Creates a new completion proposal based on the provided information.  The replacement string is
+        * considered being the display string too. All remaining fields are set to <code>null</code>.
+        *
+        * @param replacementString the actual string to be inserted into the document
+        * @param replacementPosition the position of the text to be replaced
+        * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+        */
+       public PositionBasedCompletionProposal(String replacementString, Position replacementPosition, int cursorPosition) {
+               this(replacementString, replacementPosition, cursorPosition, null, null, null, null);
+       }
+       
+       /**
+        * Creates a new completion proposal. All fields are initialized based on the provided information.
+        *
+        * @param replacementString the actual string to be inserted into the document
+        * @param replacementPosition the position of the text to be replaced
+        * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+        * @param image the image to display for this proposal
+        * @param displayString the string to be displayed for the proposal
+        * @param contextInformation the context information associated with this proposal
+        * @param additionalProposalInfo the additional information associated with this proposal
+        */
+       public PositionBasedCompletionProposal(String replacementString, Position replacementPosition, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
+               Assert.isNotNull(replacementString);
+               Assert.isTrue(replacementPosition != null);
+               
+               fReplacementString= replacementString;
+               fReplacementPosition= replacementPosition;
+               fCursorPosition= cursorPosition;
+               fImage= image;
+               fDisplayString= displayString;
+               fContextInformation= contextInformation;
+               fAdditionalProposalInfo= additionalProposalInfo;
+       }
+       
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public void apply(IDocument document) {
+               try {
+                       document.replace(fReplacementPosition.getOffset(), fReplacementPosition.getLength(), fReplacementString);
+               } catch (BadLocationException x) {
+                       // ignore
+               }
+       }
+       
+       /*
+        * @see ICompletionProposal#getSelection(IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               return new Point(fReplacementPosition.getOffset() + fCursorPosition, 0);
+       }
+       
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return fContextInformation;
+       }
+       
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return fImage;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               if (fDisplayString != null)
+                       return fDisplayString;
+               return fReplacementString;
+       }
+       
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return fAdditionalProposalInfo;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
+        */
+       public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+               apply(viewer.getDocument());
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
+        */
+       public void selected(ITextViewer viewer, boolean smartToggle) {
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
+        */
+       public void unselected(ITextViewer viewer) {
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+        */
+       public boolean validate(IDocument document, int offset, DocumentEvent event) {
+               try {
+                       String content= document.get(fReplacementPosition.getOffset(), fReplacementPosition.getLength());
+                       if (content.startsWith(fReplacementString))
+                               return true;
+               } catch (BadLocationException e) {
+                       // ignore concurrently modified document
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#apply(org.eclipse.jface.text.IDocument, char, int)
+        */
+       public void apply(IDocument document, char trigger, int offset) {
+               // not called any more
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#isValidFor(org.eclipse.jface.text.IDocument, int)
+        */
+       public boolean isValidFor(IDocument document, int offset) {
+               // not called any more
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getTriggerCharacters()
+        */
+       public char[] getTriggerCharacters() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getContextInformationPosition()
+        */
+       public int getContextInformationPosition() {
+               return fReplacementPosition.getOffset();
+       }
+       
+}
+
@@ -1,19 +1,25 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.php;
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
 
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-public class PHPTemplateMessages {
+class TemplateContentAssistMessages {
 
-       private static final String RESOURCE_BUNDLE= PHPTemplateMessages.class.getName();
+       private static final String RESOURCE_BUNDLE= TemplateContentAssistMessages.class.getName();
        private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
 
-       private PHPTemplateMessages() {
+       private TemplateContentAssistMessages() {
        }
 
        public static String getString(String key) {
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateContentAssistMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateContentAssistMessages.properties
new file mode 100644 (file)
index 0000000..3664fd8
--- /dev/null
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2000, 2004 IBM Corporation and others.
+# 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
+###############################################################################
+
+# template proposal
+TemplateProposal.delimiter=\ - 
+
+# template evaluator
+TemplateEvaluator.error.title=Template Evaluation Error
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateEngine.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateEngine.java
new file mode 100644 (file)
index 0000000..2303b47
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import java.util.ArrayList;
+
+import net.sourceforge.phpdt.core.ICompilationUnit;
+import net.sourceforge.phpdt.internal.corext.Assert;
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
+import net.sourceforge.phpdt.internal.ui.PHPUiImages;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.swt.graphics.Point;
+
+public class TemplateEngine {
+
+       private static final String $_LINE_SELECTION= "${" + GlobalTemplateVariables.LineSelection.NAME + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String $_WORD_SELECTION= "${" + GlobalTemplateVariables.WordSelection.NAME + "}"; //$NON-NLS-1$ //$NON-NLS-2$
+
+       /** The context type. */
+       private TemplateContextType fContextType;
+       /** The result proposals. */
+       private ArrayList fProposals= new ArrayList();
+
+       /**
+        * Creates the template engine for a particular context type.
+        * See <code>TemplateContext</code> for supported context types.
+        */
+       public TemplateEngine(TemplateContextType contextType) {
+               Assert.isNotNull(contextType);
+               fContextType= contextType;
+       }
+
+       /**
+        * Empties the collector.
+        */
+       public void reset() {
+               fProposals.clear();
+       }
+
+       /**
+        * Returns the array of matching templates.
+        */
+       public TemplateProposal[] getResults() {
+               return (TemplateProposal[]) fProposals.toArray(new TemplateProposal[fProposals.size()]);
+       }
+
+       /**
+        * Inspects the context of the compilation unit around <code>completionPosition</code>
+        * and feeds the collector with proposals.
+        * @param viewer the text viewer
+        * @param completionPosition the context position in the document of the text viewer
+        * @param compilationUnit the compilation unit (may be <code>null</code>)
+        */
+       public void complete(ITextViewer viewer, int completionPosition, ICompilationUnit compilationUnit) {
+           IDocument document= viewer.getDocument();
+           
+               if (!(fContextType instanceof CompilationUnitContextType))
+                       return;
+
+               Point selection= viewer.getSelectedRange();
+
+               // remember selected text
+               String selectedText= null;
+               if (selection.y != 0) {
+                       try {
+                               selectedText= document.get(selection.x, selection.y);
+                       } catch (BadLocationException e) {}
+               }
+
+               
+               CompilationUnitContext context= ((CompilationUnitContextType) fContextType).createContext(document, completionPosition, selection.y, compilationUnit);
+               context.setVariable("selection", selectedText); //$NON-NLS-1$
+               int start= context.getStart();
+               int end= context.getEnd();
+               IRegion region= new Region(start, end - start);
+
+               Template[] templates= PHPeclipsePlugin.getDefault().getTemplateStore().getTemplates(); 
+
+               if (selection.y == 0) {
+                       for (int i= 0; i != templates.length; i++)
+                               if (context.canEvaluate(templates[i]))
+                                       fProposals.add(new TemplateProposal(templates[i], context, region, PHPUiImages.get(PHPUiImages.IMG_OBJS_TEMPLATE)));
+
+               } else {
+
+                       if (context.getKey().length() == 0)
+                               context.setForceEvaluation(true);
+
+                       boolean multipleLinesSelected= areMultipleLinesSelected(viewer);
+                               
+                       for (int i= 0; i != templates.length; i++) {
+                               Template template= templates[i];                                
+                               if (context.canEvaluate(template) &&
+                                       template.getContextTypeId().equals(context.getContextType().getId()) &&                         
+                                       (!multipleLinesSelected && template.getPattern().indexOf($_WORD_SELECTION) != -1 || (multipleLinesSelected && template.getPattern().indexOf($_LINE_SELECTION) != -1)))
+                               {
+                                       fProposals.add(new TemplateProposal(templates[i], context, region, PHPUiImages.get(PHPUiImages.IMG_OBJS_TEMPLATE)));
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Returns <code>true</code> if one line is completely selected or if multiple lines are selected.
+        * Being completely selected means that all characters except the new line characters are 
+        * selected.
+        * 
+        * @return <code>true</code> if one or multiple lines are selected
+        * @since 2.1
+        */
+       private boolean areMultipleLinesSelected(ITextViewer viewer) {
+               if (viewer == null)
+                       return false;
+               
+               Point s= viewer.getSelectedRange();
+               if (s.y == 0)
+                       return false;
+                       
+               try {
+                       
+                       IDocument document= viewer.getDocument();
+                       int startLine= document.getLineOfOffset(s.x);
+                       int endLine= document.getLineOfOffset(s.x + s.y);
+                       IRegion line= document.getLineInformation(startLine);
+                       return startLine != endLine || (s.x == line.getOffset() && s.y == line.getLength());
+               
+               } catch (BadLocationException x) {
+                       return false;
+               }
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateInformationControlCreator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateInformationControlCreator.java
new file mode 100644 (file)
index 0000000..2a10036
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IInformationControlCreatorExtension;
+
+import net.sourceforge.phpdt.internal.ui.text.java.hover.SourceViewerInformationControl;
+
+
+final public class TemplateInformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension {
+       
+       private SourceViewerInformationControl fControl;
+       
+       public TemplateInformationControlCreator()  {
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+        */
+       public IInformationControl createInformationControl(Shell parent) {
+               fControl= new SourceViewerInformationControl(parent);
+               fControl.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent e) {
+                               fControl= null;
+                       }
+               });
+               return fControl;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl)
+        */
+       public boolean canReuse(IInformationControl control) {
+               return fControl == control && fControl != null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator)
+        */
+       public boolean canReplace(IInformationControlCreator creator) {
+               return (creator != null && getClass() == creator.getClass());
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateProposal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateProposal.java
new file mode 100644 (file)
index 0000000..4ca7d17
--- /dev/null
@@ -0,0 +1,435 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
+import net.sourceforge.phpdt.internal.ui.util.ExceptionHandler;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.phpeditor.EditorHighlightingSynchronizer;
+import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedModeUI;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.jface.text.link.ProposalPosition;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+
+/**
+ * A template proposal.
+ */
+public class TemplateProposal implements IPHPCompletionProposal, ICompletionProposalExtension2, ICompletionProposalExtension3 {
+
+       private final Template fTemplate;
+       private final TemplateContext fContext;
+       private final Image fImage;
+       private IRegion fRegion;
+       private int fRelevance;
+
+       private IRegion fSelectedRegion; // initialized by apply()
+       private String fDisplayString;
+               
+       /**
+        * Creates a template proposal with a template and its context.
+        * 
+        * @param template  the template
+        * @param context   the context in which the template was requested
+        * @param region        the region this proposal applies to
+        * @param image     the icon of the proposal
+        */     
+       public TemplateProposal(Template template, TemplateContext context, IRegion region, Image image) {
+               Assert.isNotNull(template);
+               Assert.isNotNull(context);
+               Assert.isNotNull(region);
+               
+               fTemplate= template;
+               fContext= context;
+               fImage= image;
+               fRegion= region;
+               
+               fDisplayString= null;
+               
+               if (context instanceof JavaContext) {
+                       switch (((JavaContext) context).getCharacterBeforeStart()) {
+                       // high relevance after whitespace
+                       case ' ':
+                       case '\r':
+                       case '\n':
+                       case '\t':
+                               fRelevance= 90;
+                               break;
+                       default:
+                               fRelevance= 0;
+                       }
+               } else {
+                       fRelevance= 90;                 
+               }               
+       }
+
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public final void apply(IDocument document) {
+               // not called anymore
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
+        */
+       public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+
+               try {
+                       
+                       fContext.setReadOnly(false);
+                       TemplateBuffer templateBuffer;
+                       try {
+                               templateBuffer= fContext.evaluate(fTemplate);
+                       } catch (TemplateException e1) {
+                               fSelectedRegion= fRegion;
+                               return;
+                       }
+                       
+                       int start= getReplaceOffset();
+                       int end= getReplaceEndOffset();
+                       end= Math.max(end, offset);
+                       
+                       // insert template string
+                       IDocument document= viewer.getDocument();
+                       String templateString= templateBuffer.getString();      
+                       document.replace(start, end - start, templateString);   
+                       
+                       // translate positions
+                       LinkedModeModel model= new LinkedModeModel();
+                       TemplateVariable[] variables= templateBuffer.getVariables();
+                       
+                       MultiVariableGuess guess= fContext instanceof CompilationUnitContext ? ((CompilationUnitContext) fContext).getMultiVariableGuess() : null;
+               
+                       boolean hasPositions= false;
+                       for (int i= 0; i != variables.length; i++) {
+                               TemplateVariable variable= variables[i];
+
+                               if (variable.isUnambiguous())
+                                       continue;
+                               
+                               LinkedPositionGroup group= new LinkedPositionGroup();
+                               
+                               int[] offsets= variable.getOffsets();
+                               int length= variable.getLength();
+                               
+                               LinkedPosition first;
+                               if (guess != null && variable instanceof MultiVariable) {
+                                       first= new VariablePosition(document, offsets[0] + start, length, guess, (MultiVariable) variable);
+                                       guess.addSlave((VariablePosition) first);
+                               } else {
+                                       String[] values= variable.getValues();
+                                       ICompletionProposal[] proposals= new ICompletionProposal[values.length];
+                                       for (int j= 0; j < values.length; j++) {
+                                               ensurePositionCategoryInstalled(document, model);
+                                               Position pos= new Position(offsets[0] + start, length);
+                                               document.addPosition(getCategory(), pos);
+                                               proposals[j]= new PositionBasedCompletionProposal(values[j], pos, length);
+                                       }
+                                       
+                                       if (proposals.length > 1)
+                                               first= new ProposalPosition(document, offsets[0] + start, length, proposals);
+                                       else
+                                               first= new LinkedPosition(document, offsets[0] + start, length);
+                               }
+                               
+                               for (int j= 0; j != offsets.length; j++)
+                                       if (j == 0)
+                                               group.addPosition(first);
+                                       else
+                                               group.addPosition(new LinkedPosition(document, offsets[j] + start, length));
+                               
+                               model.addGroup(group);
+                               hasPositions= true;
+                       }
+                       
+                       if (hasPositions) {
+                               model.forceInstall();
+                               PHPEditor editor= getJavaEditor();
+                               if (editor != null) {
+                                       model.addLinkingListener(new EditorHighlightingSynchronizer(editor));
+                               }
+                               
+                               LinkedModeUI ui= new EditorLinkedModeUI(model, viewer);
+                               ui.setExitPosition(viewer, getCaretOffset(templateBuffer) + start, 0, Integer.MAX_VALUE);
+                               ui.enter();
+                               
+                               fSelectedRegion= ui.getSelectedRegion();
+                       } else
+                               fSelectedRegion= new Region(getCaretOffset(templateBuffer) + start, 0);
+                       
+               } catch (BadLocationException e) {
+                 PHPeclipsePlugin.log(e);
+                       openErrorDialog(viewer.getTextWidget().getShell(), e);              
+                       fSelectedRegion= fRegion;
+               } catch (BadPositionCategoryException e) {
+                 PHPeclipsePlugin.log(e);
+                       openErrorDialog(viewer.getTextWidget().getShell(), e);              
+                       fSelectedRegion= fRegion;
+               }
+
+       }       
+       
+       /**
+        * Returns the currently active java editor, or <code>null</code> if it 
+        * cannot be determined.
+        * 
+        * @return  the currently active java editor, or <code>null</code>
+        */
+       private PHPEditor getJavaEditor() {
+               IEditorPart part= PHPeclipsePlugin.getActivePage().getActiveEditor();
+               if (part instanceof PHPEditor)
+                       return (PHPEditor) part;
+               else
+                       return null;
+       }
+
+       /**
+        * Returns the offset of the range in the document that will be replaced by
+        * applying this template.
+        * 
+        * @return the offset of the range in the document that will be replaced by
+        *         applying this template
+        */
+       private int getReplaceOffset() {
+               int start;
+               if (fContext instanceof DocumentTemplateContext) {
+                       DocumentTemplateContext docContext = (DocumentTemplateContext)fContext;
+                       start= docContext.getStart();
+               } else {
+                       start= fRegion.getOffset();
+               }
+               return start;
+       }
+
+       /**
+        * Returns the end offset of the range in the document that will be replaced
+        * by applying this template.
+        * 
+        * @return the end offset of the range in the document that will be replaced
+        *         by applying this template
+        */
+       private int getReplaceEndOffset() {
+               int end;
+               if (fContext instanceof DocumentTemplateContext) {
+                       DocumentTemplateContext docContext = (DocumentTemplateContext)fContext;
+                       end= docContext.getEnd();
+               } else {
+                       end= fRegion.getOffset() + fRegion.getLength();
+               }
+               return end;
+       }
+
+       private void ensurePositionCategoryInstalled(final IDocument document, LinkedModeModel model) {
+               if (!document.containsPositionCategory(getCategory())) {
+                       document.addPositionCategory(getCategory());
+                       final InclusivePositionUpdater updater= new InclusivePositionUpdater(getCategory());
+                       document.addPositionUpdater(updater);
+                       
+                       model.addLinkingListener(new ILinkedModeListener() {
+
+                               /*
+                                * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
+                                */
+                               public void left(LinkedModeModel environment, int flags) {
+                                       try {
+                                               document.removePositionCategory(getCategory());
+                                       } catch (BadPositionCategoryException e) {
+                                               // ignore
+                                       }
+                                       document.removePositionUpdater(updater);
+                               }
+
+                               public void suspend(LinkedModeModel environment) {}
+                               public void resume(LinkedModeModel environment, int flags) {}
+                       });
+               }
+       }
+
+       private String getCategory() {
+               return "TemplateProposalCategory_" + toString(); //$NON-NLS-1$
+       }
+
+       private int getCaretOffset(TemplateBuffer buffer) {
+       
+           TemplateVariable[] variables= buffer.getVariables();
+               for (int i= 0; i != variables.length; i++) {
+                       TemplateVariable variable= variables[i];
+                       if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME))
+                               return variable.getOffsets()[0];
+               }
+
+               return buffer.getString().length();
+       }
+       
+       /*
+        * @see ICompletionProposal#getSelection(IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
+       }
+
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+           try {
+                   fContext.setReadOnly(true);
+                       TemplateBuffer templateBuffer;
+                       try {
+                               templateBuffer= fContext.evaluate(fTemplate);
+                       } catch (TemplateException e1) {
+                               return null;
+                       }
+
+                       return templateBuffer.getString();
+
+           } catch (BadLocationException e) {
+                       handleException(PHPeclipsePlugin.getActiveWorkbenchShell(), new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.getPluginId(), IStatus.OK, "", e))); //$NON-NLS-1$
+                       return null;
+               }
+       }
+
+       /*
+        * @see ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               if (fDisplayString == null) {
+                       fDisplayString= fTemplate.getName() + TemplateContentAssistMessages.getString("TemplateProposal.delimiter") + fTemplate.getDescription(); //$NON-NLS-1$
+               }
+               return fDisplayString;
+       }
+       
+       public void setDisplayString(String displayString) {
+               fDisplayString= displayString;
+       }       
+
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return fImage;
+       }
+
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return null;
+       }
+
+       private void openErrorDialog(Shell shell, Exception e) {
+               MessageDialog.openError(shell, TemplateContentAssistMessages.getString("TemplateEvaluator.error.title"), e.getMessage()); //$NON-NLS-1$
+       }
+
+       private void handleException(Shell shell, CoreException e) {
+               ExceptionHandler.handle(e, shell, TemplateContentAssistMessages.getString("TemplateEvaluator.error.title"), null); //$NON-NLS-1$
+       }
+
+       /*
+        * @see IJavaCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+               return fRelevance;
+       }
+
+       public void setRelevance(int relevance) {
+               fRelevance= relevance;
+       }
+       
+       public Template getTemplate() {
+               return fTemplate;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
+        */
+       public IInformationControlCreator getInformationControlCreator() {
+               return new TemplateInformationControlCreator();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
+        */
+       public void selected(ITextViewer viewer, boolean smartToggle) {
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
+        */
+       public void unselected(ITextViewer viewer) {
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+        */
+       public boolean validate(IDocument document, int offset, DocumentEvent event) {
+               try {
+                       int replaceOffset= getReplaceOffset();
+                       if (offset >= replaceOffset) {
+                               String content= document.get(replaceOffset, offset - replaceOffset);
+                               return fTemplate.getName().startsWith(content);
+                       }
+               } catch (BadLocationException e) {
+                       // concurrent modification - ignore
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getReplacementString()
+        */
+       public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
+               return fTemplate.getName();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getReplacementOffset()
+        */
+       public int getPrefixCompletionStart(IDocument document, int completionOffset) {
+               return getReplaceOffset();
+       }
+}
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/VariablePosition.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/VariablePosition.java
new file mode 100644 (file)
index 0000000..5edace0
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.jface.text.link.ProposalPosition;
+
+
+/**
+ * 
+ */
+public class VariablePosition extends ProposalPosition {
+
+       private MultiVariableGuess fGuess;
+       private MultiVariable fVariable;
+
+       public VariablePosition(IDocument document, int offset, int length, MultiVariableGuess guess, MultiVariable variable) {
+               this(document, offset, length, LinkedPositionGroup.NO_STOP, guess, variable);
+       }
+       
+       public VariablePosition(IDocument document, int offset, int length, int sequence, MultiVariableGuess guess, MultiVariable variable) {
+               super(document, offset, length, sequence, null);
+               Assert.isNotNull(guess);
+               Assert.isNotNull(variable);
+               fVariable= variable;
+               fGuess= guess;
+       }
+       
+       
+       /*
+        * @see org.eclipse.jface.text.link.ProposalPosition#equals(java.lang.Object)
+        */
+       public boolean equals(Object o) {
+               if (o instanceof VariablePosition && super.equals(o)) {
+                       return fGuess.equals(((VariablePosition) o).fGuess);
+               }
+               return false;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.link.ProposalPosition#hashCode()
+        */
+       public int hashCode() {
+               return super.hashCode() | fGuess.hashCode();
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.link.ProposalPosition#getChoices()
+        */
+       public ICompletionProposal[] getChoices() {
+               return fGuess.getProposals(fVariable, offset, length);
+       }
+
+       /**
+        * @return
+        */
+       public MultiVariable getVariable() {
+               return fVariable;
+       }
+       
+}
@@ -1,19 +1,25 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.php;
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.preferences;
 
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-public class PHPTemplateMessages {
+class TemplatePreferencesMessages {
 
-       private static final String RESOURCE_BUNDLE= PHPTemplateMessages.class.getName();
+       private static final String RESOURCE_BUNDLE= TemplatePreferencesMessages.class.getName();
        private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
 
-       private PHPTemplateMessages() {
+       private TemplatePreferencesMessages() {
        }
 
        public static String getString(String key) {
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/preferences/TemplatePreferencesMessages.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/preferences/TemplatePreferencesMessages.properties
new file mode 100644 (file)
index 0000000..4cfe7bd
--- /dev/null
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2000, 2004 IBM Corporation and others.
+# 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
+###############################################################################
+
+TemplateVariableProposal.error.title=Error applying template variable proposal
@@ -1,4 +1,14 @@
-package net.sourceforge.phpdt.internal.ui.text.template;
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.preferences;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -6,14 +16,15 @@ import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.TemplateVariable;
-
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.ICompletionProposal;
 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
 import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+
 
 public class TemplateVariableProcessor implements IContentAssistProcessor {    
 
@@ -32,15 +43,22 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
 
        
        /** the context type */
-       private ContextType fContextType;
+       private TemplateContextType fContextType;
        
        /**
         * Sets the context type.
         */
-       public void setContextType(ContextType contextType) {
+       public void setContextType(TemplateContextType contextType) {
                fContextType= contextType;      
        }
        
+       /**
+        * Gets the context type.
+        */
+       public TemplateContextType getContextType() {
+               return fContextType;    
+       }       
+       
        /*
         * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
         */
@@ -63,10 +81,10 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
                int offset= start;
                int length= end - start;
 
-               for (Iterator iterator= fContextType.variableIterator(); iterator.hasNext(); ) {
-                       TemplateVariable variable= (TemplateVariable) iterator.next();
+               for (Iterator iterator= fContextType.resolvers(); iterator.hasNext(); ) {
+                       TemplateVariableResolver variable= (TemplateVariableResolver) iterator.next();
 
-                       if (prefix == null || variable.getName().startsWith(prefix))
+                       if (prefix == null || variable.getType().startsWith(prefix))
                                proposals.add(new TemplateVariableProposal(variable, offset, length, viewer));
                }
 
@@ -1,11 +1,15 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.ui.text.template;
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.preferences;
 
-import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
-import net.sourceforge.phpdt.internal.corext.template.TemplateVariable;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.jface.dialogs.MessageDialog;
@@ -14,17 +18,17 @@ import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextViewer;
 import org.eclipse.jface.text.contentassist.ICompletionProposal;
 import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Shell;
-//import org.eclipse.jdt.internal.ui.JavaPlugin;
 
 /**
  * A proposal for insertion of template variables.
  */
 public class TemplateVariableProposal implements ICompletionProposal {
 
-       private TemplateVariable fVariable;
+       private TemplateVariableResolver fVariable;
        private int fOffset;
        private int fLength;    
        private ITextViewer fViewer;
@@ -39,7 +43,7 @@ public class TemplateVariableProposal implements ICompletionProposal {
         * @param length the length to replace
         * @param viewer the viewer
         */
-       public TemplateVariableProposal(TemplateVariable variable, int offset, int length, ITextViewer viewer) {
+       public TemplateVariableProposal(TemplateVariableResolver variable, int offset, int length, ITextViewer viewer) {
                fVariable= variable;
                fOffset= offset;
                fLength= length;
@@ -52,7 +56,7 @@ public class TemplateVariableProposal implements ICompletionProposal {
        public void apply(IDocument document) {
 
                try {
-                       String variable= fVariable.getName().equals("dollar") ? "$$" : "${" + fVariable.getName() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                       String variable= fVariable.getType().equals("dollar") ? "$$" : "${" + fVariable.getType() + '}'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        document.replace(fOffset, fLength, variable);
                        fSelection= new Point(fOffset + variable.length(), 0);
 
@@ -60,7 +64,7 @@ public class TemplateVariableProposal implements ICompletionProposal {
                        PHPeclipsePlugin.log(e);
 
                        Shell shell= fViewer.getTextWidget().getShell();
-                       MessageDialog.openError(shell, TemplateMessages.getString("TemplateVariableProposal.error.title"), e.getMessage()); //$NON-NLS-1$
+                       MessageDialog.openError(shell, TemplatePreferencesMessages.getString("TemplateVariableProposal.error.title"), e.getMessage()); //$NON-NLS-1$
                }
        }
 
@@ -82,7 +86,7 @@ public class TemplateVariableProposal implements ICompletionProposal {
         * @see ICompletionProposal#getDisplayString()
         */
        public String getDisplayString() {
-               return fVariable.getName() + " - " + fVariable.getDescription(); //$NON-NLS-1$
+               return fVariable.getType() + " - " + fVariable.getDescription(); //$NON-NLS-1$
        }
 
        /*
@@ -98,4 +102,4 @@ public class TemplateVariableProposal implements ICompletionProposal {
        public IContextInformation getContextInformation() {
                return null;
        }
-}
\ No newline at end of file
+}
index ffdd686..d0f44bf 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
  * 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
@@ -75,8 +75,7 @@ public class SWTUtil {
         * Returns a width hint for a button control.
         */
        public static int getButtonWidthHint(Button button) {
-               if (button.getFont().equals(JFaceResources.getDefaultFont()))
-                       button.setFont(JFaceResources.getDialogFont());
+               button.setFont(JFaceResources.getDialogFont());
                PixelConverter converter= new PixelConverter(button);
                int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
                return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
@@ -85,27 +84,26 @@ public class SWTUtil {
        /**
         * Returns a height hint for a button control.
         */             
-       public static int getButtonHeigthHint(Button button) {
-               if (button.getFont().equals(JFaceResources.getDefaultFont()))
-                       button.setFont(JFaceResources.getDialogFont());
+       public static int getButtonHeightHint(Button button) {
+               button.setFont(JFaceResources.getDialogFont());
                PixelConverter converter= new PixelConverter(button);
                return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
-       }       
-
+       }
        
        /**
         * Sets width and height hint for the button control.
         * <b>Note:</b> This is a NOP if the button's layout data is not
         * an instance of <code>GridData</code>.
         * 
-        * @param       the button for which to set the dimension hint
+        * @param button        the button for which to set the dimension hint
         */             
        public static void setButtonDimensionHint(Button button) {
                Assert.isNotNull(button);
                Object gd= button.getLayoutData();
                if (gd instanceof GridData) {
-                       ((GridData)gd).heightHint= getButtonHeigthHint(button);
-                       ((GridData)gd).widthHint= getButtonWidthHint(button);            
+                       ((GridData)gd).heightHint= getButtonHeightHint(button);
+                       ((GridData)gd).widthHint= getButtonWidthHint(button);   
+                       ((GridData)gd).horizontalAlignment = GridData.FILL;      
                }
        }
        
index 32f3e6f..867e0f2 100644 (file)
@@ -372,7 +372,7 @@ public class ListDialogField extends DialogField {
                gd.horizontalAlignment= GridData.FILL;
                gd.grabExcessHorizontalSpace= true;
                gd.verticalAlignment= GridData.BEGINNING;
-               gd.heightHint = SWTUtil.getButtonHeigthHint(button);
+               gd.heightHint = SWTUtil.getButtonHeightHint(button);
                gd.widthHint = SWTUtil.getButtonWidthHint(button);
        
                button.setLayoutData(gd);
index 8572b44..a97e525 100644 (file)
@@ -89,7 +89,7 @@ public class SelectionButtonDialogField extends DialogField {
                gd.horizontalSpan= nColumns;
                gd.horizontalAlignment= GridData.FILL;
                if (fButtonStyle == SWT.PUSH) {
-                       gd.heightHint = SWTUtil.getButtonHeigthHint(button);
+                       gd.heightHint = SWTUtil.getButtonHeightHint(button);
                        gd.widthHint = SWTUtil.getButtonWidthHint(button);
                }                       
                
index 34f3a06..fb13bc4 100644 (file)
@@ -87,7 +87,7 @@ public class StringButtonDialogField extends StringDialogField {
                gd.horizontalAlignment= GridData.FILL;
                gd.grabExcessHorizontalSpace= false;
                gd.horizontalSpan= span;
-               gd.heightHint = SWTUtil.getButtonHeigthHint(button);
+               gd.heightHint = SWTUtil.getButtonHeightHint(button);
                gd.widthHint = SWTUtil.getButtonWidthHint(button);              
                return gd;
        }               
index d1ae767..4cf3892 100644 (file)
@@ -313,7 +313,7 @@ public class TreeListDialogField extends DialogField {
                gd.horizontalAlignment= GridData.FILL;
                gd.grabExcessHorizontalSpace= true;
                gd.verticalAlignment= GridData.BEGINNING;
-               gd.heightHint= SWTUtil.getButtonHeigthHint(button);
+               gd.heightHint= SWTUtil.getButtonHeightHint(button);
                gd.widthHint= SWTUtil.getButtonWidthHint(button);
 
                button.setLayoutData(gd);
index 33a5411..810f946 100644 (file)
@@ -476,19 +476,21 @@ public class JavaTextTools implements IPHPPartitions {
   }
 
   /**
-   * Determines whether the preference change encoded by the given event changes the behavior of one its contained components.
-   * 
-   * @param event
-   *          the event to be investigated
-   * @return <code>true</code> if event causes a behavioral change
-   * 
-   * @since 2.0
-   */
-  public boolean affectsBehavior(PropertyChangeEvent event) {
-    return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event)
-        || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event)
-        || fPHPDocScanner.affectsBehavior(event);
-  }
+        * Determines whether the preference change encoded by the given event
+        * changes the behavior of one its contained components.
+        * 
+        * @param event the event to be investigated
+        * @return <code>true</code> if event causes a behavioral change
+        * @since 2.0
+        * @deprecated As of 3.0, replaced by {@link org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)}
+        */
+//  public boolean affectsBehavior(PropertyChangeEvent event) {
+//    return fCodeScanner.affectsBehavior(event) 
+//        || fMultilineCommentScanner.affectsBehavior(event)
+//        || fSinglelineCommentScanner.affectsBehavior(event) 
+//        || fStringScanner.affectsBehavior(event)
+//        || fPHPDocScanner.affectsBehavior(event);
+//  }
 
   /**
    * Adapts the behavior of the contained components to the change encoded in the given event.
@@ -504,8 +506,8 @@ public class JavaTextTools implements IPHPPartitions {
       fMultilineCommentScanner.adaptToPreferenceChange(event);
     if (fSinglelineCommentScanner.affectsBehavior(event))
       fSinglelineCommentScanner.adaptToPreferenceChange(event);
-    if (fStringScanner.affectsBehavior(event))
-      fStringScanner.adaptToPreferenceChange(event);
+//    if (fStringScanner.affectsBehavior(event))
+//      fStringScanner.adaptToPreferenceChange(event);
     if (fPHPDocScanner.affectsBehavior(event))
       fPHPDocScanner.adaptToPreferenceChange(event);
     //    if (fHTMLScanner.affectsBehavior(event))
index 0dcaeed..735dcec 100644 (file)
@@ -14,10 +14,12 @@ package net.sourceforge.phpdt.ui.text;
 import java.util.Vector;
 
 import net.sourceforge.phpdt.core.JavaCore;
+import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
+import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
 import net.sourceforge.phpdt.internal.ui.text.JavaCompositeReconcilingStrategy;
 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
@@ -29,17 +31,22 @@ import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaInformationProvider;
+import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
+import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
+import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
+import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
@@ -112,12 +119,14 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
   private JavaTextTools fJavaTextTools;
 
   private ITextEditor fTextEditor;
+
   /**
-        * The document partitioning.
-        * @since 3.0
-        */
+   * The document partitioning.
+   * 
+   * @since 3.0
+   */
   private String fDocumentPartitioning;
-       
+
   private ContentFormatter fFormatter;
 
   private HTMLFormattingStrategy fFormattingStrategy;
@@ -136,42 +145,41 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
    * 
    * @since 3.0
    */
-//  private String fDocumentPartitioning;
-
-//  /**
-//   * The Java source code scanner
-//   * 
-//   * @since 3.0
-//   */
-//  private AbstractJavaScanner fCodeScanner;
-//
-//  /**
-//   * The Java multi-line comment scanner
-//   * 
-//   * @since 3.0
-//   */
-//  private AbstractJavaScanner fMultilineCommentScanner;
-//
-//  /**
-//   * The Java single-line comment scanner
-//   * 
-//   * @since 3.0
-//   */
-//  private AbstractJavaScanner fSinglelineCommentScanner;
-//
-//  /**
-//   * The Java string scanner
-//   * 
-//   * @since 3.0
-//   */
-//  private AbstractJavaScanner fStringScanner;
-//
-//  /**
-//   * The Javadoc scanner
-//   * 
-//   * @since 3.0
-//   */
-//  private AbstractJavaScanner fJavaDocScanner;
+  //  private String fDocumentPartitioning;
+  /**
+   * The Java source code scanner
+   * 
+   * @since 3.0
+   */
+  private AbstractJavaScanner fCodeScanner;
+
+  /**
+   * The Java multi-line comment scanner
+   * 
+   * @since 3.0
+   */
+  private AbstractJavaScanner fMultilineCommentScanner;
+
+  /**
+   * The Java single-line comment scanner
+   * 
+   * @since 3.0
+   */
+  private AbstractJavaScanner fSinglelineCommentScanner;
+
+  /**
+   * The Java string scanner
+   * 
+   * @since 3.0
+   */
+  private AbstractJavaScanner fStringScanner;
+
+  /**
+   * The Javadoc scanner
+   * 
+   * @since 3.0
+   */
+  private AbstractJavaScanner fJavaDocScanner;
 
   /**
    * The preference store, can be read-only
@@ -188,7 +196,9 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
   private IColorManager fColorManager;
 
   private XMLTextTools fXMLTextTools;
+
   private XMLConfiguration xmlConfiguration;
+
   /**
    * Creates a new Java source viewer configuration for viewers in the given editor using the given preference store, the color
    * manager and the specified document partitioning.
@@ -214,29 +224,103 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     fPreferenceStore = preferenceStore;
     fTextEditor = editor;
     fDocumentPartitioning = partitioning;
-    fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+//    fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
     fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
     xmlConfiguration = new XMLConfiguration(fXMLTextTools);
+    fColorManager= colorManager;
+       fPreferenceStore= preferenceStore;
+       fTextEditor= editor;
+       fDocumentPartitioning= partitioning;
+       
+    initializeScanners();
+  }
 
-    //         initializeScanners(); 
+  /**
+        * Creates a new Java source viewer configuration for viewers in the given editor 
+        * using the given Java tools.
+        *
+        * @param tools the Java text tools to be used
+        * @param editor the editor in which the configured viewer(s) will reside
+        * @see JavaTextTools
+        * @deprecated As of 3.0, replaced by {@link JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)}
+        */
+//  public PHPSourceViewerConfiguration(JavaTextTools tools, PHPEditor editor, String partitioning) {
+//    fJavaTextTools = tools;
+//    fColorManager = tools.getColorManager();
+//    fPreferenceStore = createPreferenceStore();
+//    fDocumentPartitioning = partitioning;
+//    fCodeScanner = (AbstractJavaScanner) fJavaTextTools.getCodeScanner();
+//    fMultilineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getMultilineCommentScanner();
+//    fSinglelineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getSinglelineCommentScanner();
+//    fStringScanner = (AbstractJavaScanner) fJavaTextTools.getStringScanner();
+//    fJavaDocScanner = (AbstractJavaScanner) fJavaTextTools.getJavaDocScanner();
+//    fTextEditor = editor;
+//    fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
+//    xmlConfiguration = new XMLConfiguration(fXMLTextTools);
+//  }
+
+  /**
+   * Returns the color manager for this configuration.
+   * 
+   * @return the color manager
+   */
+  protected IColorManager getColorManager() {
+    return fColorManager;
   }
 
   /**
-   * Default constructor.
-   */
-  public PHPSourceViewerConfiguration(JavaTextTools tools, PHPEditor editor, String partitioning) {   
-       fJavaTextTools= tools;
-       fColorManager= tools.getColorManager();
-       fPreferenceStore= createPreferenceStore();
-       fDocumentPartitioning = partitioning;
-//     fCodeScanner= (AbstractJavaScanner) fJavaTextTools.getCodeScanner();
-//     fMultilineCommentScanner= (AbstractJavaScanner) fJavaTextTools.getMultilineCommentScanner();
-//     fSinglelineCommentScanner= (AbstractJavaScanner) fJavaTextTools.getSinglelineCommentScanner();
-//     fStringScanner= (AbstractJavaScanner) fJavaTextTools.getStringScanner();
-//     fJavaDocScanner= (AbstractJavaScanner) fJavaTextTools.getJavaDocScanner();
-       fTextEditor= editor;
-    fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
-    xmlConfiguration = new XMLConfiguration(fXMLTextTools);
+   * Initializes the scanners.
+   * 
+   * @since 3.0
+   */
+  private void initializeScanners() {
+    Assert.isTrue(isNewSetup());
+    fCodeScanner = new PHPCodeScanner(getColorManager(), fPreferenceStore);
+    fMultilineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
+        IPreferenceConstants.PHP_MULTILINE_COMMENT);
+    fSinglelineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
+        IPreferenceConstants.PHP_SINGLELINE_COMMENT);
+    fStringScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING);
+    fJavaDocScanner = new PHPDocCodeScanner(getColorManager(), fPreferenceStore);
+  }
+
+  /**
+   * Determines whether the preference change encoded by the given event changes the behavior of one of its contained components.
+   * 
+   * @param event
+   *          the event to be investigated
+   * @return <code>true</code> if event causes a behavioral change
+   * @since 3.0
+   */
+  public boolean affectsTextPresentation(PropertyChangeEvent event) {
+    return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event)
+        || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event)
+        || fJavaDocScanner.affectsBehavior(event);
+  }
+
+  /**
+   * Adapts the behavior of the contained components to the change encoded in the given event.
+   * <p>
+   * Clients are not allowed to call this method if the old setup with text tools is in use.
+   * </p>
+   * 
+   * @param event
+   *          the event to which to adapt
+   * @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
+   * @since 3.0
+   */
+  public void handlePropertyChangeEvent(PropertyChangeEvent event) {
+    Assert.isTrue(isNewSetup());
+    if (fCodeScanner.affectsBehavior(event))
+      fCodeScanner.adaptToPreferenceChange(event);
+    if (fMultilineCommentScanner.affectsBehavior(event))
+      fMultilineCommentScanner.adaptToPreferenceChange(event);
+    if (fSinglelineCommentScanner.affectsBehavior(event))
+      fSinglelineCommentScanner.adaptToPreferenceChange(event);
+    if (fStringScanner.affectsBehavior(event))
+      fStringScanner.adaptToPreferenceChange(event);
+    if (fJavaDocScanner.affectsBehavior(event))
+      fJavaDocScanner.adaptToPreferenceChange(event);
   }
 
   /*
@@ -329,10 +413,13 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
    * (non-Javadoc) Method declared on SourceViewerConfiguration
    */
   public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
-    if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
+    if (IPHPPartitions.PHP_STRING_DQ.equals(contentType) || IPHPPartitions.PHP_STRING_SQ.equals(contentType))
       return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
 
-    return (IPHPPartitions.PHP_PARTITIONING.equals(contentType) ? new PHPAutoIndentStrategy() : new DefaultAutoIndentStrategy());
+    return (PHPDocumentPartitioner.PHP_TEMPLATE_DATA.equals(contentType)
+        || PHPDocumentPartitioner.PHP_SCRIPT_CODE.equals(contentType) || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
+        || IPHPPartitions.PHP_PARTITIONING.equals(contentType) || PHPPartitionScanner.PHP_SCRIPTING_AREA.equals(contentType) ? new PHPAutoIndentStrategy()
+        : new DefaultAutoIndentStrategy());
   }
 
   /**
@@ -341,26 +428,53 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
    * @return the PHP source code scanner
    */
   protected RuleBasedScanner getCodeScanner() {
-    return fJavaTextTools.getCodeScanner();
+    return fCodeScanner; //fJavaTextTools.getCodeScanner();
   }
-
+       /**
+        * Returns the Java multi-line comment scanner for this configuration.
+        *
+        * @return the Java multi-line comment scanner
+        * @since 2.0
+        */
+       protected RuleBasedScanner getMultilineCommentScanner() {
+               return fMultilineCommentScanner;
+       }
+       
+       /**
+        * Returns the Java single-line comment scanner for this configuration.
+        *
+        * @return the Java single-line comment scanner
+        * @since 2.0
+        */
+       protected RuleBasedScanner getSinglelineCommentScanner() {
+               return fSinglelineCommentScanner;
+       }
+       
+       /**
+        * Returns the Java string scanner for this configuration.
+        *
+        * @return the Java string scanner
+        * @since 2.0
+        */
+       protected RuleBasedScanner getStringScanner() {
+               return fStringScanner;
+       }
   /**
    * Returns the HTML source code scanner for this configuration.
    * 
    * @return the HTML source code scanner
    */
-//  protected RuleBasedScanner getHTMLScanner() {
-//    return fJavaTextTools.getHTMLScanner();
-//  }
-
+  //  protected RuleBasedScanner getHTMLScanner() {
+  //    return fJavaTextTools.getHTMLScanner();
+  //  }
   /**
    * Returns the Smarty source code scanner for this configuration.
    * 
    * @return the Smarty source code scanner
    */
-  protected RuleBasedScanner getSmartyScanner() {
-    return fJavaTextTools.getSmartyScanner();
-  }
+//  protected RuleBasedScanner getSmartyScanner() {
+//    return fJavaTextTools.getSmartyScanner();
+//  }
 
   /*
    * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
@@ -463,9 +577,9 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
    * 
    * @return the SmartyDoc source code scanner
    */
-  protected RuleBasedScanner getSmartyDocScanner() {
-    return fJavaTextTools.getSmartyDocScanner();
-  }
+//  protected RuleBasedScanner getSmartyDocScanner() {
+//    return fJavaTextTools.getSmartyDocScanner();
+//  }
 
   /**
    * Returns the PHPDoc source code scanner for this configuration.
@@ -473,100 +587,65 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
    * @return the PHPDoc source code scanner
    */
   protected RuleBasedScanner getPHPDocScanner() {
-    return fJavaTextTools.getJavaDocScanner();
+    return fJavaDocScanner; //fJavaTextTools.getJavaDocScanner();
   }
 
   /*
    * (non-Javadoc) Method declared on SourceViewerConfiguration
    */
   public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
-    return new String[] { 
-        IDocument.DEFAULT_CONTENT_TYPE, 
-        PHPPartitionScanner.PHP_SCRIPTING_AREA,
-        
-        IPHPPartitions.HTML, 
-        IPHPPartitions.HTML_MULTILINE_COMMENT,
-        IPHPPartitions.PHP_PARTITIONING, 
-        IPHPPartitions.PHP_SINGLELINE_COMMENT,
-        IPHPPartitions.PHP_MULTILINE_COMMENT,
-        IPHPPartitions.PHP_PHPDOC_COMMENT, 
-        IPHPPartitions.PHP_STRING_DQ,
-        IPHPPartitions.PHP_STRING_SQ,
-        IPHPPartitions.CSS,
-        IPHPPartitions.CSS_MULTILINE_COMMENT, 
-        IPHPPartitions.JAVASCRIPT, 
-        IPHPPartitions.JS_MULTILINE_COMMENT,
-        IPHPPartitions.SMARTY, 
+    return new String[] { IDocument.DEFAULT_CONTENT_TYPE, PHPPartitionScanner.PHP_SCRIPTING_AREA,
+
+    IPHPPartitions.HTML, IPHPPartitions.HTML_MULTILINE_COMMENT, IPHPPartitions.PHP_PARTITIONING,
+        IPHPPartitions.PHP_SINGLELINE_COMMENT, IPHPPartitions.PHP_MULTILINE_COMMENT, IPHPPartitions.PHP_PHPDOC_COMMENT,
+        IPHPPartitions.PHP_STRING_DQ, IPHPPartitions.PHP_STRING_SQ, IPHPPartitions.CSS, IPHPPartitions.CSS_MULTILINE_COMMENT,
+        IPHPPartitions.JAVASCRIPT, IPHPPartitions.JS_MULTILINE_COMMENT, IPHPPartitions.SMARTY,
         IPHPPartitions.SMARTY_MULTILINE_COMMENT,
-        
-        XMLPartitionScanner.XML_PI,
-               XMLPartitionScanner.XML_COMMENT,
-               XMLPartitionScanner.XML_DECL,
-               XMLPartitionScanner.XML_TAG,
-               XMLPartitionScanner.XML_ATTRIBUTE,
-               XMLPartitionScanner.XML_CDATA,
-               
-               XMLPartitionScanner.DTD_INTERNAL,
-               XMLPartitionScanner.DTD_INTERNAL_PI,
-               XMLPartitionScanner.DTD_INTERNAL_COMMENT,
-               XMLPartitionScanner.DTD_INTERNAL_DECL,
-               
-               PHPDocumentPartitioner.PHP_TEMPLATE_DATA,
-               PHPDocumentPartitioner.PHP_SCRIPT_CODE
-               };
+
+        XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL, XMLPartitionScanner.XML_TAG,
+        XMLPartitionScanner.XML_ATTRIBUTE, XMLPartitionScanner.XML_CDATA,
+
+        XMLPartitionScanner.DTD_INTERNAL, XMLPartitionScanner.DTD_INTERNAL_PI, XMLPartitionScanner.DTD_INTERNAL_COMMENT,
+        XMLPartitionScanner.DTD_INTERNAL_DECL,
+
+        PHPDocumentPartitioner.PHP_TEMPLATE_DATA, PHPDocumentPartitioner.PHP_SCRIPT_CODE };
   }
 
   public String[] getConfiguredHTMLContentTypes() {
-    return new String[] {  
-        XMLPartitionScanner.XML_PI,
-               XMLPartitionScanner.XML_COMMENT,
-               XMLPartitionScanner.XML_DECL,
-               XMLPartitionScanner.XML_TAG,
-               XMLPartitionScanner.XML_ATTRIBUTE,
-               XMLPartitionScanner.XML_CDATA,
-               
-               XMLPartitionScanner.DTD_INTERNAL,
-               XMLPartitionScanner.DTD_INTERNAL_PI,
-               XMLPartitionScanner.DTD_INTERNAL_COMMENT,
-               XMLPartitionScanner.DTD_INTERNAL_DECL,
-        };
+    return new String[] { XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL,
+        XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_ATTRIBUTE, XMLPartitionScanner.XML_CDATA,
+
+        XMLPartitionScanner.DTD_INTERNAL, XMLPartitionScanner.DTD_INTERNAL_PI, XMLPartitionScanner.DTD_INTERNAL_COMMENT,
+        XMLPartitionScanner.DTD_INTERNAL_DECL, };
   }
+
   public String[] getConfiguredPHPContentTypes() {
-    return new String[] { 
-        IDocument.DEFAULT_CONTENT_TYPE, 
-        IPHPPartitions.PHP_PARTITIONING, 
-        IPHPPartitions.PHP_SINGLELINE_COMMENT,
-        IPHPPartitions.PHP_MULTILINE_COMMENT,
-        IPHPPartitions.PHP_PHPDOC_COMMENT, 
-        IPHPPartitions.PHP_STRING_DQ,
-        IPHPPartitions.PHP_STRING_SQ,
-        IPHPPartitions.CSS,
-        IPHPPartitions.CSS_MULTILINE_COMMENT, 
-        IPHPPartitions.JAVASCRIPT, 
-        IPHPPartitions.JS_MULTILINE_COMMENT,
-        IPHPPartitions.SMARTY, 
-        IPHPPartitions.SMARTY_MULTILINE_COMMENT,
-        };
+    return new String[] { IDocument.DEFAULT_CONTENT_TYPE, IPHPPartitions.PHP_PARTITIONING, IPHPPartitions.PHP_SINGLELINE_COMMENT,
+        IPHPPartitions.PHP_MULTILINE_COMMENT, IPHPPartitions.PHP_PHPDOC_COMMENT, IPHPPartitions.PHP_STRING_DQ,
+        IPHPPartitions.PHP_STRING_SQ, IPHPPartitions.CSS, IPHPPartitions.CSS_MULTILINE_COMMENT, IPHPPartitions.JAVASCRIPT,
+        IPHPPartitions.JS_MULTILINE_COMMENT, IPHPPartitions.SMARTY, IPHPPartitions.SMARTY_MULTILINE_COMMENT, };
   }
-       /*
-        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
-        * @since 3.0
-        */
-       public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
-               if (fDocumentPartitioning != null)
-                       return fDocumentPartitioning;
-               return super.getConfiguredDocumentPartitioning(sourceViewer);
-       }
+
+  /*
+   * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
+   * @since 3.0
+   */
+  public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
+    if (fDocumentPartitioning != null)
+      return fDocumentPartitioning;
+    return super.getConfiguredDocumentPartitioning(sourceViewer);
+  }
+
   /*
    * (non-Javadoc) Method declared on SourceViewerConfiguration
    */
   public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
     ContentAssistant assistant = new ContentAssistant();
-    IContentAssistProcessor processor = new HTMLCompletionProcessor();
+    IContentAssistProcessor processor = new HTMLCompletionProcessor(getEditor());
     assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
     assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML_MULTILINE_COMMENT);
-    
+
     assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS_MULTILINE_COMMENT);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.JAVASCRIPT);
@@ -574,20 +653,20 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     // TODO define special smarty partition content assist
     assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
-    
+
     assistant.setContentAssistProcessor(processor, PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
     String[] htmlTypes = getConfiguredHTMLContentTypes();
     for (int i = 0; i < htmlTypes.length; i++) {
-      assistant.setContentAssistProcessor(processor, htmlTypes[i]); 
+      assistant.setContentAssistProcessor(processor, htmlTypes[i]);
     }
     processor = new PHPCompletionProcessor(getEditor());
-    
+
     assistant.setContentAssistProcessor(processor, PHPDocumentPartitioner.PHP_SCRIPT_CODE);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_PARTITIONING);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_DQ);
     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_SQ);
-    
-    assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(), IPHPPartitions.PHP_PHPDOC_COMMENT);
+
+    assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(getEditor()), IPHPPartitions.PHP_PHPDOC_COMMENT);
     //    assistant.enableAutoActivation(true);
     //    assistant.setAutoActivationDelay(500);
     //    assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
@@ -601,7 +680,7 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
     assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
     return assistant;
-  } 
+  }
 
   /*
    * (non-Javadoc) Method declared on SourceViewerConfiguration
@@ -655,29 +734,32 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     vector.add(""); //$NON-NLS-1$
     return (String[]) vector.toArray(new String[vector.size()]);
   }
+
   /**
-        * @return <code>true</code> iff the new setup without text tools is in use.
-        * 
-        * @since 3.0
-        */
-       private boolean isNewSetup() {
-               return fJavaTextTools == null;
-       }
+   * @return <code>true</code> iff the new setup without text tools is in use.
+   * 
+   * @since 3.0
+   */
+  private boolean isNewSetup() {
+    return fJavaTextTools == null;
+  }
+
   /**
-        * Creates and returns a preference store which combines the preference
-        * stores from the text tools and which is read-only.
-        *
-        * @return the read-only preference store 
-        * @since 3.0
-        */
-       private IPreferenceStore createPreferenceStore() {
-               Assert.isTrue(!isNewSetup());
-               IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
-               if (fJavaTextTools.getCorePreferenceStore() == null)
-                       return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(), generalTextStore});
-               
-               return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(), new PreferencesAdapter(fJavaTextTools.getCorePreferenceStore()), generalTextStore });
-       }
+   * Creates and returns a preference store which combines the preference stores from the text tools and which is read-only.
+   * 
+   * @return the read-only preference store
+   * @since 3.0
+   */
+  private IPreferenceStore createPreferenceStore() {
+    Assert.isTrue(!isNewSetup());
+    IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
+    if (fJavaTextTools.getCorePreferenceStore() == null)
+      return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(), generalTextStore });
+
+    return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(),
+        new PreferencesAdapter(fJavaTextTools.getCorePreferenceStore()), generalTextStore });
+  }
+
   /*
    * (non-Javadoc) Method declared on SourceViewerConfiguration
    */
@@ -689,39 +771,39 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     PresentationReconciler phpReconciler = new JavaPresentationReconciler();
     phpReconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
 
-//    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
-//    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
-//    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-//    dr = new DefaultDamagerRepairer(getHTMLScanner());
-//    reconciler.setDamager(dr, IPHPPartitions.HTML);
-//    reconciler.setRepairer(dr, IPHPPartitions.HTML);
-//    dr = new DefaultDamagerRepairer(getHTMLScanner());
-//    reconciler.setDamager(dr, IPHPPartitions.CSS);
-//    reconciler.setRepairer(dr, IPHPPartitions.CSS);
-//    dr = new DefaultDamagerRepairer(getHTMLScanner());
-//    reconciler.setDamager(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
-//    reconciler.setRepairer(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
-//    dr = new DefaultDamagerRepairer(getHTMLScanner());
-//    reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
-//    reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
-//    dr = new DefaultDamagerRepairer(getHTMLScanner());
-//    reconciler.setDamager(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
-//    reconciler.setRepairer(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
-    DefaultDamagerRepairer phpDR = new DefaultDamagerRepairer(getSmartyScanner());
-    phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY);
-    phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY);
-    phpDR = new DefaultDamagerRepairer(getSmartyDocScanner());
-    phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
-    phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
-//    dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-//        PHPColorProvider.MULTI_LINE_COMMENT))));
-//    reconciler.setDamager(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
-//    reconciler.setRepairer(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
-
-    phpDR = new DefaultDamagerRepairer(getCodeScanner());
+    //    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
+    //    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+    //    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+    //    dr = new DefaultDamagerRepairer(getHTMLScanner());
+    //    reconciler.setDamager(dr, IPHPPartitions.HTML);
+    //    reconciler.setRepairer(dr, IPHPPartitions.HTML);
+    //    dr = new DefaultDamagerRepairer(getHTMLScanner());
+    //    reconciler.setDamager(dr, IPHPPartitions.CSS);
+    //    reconciler.setRepairer(dr, IPHPPartitions.CSS);
+    //    dr = new DefaultDamagerRepairer(getHTMLScanner());
+    //    reconciler.setDamager(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
+    //    reconciler.setRepairer(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
+    //    dr = new DefaultDamagerRepairer(getHTMLScanner());
+    //    reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
+    //    reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
+    //    dr = new DefaultDamagerRepairer(getHTMLScanner());
+    //    reconciler.setDamager(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
+    //    reconciler.setRepairer(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
+//    DefaultDamagerRepairer phpDR = new DefaultDamagerRepairer(getSmartyScanner());
+//    phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY);
+//    phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY);
+//    phpDR = new DefaultDamagerRepairer(getSmartyDocScanner());
+//    phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
+//    phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
+    //    dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
+    //        PHPColorProvider.MULTI_LINE_COMMENT))));
+    //    reconciler.setDamager(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
+    //    reconciler.setRepairer(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
+
+    DefaultDamagerRepairer phpDR = new DefaultDamagerRepairer(getCodeScanner());
     phpReconciler.setDamager(phpDR, IDocument.DEFAULT_CONTENT_TYPE);
     phpReconciler.setRepairer(phpDR, IDocument.DEFAULT_CONTENT_TYPE);
-    
+
     phpDR = new DefaultDamagerRepairer(getCodeScanner());
     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PARTITIONING);
     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PARTITIONING);
@@ -730,72 +812,59 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
 
-    phpDR = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-        PHPColorProvider.STRING))));
+    phpDR = new DefaultDamagerRepairer(getStringScanner());
     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_DQ);
     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_DQ);
-    phpDR = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-        PHPColorProvider.STRING))));
+    phpDR = new DefaultDamagerRepairer(getStringScanner());
     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_SQ);
     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
-    phpDR = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-        PHPColorProvider.SINGLE_LINE_COMMENT))));
+    phpDR = new DefaultDamagerRepairer(getSinglelineCommentScanner());
     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
-    phpDR = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-        PHPColorProvider.MULTI_LINE_COMMENT))));
+    phpDR = new DefaultDamagerRepairer(getMultilineCommentScanner());
     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
-    
+
     PresentationReconciler reconciler = new PresentationReconciler();
     reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
-//
+    //
     JavaTextTools jspTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-        PHPColorProvider.PHPDOC_TAG))));//jspTextTools.getJSPTextScanner());
-       reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
-       reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
-
-//     dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
-//        PHPColorProvider.PHPDOC_TAG))));//jspTextTools.getJSPBracketScanner());
-//     reconciler.setDamager(dr, JSPScriptScanner.JSP_BRACKET);
-//     reconciler.setRepairer(dr, JSPScriptScanner.JSP_BRACKET);
-       
+    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getPHPDocScanner());//jspTextTools.getJSPTextScanner());
+    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+    // dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
+    //        PHPColorProvider.PHPDOC_TAG))));//jspTextTools.getJSPBracketScanner());
+    // reconciler.setDamager(dr, JSPScriptScanner.JSP_BRACKET);
+    // reconciler.setRepairer(dr, JSPScriptScanner.JSP_BRACKET);
+
     // xml partitions
-       configureEmbeddedPresentationReconciler(reconciler,
-           xmlConfiguration.getPresentationReconciler(sourceViewer),
-               xmlConfiguration.getConfiguredContentTypes(sourceViewer),
-               PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
-
-       // java partitions
-       configureEmbeddedPresentationReconciler(reconciler,
-           phpReconciler,
-               getConfiguredPHPContentTypes(),
-               PHPDocumentPartitioner.PHP_SCRIPT_CODE);
-       
+    configureEmbeddedPresentationReconciler(reconciler, xmlConfiguration.getPresentationReconciler(sourceViewer), xmlConfiguration
+        .getConfiguredContentTypes(sourceViewer), PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
+
+    // java partitions
+    configureEmbeddedPresentationReconciler(reconciler, phpReconciler, getConfiguredPHPContentTypes(),
+        PHPDocumentPartitioner.PHP_SCRIPT_CODE);
+
     return reconciler;
   }
-  
-  private void configureEmbeddedPresentationReconciler(
-               PresentationReconciler reconciler,
-               IPresentationReconciler embedded,
-               String[] types, 
-               String defaultType
-       ) {
-               for (int i = 0; i < types.length; i++) {
-                       String type = types[i];
-
-                       IPresentationDamager damager = embedded.getDamager(type);
-                       IPresentationRepairer repairer = embedded.getRepairer(type);
-
-                       if (type == IDocument.DEFAULT_CONTENT_TYPE) {
-                               type = defaultType;
-                       }
-
-                       reconciler.setDamager(damager, type);
-                       reconciler.setRepairer(repairer, type);
-               }
-       }
+
+  private void configureEmbeddedPresentationReconciler(PresentationReconciler reconciler, IPresentationReconciler embedded,
+      String[] types, String defaultType) {
+    for (int i = 0; i < types.length; i++) {
+      String type = types[i];
+
+      IPresentationDamager damager = embedded.getDamager(type);
+      IPresentationRepairer repairer = embedded.getRepairer(type);
+
+      if (type == IDocument.DEFAULT_CONTENT_TYPE) {
+        type = defaultType;
+      }
+
+      reconciler.setDamager(damager, type);
+      reconciler.setRepairer(repairer, type);
+    }
+  }
 
   /*
    * (non-Javadoc) Method declared on SourceViewerConfiguration
@@ -836,20 +905,21 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
     };
   }
 
-       /*
-        * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
-        * @since 2.0
-        */
-       public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
-               InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
-               presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
-               IInformationProvider provider= new JavaInformationProvider(getEditor());
-               presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
-               presenter.setInformationProvider(provider, IPHPPartitions.PHP_PHPDOC_COMMENT);
-//             presenter.setInformationProvider(provider, IPHPPartitions.JAVA_CHARACTER);
-               presenter.setSizeConstraints(60, 10, true, true);
-               return presenter;
-       }
+  /*
+   * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
+   * @since 2.0
+   */
+  public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
+    InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
+    presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+    IInformationProvider provider = new JavaInformationProvider(getEditor());
+    presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
+    presenter.setInformationProvider(provider, IPHPPartitions.PHP_PHPDOC_COMMENT);
+    //         presenter.setInformationProvider(provider, IPHPPartitions.JAVA_CHARACTER);
+    presenter.setSizeConstraints(60, 10, true, true);
+    return presenter;
+  }
+
   /*
    * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
    * @since 2.0
index a12516f..582eda6 100644 (file)
@@ -18,7 +18,6 @@ import net.sourceforge.phpdt.core.IBuffer;
 import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.IJavaElement;
 import net.sourceforge.phpdt.core.IPackageFragment;
-import net.sourceforge.phpdt.core.IPackageFragmentRoot;
 import net.sourceforge.phpdt.core.ISourceRange;
 import net.sourceforge.phpdt.core.IType;
 import net.sourceforge.phpdt.core.ToolFactory;
@@ -27,9 +26,8 @@ import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
 import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo;
 import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.Templates;
 import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
+import net.sourceforge.phpdt.internal.corext.template.php.Templates;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 import net.sourceforge.phpdt.internal.ui.util.SWTUtil;
 import net.sourceforge.phpdt.internal.ui.wizards.NewWizardMessages;
@@ -45,10 +43,8 @@ import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.Separator;
 import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
 import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringButtonStatusDialogField;
 import net.sourceforge.phpdt.internal.ui.wizards.dialogfields.StringDialogField;
-import net.sourceforge.phpdt.ui.JavaUI;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpeclipse.phpeditor.EditorUtility;
 
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -56,6 +52,9 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.SubProgressMonitor;
 import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateException;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
@@ -406,7 +405,7 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage {
 
     Button button = fEnclosingTypeDialogField.getChangeControl(composite);
     gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
-    gd.heightHint = SWTUtil.getButtonHeigthHint(button);
+    gd.heightHint = SWTUtil.getButtonHeightHint(button);
     gd.widthHint = SWTUtil.getButtonWidthHint(button);
     button.setLayoutData(gd);
   }
@@ -1625,10 +1624,16 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage {
     try {
       Template[] templates = Templates.getInstance().getTemplates(name);
       if (templates.length > 0) {
-        return JavaContext.evaluateTemplate(templates[0], parentCU, pos);
+          return JavaContext.evaluateTemplate(templates[0], parentCU, pos);
       }
     } catch (CoreException e) {
       PHPeclipsePlugin.log(e);
+    } catch (BadLocationException e1) {
+      // TODO Auto-generated catch block
+      e1.printStackTrace();
+    } catch (TemplateException e1) {
+      // TODO Auto-generated catch block
+      e1.printStackTrace();
     }
     return null;
   }
index 8fea4a1..97775d7 100644 (file)
@@ -138,10 +138,10 @@ public interface IPreferenceConstants {
   public static final String PHP_SINGLELINE_COMMENT_BOLD = "_php_singlelineComment_bold";//$NON-NLS-1$
   public static final String PHP_SINGLELINE_COMMENT_ITALIC = "_php_singlelineComment_italic";//$NON-NLS-1$
   public static final String PHP_SINGLELINE_COMMENT_UNDERLINE = "_php_singlelineComment_underline";//$NON-NLS-1$
-       public static final String PHP_TAG = "_php_tag";//$NON-NLS-1$
-       public static final String PHP_TAG_BOLD = "_php_tag_bold";//$NON-NLS-1$
-       public static final String PHP_TAG_ITALIC = "_php_tag_italic";//$NON-NLS-1$
-       public static final String PHP_TAG_UNDERLINE = "_php_tag_underline";//$NON-NLS-1$
+  public static final String PHP_TAG = "_php_tag";//$NON-NLS-1$
+  public static final String PHP_TAG_BOLD = "_php_tag_bold";//$NON-NLS-1$
+  public static final String PHP_TAG_ITALIC = "_php_tag_italic";//$NON-NLS-1$
+  public static final String PHP_TAG_UNDERLINE = "_php_tag_underline";//$NON-NLS-1$
   public static final String PHP_KEYWORD = "_php_keyword";//$NON-NLS-1$
   public static final String PHP_KEYWORD_BOLD = "_php_keyword_bold";//$NON-NLS-1$
   public static final String PHP_KEYWORD_ITALIC = "_php_keyword_italic";//$NON-NLS-1$
index 7b9ba11..63c5c41 100644 (file)
@@ -109,14 +109,14 @@ public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWo
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.keywords"), IPreferenceConstants.PHP_KEYWORD }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.variables"), IPreferenceConstants.PHP_VARIABLE }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.types"), IPreferenceConstants.PHP_TYPE }, {
-      PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.constants"), IPreferenceConstants.PHP_CONSTANT }, {
+        PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings"), IPreferenceConstants.PHP_STRING }, {
       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT }, {
-                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_keywords"), IPreferenceConstants.PHPDOC_KEYWORD }, {
-                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_tags"), IPreferenceConstants.PHPDOC_TAG }, {
-                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_links"), IPreferenceConstants.PHPDOC_LINK }, {
-                       PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_others"), IPreferenceConstants.PHPDOC_DEFAULT }
+         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_keywords"), IPreferenceConstants.PHPDOC_KEYWORD }, {
+         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_tags"), IPreferenceConstants.PHPDOC_TAG }, {
+         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_links"), IPreferenceConstants.PHPDOC_LINK }, {
+         PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.phpdoc_others"), IPreferenceConstants.PHPDOC_DEFAULT }
   };
 
   private OverlayPreferenceStore OverlayStore;
index 75709ed..341a36a 100644 (file)
@@ -12,6 +12,7 @@
 package net.sourceforge.phpeclipse;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -28,16 +29,16 @@ import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.WorkingCopyOwner;
 import net.sourceforge.phpdt.externaltools.internal.model.ColorManager;
 import net.sourceforge.phpdt.externaltools.internal.model.ExternalToolsPlugin;
-import net.sourceforge.phpdt.externaltools.internal.model.VariableContextManager;
 import net.sourceforge.phpdt.internal.core.BatchOperation;
 import net.sourceforge.phpdt.internal.core.JavaModelManager;
-import net.sourceforge.phpdt.internal.core.util.Util;
+import net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaDocContextType;
 import net.sourceforge.phpdt.internal.ui.IJavaStatusConstants;
 import net.sourceforge.phpdt.internal.ui.JavaElementAdapterFactory;
 import net.sourceforge.phpdt.internal.ui.ResourceAdapterFactory;
 import net.sourceforge.phpdt.internal.ui.preferences.MembersOrderPreferenceCache;
 import net.sourceforge.phpdt.internal.ui.preferences.MockupPreferenceStore;
-import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage;
 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
 import net.sourceforge.phpdt.internal.ui.text.folding.JavaFoldingStructureProviderRegistry;
 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
@@ -58,7 +59,6 @@ import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr;
 import net.sourceforge.phpeclipse.phpeditor.WorkingCopyManager;
 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
 
-import org.eclipse.core.internal.runtime.InternalPlatform;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
@@ -78,7 +78,6 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.action.GroupMarker;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.Separator;
@@ -87,6 +86,8 @@ import org.eclipse.jface.preference.PreferenceConverter;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.text.BadLocationException;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.graphics.RGB;
@@ -101,6 +102,8 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
+import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
 import org.eclipse.ui.ide.IDE;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
@@ -135,6 +138,28 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements
    */
   public final static int MAX_PROPOSALS = 200;
 
+  /**
+        * The key to store customized templates. 
+        * @since 3.0
+        */
+       private static final String TEMPLATES_KEY= "net.sourceforge.phpdt.ui.text.custom_templates"; //$NON-NLS-1$
+       /**
+        * The key to store customized code templates. 
+        * @since 3.0
+        */
+       private static final String CODE_TEMPLATES_KEY= "net.sourceforge.phpdt.ui.text.custom_code_templates"; //$NON-NLS-1$
+       /**
+        * The key to store whether the legacy templates have been migrated 
+        * @since 3.0
+        */
+//     private static final String TEMPLATES_MIGRATION_KEY= "net.sourceforge.phpdt.ui.text.templates_migrated"; //$NON-NLS-1$
+       /**
+        * The key to store whether the legacy code templates have been migrated 
+        * @since 3.0
+        */
+//     private static final String CODE_TEMPLATES_MIGRATION_KEY= "net.sourceforge.phpdt.ui.text.code_templates_migrated"; //$NON-NLS-1$
+       
+
   private static ExternalToolsPlugin externalTools;
 
   /**
@@ -174,6 +199,28 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements
   //The shared instance.
   private static PHPeclipsePlugin plugin;
 
+  /** 
+        * The template context type registry for the java editor. 
+        * @since 3.0
+        */
+       private ContextTypeRegistry fContextTypeRegistry;
+       /** 
+        * The code template context type registry for the java editor. 
+        * @since 3.0
+        */
+       private ContextTypeRegistry fCodeTemplateContextTypeRegistry;
+       
+       /**
+        * The template store for the java editor. 
+        * @since 3.0
+        */
+       private TemplateStore fTemplateStore;
+       /**
+        * The coded template store for the java editor. 
+        * @since 3.0
+        */
+       private TemplateStore fCodeTemplateStore;
+       
   /** Windows 9x */
   private static final int WINDOWS_9x = 6;
 
@@ -225,7 +272,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements
 
   /**
    * The extension point registry for the
-   * <code>org.eclipse.jdt.ui.javaFoldingStructureProvider</code> extension
+   * <code>net.sourceforge.phpdt.ui.javaFoldingStructureProvider</code> extension
    * point.
    * 
    * @since 3.0
@@ -781,7 +828,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements
     //    store.setDefault(RESOURCE_BUNDLE_DE, "false");
     //    store.setDefault(RESOURCE_BUNDLE_FR, "false");
     //    store.setDefault(RESOURCE_BUNDLE_ES, "false");
-    TemplatePreferencePage.initDefaults(store);
+//    TemplatePreferencePage.initDefaults(store);
     //this will initialize the static fields in the syntaxrdr class
     new PHPSyntaxRdr();
     JavaCore.initializeDefaultPluginPreferences();
@@ -1329,7 +1376,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements
 
   /**
    * Returns the registry of the extensions to the
-   * <code>org.eclipse.jdt.ui.javaFoldingStructureProvider</code> extension
+   * <code>net.sourceforge.phpdt.ui.javaFoldingStructureProvider</code> extension
    * point.
    * 
    * @return the registry of contributed
@@ -1426,4 +1473,96 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements
           monitor);
     }
   }
+  
+  /**
+        * Returns the template context type registry for the java plugin.
+        * 
+        * @return the template context type registry for the java plugin
+        * @since 3.0
+        */
+       public ContextTypeRegistry getTemplateContextRegistry() {
+               if (fContextTypeRegistry == null) {
+                       fContextTypeRegistry= new ContributionContextTypeRegistry();
+                       
+                       fContextTypeRegistry.addContextType(new JavaContextType());
+                       fContextTypeRegistry.addContextType(new JavaDocContextType());
+                       fContextTypeRegistry.addContextType(new HTMLContextType());
+               }
+
+               return fContextTypeRegistry;
+       }
+       
+       /**
+        * Returns the template store for the java editor templates.
+        * 
+        * @return the template store for the java editor templates
+        * @since 3.0
+        */
+       public TemplateStore getTemplateStore() {
+               if (fTemplateStore == null) {
+//                     boolean alreadyMigrated= getPreferenceStore().getBoolean(TEMPLATES_MIGRATION_KEY);
+//                     if (alreadyMigrated)
+                               fTemplateStore= new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), TEMPLATES_KEY);
+//                     else {
+//                             fTemplateStore= new CompatibilityTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), TEMPLATES_KEY, Templates.getInstance());
+//                             getPreferenceStore().setValue(TEMPLATES_MIGRATION_KEY, true);
+//                     }
+
+                       try {
+                               fTemplateStore.load();
+                       } catch (IOException e) {
+                               log(e);
+                       }
+               }
+               
+               return fTemplateStore;
+       }
+
+       /**
+        * Returns the template context type registry for the code generation
+        * templates.
+        * 
+        * @return the template context type registry for the code generation
+        *         templates
+        * @since 3.0
+        */
+       public ContextTypeRegistry getCodeTemplateContextRegistry() {
+               if (fCodeTemplateContextTypeRegistry == null) {
+                       fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry();
+                       
+//                     CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);
+               }
+
+               return fCodeTemplateContextTypeRegistry;
+       }
+       
+       /**
+        * Returns the template store for the code generation templates.
+        * 
+        * @return the template store for the code generation templates
+        * @since 3.0
+        */
+       public TemplateStore getCodeTemplateStore() {
+               if (fCodeTemplateStore == null) {
+//                     boolean alreadyMigrated= getPreferenceStore().getBoolean(CODE_TEMPLATES_MIGRATION_KEY);
+//                     if (alreadyMigrated)
+                               fCodeTemplateStore= new ContributionTemplateStore(getCodeTemplateContextRegistry(), getPreferenceStore(), CODE_TEMPLATES_KEY);
+//                     else {
+//                             fCodeTemplateStore= new CompatibilityTemplateStore(getCodeTemplateContextRegistry(), getPreferenceStore(), CODE_TEMPLATES_KEY, CodeTemplates.getInstance());
+//                             getPreferenceStore().setValue(CODE_TEMPLATES_MIGRATION_KEY, true);
+//                     }
+
+                       try {
+                               fCodeTemplateStore.load();
+                       } catch (IOException e) {
+                               log(e);
+                       }
+                       
+                       // compatibility / bug fixing code for duplicated templates
+                       // TODO remove for 3.0
+//                     CompatibilityTemplateStore.pruneDuplicates(fCodeTemplateStore, true);
+               }
+               
+               return fCodeTemplateStore;
+       }
 }
\ No newline at end of file
@@ -25,7 +25,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants;
 import net.sourceforge.phpdt.internal.compiler.lookup.TypeIds;
 
 
-public abstract class AstNode implements BaseTypes, CompilerModifiers, TypeConstants, TypeIds {
+public abstract class ASTNode implements BaseTypes, CompilerModifiers, TypeConstants, TypeIds {
        
        public int sourceStart, sourceEnd;
 
@@ -108,7 +108,7 @@ public abstract class AstNode implements BaseTypes, CompilerModifiers, TypeConst
        // for references on lhs of assignment (set only for true assignments, as opposed to compound ones)
        public static final int IsStrictlyAssignedMASK = Bit14;
        
-       public AstNode() {
+       public ASTNode() {
 
                super();
        }
@@ -117,7 +117,7 @@ public abstract class AstNode implements BaseTypes, CompilerModifiers, TypeConst
                return false;
        }
 
-       public AstNode concreteStatement() {
+       public ASTNode concreteStatement() {
                return this;
        }
 
index 15b28ed..7919157 100644 (file)
@@ -30,7 +30,7 @@ import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
 
 
 public abstract class AbstractMethodDeclaration
-       extends AstNode
+       extends ASTNode
        implements ProblemSeverities, ReferenceContext {
                
        public MethodScope scope;
index be0bdb0..eb6b06f 100644 (file)
@@ -16,7 +16,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 public abstract class BranchStatement extends Statement {
        public char[] label;
        public Label targetLabel;
-       public AstNode[] subroutines;
+       public ASTNode[] subroutines;
 /**
  * BranchStatement constructor comment.
  */
@@ -41,7 +41,7 @@ public BranchStatement(char[] l, int s,int e) {
 //     // blocks in sequence
 //     if (subroutines != null){
 //             for (int i = 0, max = subroutines.length; i < max; i++){
-//                     AstNode sub;
+//                     ASTNode sub;
 //                     if ((sub = subroutines[i]) instanceof SynchronizedStatement){
 //                             codeStream.load(((SynchronizedStatement)sub).synchroVariable);
 //                             codeStream.monitorexit(); 
index d01e783..bd53e9f 100644 (file)
@@ -46,13 +46,13 @@ public class Break extends BranchStatement {
                targetLabel = targetContext.breakLabel();
                FlowContext traversedContext = flowContext;
                int subIndex = 0, maxSub = 5;
-               subroutines = new AstNode[maxSub];
+               subroutines = new ASTNode[maxSub];
                
                do {
-                       AstNode sub;
+                       ASTNode sub;
                        if ((sub = traversedContext.subRoutine()) != null) {
                                if (subIndex == maxSub) {
-                                       System.arraycopy(subroutines, 0, (subroutines = new AstNode[maxSub*=2]), 0, subIndex); // grow
+                                       System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow
                                }
                                subroutines[subIndex++] = sub;
                                if (sub.cannotReturn()) {
@@ -61,7 +61,7 @@ public class Break extends BranchStatement {
                        }
                        traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
 
-                       AstNode node;
+                       ASTNode node;
                        if ((node = traversedContext.associatedNode) instanceof TryStatement) {
                                TryStatement tryStatement = (TryStatement) node;
                                flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits                 
@@ -74,7 +74,7 @@ public class Break extends BranchStatement {
                
                // resize subroutines
                if (subIndex != maxSub) {
-                       System.arraycopy(subroutines, 0, (subroutines = new AstNode[subIndex]), 0, subIndex);
+                       System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex);
                }
                return FlowInfo.DEAD_END;
        }
index dc49be5..a3be92d 100644 (file)
@@ -25,7 +25,7 @@ import net.sourceforge.phpdt.internal.compiler.problem.AbortType;
 import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
 import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
 
-public class CompilationUnitDeclaration extends AstNode implements ProblemSeverities, ReferenceContext {
+public class CompilationUnitDeclaration extends ASTNode implements ProblemSeverities, ReferenceContext {
 
   public ImportReference currentPackage;
   public ImportReference[] imports;
@@ -294,7 +294,7 @@ public class CompilationUnitDeclaration extends AstNode implements ProblemSeveri
 
     if (types != null)
       for (int i = 0; i < types.size(); i++) {
-        s += ((AstNode) types.get(i)).toString(tab) + "\n"; //$NON-NLS-1$
+        s += ((ASTNode) types.get(i)).toString(tab) + "\n"; //$NON-NLS-1$
       }
     return s;
   }
index 6e62d47..4a49302 100644 (file)
@@ -122,7 +122,7 @@ public class ConstructorDeclaration extends AbstractMethodDeclaration {
                                                && (!flowInfo.isDefinitelyAssigned(fields[i]))) {
                                                scope.problemReporter().uninitializedBlankFinalField(
                                                        field,
-                                                       isDefaultConstructor ? (AstNode) scope.referenceType() : this);
+                                                       isDefaultConstructor ? (ASTNode) scope.referenceType() : this);
                                        }
                                }
                        }
index c76da6a..52b2172 100644 (file)
@@ -51,13 +51,13 @@ public class Continue extends BranchStatement {
                targetLabel = targetContext.continueLabel();
                FlowContext traversedContext = flowContext;
                int subIndex = 0, maxSub = 5;
-               subroutines = new AstNode[maxSub];
+               subroutines = new ASTNode[maxSub];
 
                do {
-                       AstNode sub;
+                       ASTNode sub;
                        if ((sub = traversedContext.subRoutine()) != null) {
                                if (subIndex == maxSub) {
-                                       System.arraycopy(subroutines, 0, (subroutines = new AstNode[maxSub*=2]), 0, subIndex); // grow
+                                       System.arraycopy(subroutines, 0, (subroutines = new ASTNode[maxSub*=2]), 0, subIndex); // grow
                                }
                                subroutines[subIndex++] = sub;
                                if (sub.cannotReturn()) {
@@ -66,7 +66,7 @@ public class Continue extends BranchStatement {
                        }
                        traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
 
-                       AstNode node;
+                       ASTNode node;
                        if ((node = traversedContext.associatedNode) instanceof TryStatement) {
                                TryStatement tryStatement = (TryStatement) node;
                                flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); // collect inits                 
@@ -79,7 +79,7 @@ public class Continue extends BranchStatement {
                
                // resize subroutines
                if (subIndex != maxSub) {
-                       System.arraycopy(subroutines, 0, (subroutines = new AstNode[subIndex]), 0, subIndex);
+                       System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex);
                }
                return FlowInfo.DEAD_END;
        }
index f72c8bf..175afee 100644 (file)
@@ -79,8 +79,8 @@ public class ExplicitConstructorCall
                                flowContext.checkExceptionHandlers(
                                        thrownExceptions,
                                        (accessMode == ImplicitSuper)
-                                               ? (AstNode) currentScope.methodScope().referenceContext
-                                               : (AstNode) this,
+                                               ? (ASTNode) currentScope.methodScope().referenceContext
+                                               : (ASTNode) this,
                                        flowInfo,
                                        currentScope);
                        }
index d0d13d3..ce10dac 100644 (file)
@@ -13,7 +13,7 @@ package net.sourceforge.phpeclipse.internal.compiler.ast;
 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
 import net.sourceforge.phpdt.internal.compiler.lookup.CompilationUnitScope;
 
-public class ImportReference extends AstNode {
+public class ImportReference extends ASTNode {
        
 //     public char[][] tokens;
 //     public long[] sourcePositions; //each entry is using the code : (start<<32) + end
index 154aa8f..08fe9d5 100644 (file)
@@ -68,7 +68,7 @@ public class LabeledStatement extends Statement {
                }
        }
        
-       public AstNode concreteStatement() {
+       public ASTNode concreteStatement() {
                
                // return statement.concreteStatement(); // for supporting nested labels:   a:b:c: someStatement (see 21912)
                return statement;
index 8d65b96..13e7baf 100644 (file)
@@ -25,7 +25,7 @@ public class ReturnStatement extends Statement {
 
        public TypeBinding expressionType;
        public boolean isSynchronized;
-       public AstNode[] subroutines;
+       public ASTNode[] subroutines;
        public LocalVariableBinding saveValueVariable;
 
 public ReturnStatement(Expression expr, int s, int e ) {
@@ -47,13 +47,13 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
        boolean saveValueNeeded = false;
        boolean hasValueToSave = expression != null && expression.constant == NotAConstant;
        do {
-               AstNode sub;
+               ASTNode sub;
                if ((sub = traversedContext.subRoutine()) != null) {
                        if (this.subroutines == null){
-                               this.subroutines = new AstNode[maxSub];
+                               this.subroutines = new ASTNode[maxSub];
                        }
                        if (subIndex == maxSub) {
-                               System.arraycopy(this.subroutines, 0, (this.subroutines = new AstNode[maxSub *= 2]), 0, subIndex); // grow
+                               System.arraycopy(this.subroutines, 0, (this.subroutines = new ASTNode[maxSub *= 2]), 0, subIndex); // grow
                        }
                        this.subroutines[subIndex++] = sub;
                        if (sub.cannotReturn()) {
@@ -63,7 +63,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
                }
                traversedContext.recordReturnFrom(flowInfo.unconditionalInits());
 
-               AstNode node;
+               ASTNode node;
                if ((node = traversedContext.associatedNode) instanceof SynchronizedStatement) {
                        isSynchronized = true;
 
@@ -85,7 +85,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
        
        // resize subroutines
        if ((subroutines != null) && (subIndex != maxSub)) {
-               System.arraycopy(subroutines, 0, (subroutines = new AstNode[subIndex]), 0, subIndex);
+               System.arraycopy(subroutines, 0, (subroutines = new ASTNode[subIndex]), 0, subIndex);
        }
 
        // secret local variable for return value (note that this can only occur in a real method)
@@ -124,7 +124,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl
 //     // generation of code responsible for invoking the finally blocks in sequence
 //     if (subroutines != null) {
 //             for (int i = 0, max = subroutines.length; i < max; i++) {
-//                     AstNode sub;
+//                     ASTNode sub;
 //                     if ((sub = subroutines[i]) instanceof SynchronizedStatement) {
 //                             codeStream.load(((SynchronizedStatement) sub).synchroVariable);
 //                             codeStream.monitorexit();
index b767e9d..1559614 100644 (file)
@@ -18,7 +18,7 @@ import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
 
 
-public abstract class Statement extends AstNode {
+public abstract class Statement extends ASTNode {
        
        /**
         * Statement constructor comment.
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/EditorHighlightingSynchronizer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/EditorHighlightingSynchronizer.java
new file mode 100644 (file)
index 0000000..4f635d6
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/
+package net.sourceforge.phpeclipse.phpeditor;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+
+
+/**
+ * Turns off occurrences highlighting on a java editor until linked mode is
+ * left.
+ * 
+ * @since 3.0
+ */
+public class EditorHighlightingSynchronizer implements ILinkedModeListener {
+       
+       private final PHPEditor fEditor;
+//     private final boolean fWasOccurrencesOn;
+       
+       /**
+        * Creates a new synchronizer.
+        * 
+        * @param editor the java editor the occurrences markers of which will be 
+        *        synchonized with the linked mode
+        * 
+        */
+       public EditorHighlightingSynchronizer(PHPEditor editor) {
+               Assert.isLegal(editor != null);
+               fEditor= editor;
+//             fWasOccurrencesOn= fEditor.isMarkingOccurrences();
+//             
+//             if (fWasOccurrencesOn)
+//                     fEditor.uninstallOccurrencesFinder();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
+        */
+       public void left(LinkedModeModel environment, int flags) {
+//             if (fWasOccurrencesOn)
+//                     fEditor.installOccurrencesFinder();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
+        */
+       public void suspend(LinkedModeModel environment) {
+       }
+
+       /*
+        * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
+        */
+       public void resume(LinkedModeModel environment, int flags) {
+       }
+
+}
index 040e974..ed584d5 100644 (file)
@@ -1681,7 +1681,11 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
    * @since 3.0
    */
   private IJavaFoldingStructureProvider fProjectionModelUpdater;
-
+  /**
+        * The override and implements indicator manager for this editor.
+        * @since 3.0
+        */
+//     protected OverrideIndicatorManager fOverrideIndicatorManager;
   /**
    * The action group for folding.
    * 
@@ -1741,18 +1745,16 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
    */
   protected void initializeEditor() {
     //jsurfer old code
-    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this, IPHPPartitions.PHP_PARTITIONING)); //, IJavaPartitions.JAVA_PARTITIONING));
-    setRangeIndicator(new DefaultRangeIndicator());
-    //         IPreferenceStore store=
-    // PHPeclipsePlugin.getDefault().getPreferenceStore();
-    //         setPreferenceStore(store);
-    IPreferenceStore store = createCombinedPreferenceStore(null);
-    setPreferenceStore(store);
-
+//    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+//    setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools, this, IPHPPartitions.PHP_PARTITIONING)); //, IJavaPartitions.JAVA_PARTITIONING));
+    IPreferenceStore store= createCombinedPreferenceStore(null);
+       setPreferenceStore(store);
+    JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+       setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools.getColorManager(), store, this, IPHPPartitions.PHP_PARTITIONING));
     // TODO changed in 3.x ?
-    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
-      fUpdater = new OutlinePageSelectionUpdater();
+//    setRangeIndicator(new DefaultRangeIndicator());
+//    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))
+//      fUpdater = new OutlinePageSelectionUpdater();
     // jsurfer end
 
     //         IPreferenceStore store= createCombinedPreferenceStore(null);
@@ -1901,7 +1903,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
        
        super.configureSourceViewerDecorationSupport(support);
   }
-  
+       
   /**
    * Returns this document's complete text.
    * 
@@ -2668,14 +2670,11 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
         return;
       }
 
-      //      if
-      // (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property))
-      // {
-      //               if ((event.getNewValue() instanceof Boolean) &&
-      // ((Boolean)event.getNewValue()).booleanValue())
-      //                       fEditorSelectionChangedListener.selectionChanged();
-      //               return;
-      //       }
+      if (PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE.equals(property)) {
+               if ((event.getNewValue() instanceof Boolean) && ((Boolean)event.getNewValue()).booleanValue())
+                       selectionChanged();
+               return;
+         } 
 
       if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) {
         if (event.getNewValue() instanceof Boolean) {
@@ -2715,6 +2714,20 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
       //                       }
       //               }
       //       }
+      
+      ((PHPSourceViewerConfiguration)getSourceViewerConfiguration()).handlePropertyChangeEvent(event);
+               
+//             if (affectsOverrideIndicatorAnnotations(event)) {
+//                     if (isShowingOverrideIndicators()) {
+//                             if (fOverrideIndicatorManager == null)
+//                                     installOverrideIndicator(true);
+//                     } else {
+//                             if (fOverrideIndicatorManager != null)
+//                                     uninstallOverrideIndicator();
+//                     }
+//                     return;
+//             }
+               
       if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
         if (sourceViewer instanceof ProjectionViewer) {
           ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
@@ -2989,19 +3002,19 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
   protected final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
 
   /** Preference key for highlighting current line */
-  protected final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
+//  protected final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
 
   /** Preference key for highlight color of current line */
-  protected final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
+//  protected final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
 
   /** Preference key for showing print marging ruler */
-  protected final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
+//  protected final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
 
   /** Preference key for print margin ruler color */
-  protected final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
+//  protected final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
 
   /** Preference key for print margin ruler column */
-  protected final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
+//  protected final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
 
   /** Preference key for error indication */
   //  protected final static String ERROR_INDICATION =
@@ -3396,7 +3409,17 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
 
     return viewer;
   }
-
+  /*
+        * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
+        */
+       protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+               return ((PHPSourceViewerConfiguration)getSourceViewerConfiguration()).affectsTextPresentation(event) || super.affectsTextPresentation(event);
+       }
+//
+//       protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+//         JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
+//         return textTools.affectsBehavior(event);
+//       }
   /**
    * Creates and returns the preference store for this Java editor with the given input.
    * 
@@ -3432,23 +3455,6 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
     return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
   }
 
-  /*
-   * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
-   */
-  //   protected ISourceViewer createJavaSourceViewer(Composite parent,
-  // IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean
-  // isOverviewRulerVisible, int styles) {
-  //           return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(),
-  // isOverviewRulerVisible(), styles);
-  //   }
-  /*
-   * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
-   */
-  protected boolean affectsTextPresentation(PropertyChangeEvent event) {
-    JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
-    return textTools.affectsBehavior(event);
-  }
-
   /**
    * Jumps to the error next according to the given direction.
    */
index 6cb6318..5aa3cca 100644 (file)
@@ -1159,16 +1159,16 @@ public class PHPUnitEditor extends PHPEditor { //implements
   /** The editor's paint manager */
   //  private PaintManager fPaintManager;
   /** The editor's bracket painter */
-  private BracketPainter fBracketPainter;
+//  private BracketPainter fBracketPainter;
 
   /** The editor's bracket matcher */
   private PHPPairMatcher fBracketMatcher;
 
   /** The editor's line painter */
-  private LinePainter fLinePainter;
+//  private LinePainter fLinePainter;
 
   /** The editor's print margin ruler painter */
-  private PrintMarginPainter fPrintMarginPainter;
+//  private PrintMarginPainter fPrintMarginPainter;
 
   /** The editor's problem painter */
   //  private ProblemPainter fProblemPainter;
@@ -1215,25 +1215,25 @@ public class PHPUnitEditor extends PHPEditor { //implements
   private final static String CODE_FORMATTER_TAB_SIZE = JavaCore.FORMATTER_TAB_SIZE;
 
   /** Preference key for matching brackets */
-  private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
+//  private final static String MATCHING_BRACKETS = PreferenceConstants.EDITOR_MATCHING_BRACKETS;
 
   /** Preference key for matching brackets color */
-  private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
+//  private final static String MATCHING_BRACKETS_COLOR = PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR;
 
   /** Preference key for highlighting current line */
-  private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
+//  private final static String CURRENT_LINE = PreferenceConstants.EDITOR_CURRENT_LINE;
 
   /** Preference key for highlight color of current line */
-  private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
+//  private final static String CURRENT_LINE_COLOR = PreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
 
   /** Preference key for showing print marging ruler */
-  private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
+//  private final static String PRINT_MARGIN = PreferenceConstants.EDITOR_PRINT_MARGIN;
 
   /** Preference key for print margin ruler color */
-  private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
+//  private final static String PRINT_MARGIN_COLOR = PreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
 
   /** Preference key for print margin ruler column */
-  private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
+//  private final static String PRINT_MARGIN_COLUMN = PreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
 
   /** Preference key for inserting spaces rather than tabs */
   private final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
@@ -1590,12 +1590,12 @@ public class PHPUnitEditor extends PHPEditor { //implements
     linePainter = new LinePainter(getSourceViewer());
     linePainter.setHighlightColor(new Color(Display.getCurrent(), 225, 235, 224));
     //    fPaintManager.addPainter(linePainter);
-    if (isBracketHighlightingEnabled())
-      startBracketHighlighting();
-    if (isLineHighlightingEnabled())
-      startLineHighlighting();
-    if (isPrintMarginVisible())
-      showPrintMargin();
+//    if (isBracketHighlightingEnabled())
+//      startBracketHighlighting();
+//    if (isLineHighlightingEnabled())
+//      startLineHighlighting();
+//    if (isPrintMarginVisible())
+//      showPrintMargin();
     //    Iterator e = ANNOTATION_MAP.keySet().iterator();
     //    while (e.hasNext()) {
     //      AnnotationType type = (AnnotationType) e.next();
@@ -1645,74 +1645,74 @@ public class PHPUnitEditor extends PHPEditor { //implements
     }
   }
 
-  private void startBracketHighlighting() {
-    if (fBracketPainter == null) {
-      ISourceViewer sourceViewer = getSourceViewer();
-      fBracketPainter = new BracketPainter(sourceViewer);
-      fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
-      //      fPaintManager.addPainter(fBracketPainter);
-    }
-  }
-
-  private void stopBracketHighlighting() {
-    if (fBracketPainter != null) {
-      //      fPaintManager.removePainter(fBracketPainter);
-      fBracketPainter.deactivate(true);
-      fBracketPainter.dispose();
-      fBracketPainter = null;
-    }
-  }
-
-  private boolean isBracketHighlightingEnabled() {
-    IPreferenceStore store = getPreferenceStore();
-    return store.getBoolean(MATCHING_BRACKETS);
-  }
-
-  private void startLineHighlighting() {
-    if (fLinePainter == null) {
-      ISourceViewer sourceViewer = getSourceViewer();
-      fLinePainter = new LinePainter(sourceViewer);
-      fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
-      //      fPaintManager.addPainter(fLinePainter);
-    }
-  }
-
-  private void stopLineHighlighting() {
-    if (fLinePainter != null) {
-      //      fPaintManager.removePainter(fLinePainter);
-      fLinePainter.deactivate(true);
-      fLinePainter.dispose();
-      fLinePainter = null;
-    }
-  }
-
-  private boolean isLineHighlightingEnabled() {
-    IPreferenceStore store = getPreferenceStore();
-    return store.getBoolean(CURRENT_LINE);
-  }
-
-  private void showPrintMargin() {
-    if (fPrintMarginPainter == null) {
-      fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
-      fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
-      //      fPaintManager.addPainter(fPrintMarginPainter);
-    }
-  }
-
-  private void hidePrintMargin() {
-    if (fPrintMarginPainter != null) {
-      //      fPaintManager.removePainter(fPrintMarginPainter);
-      fPrintMarginPainter.deactivate(true);
-      fPrintMarginPainter.dispose();
-      fPrintMarginPainter = null;
-    }
-  }
-
-  private boolean isPrintMarginVisible() {
-    IPreferenceStore store = getPreferenceStore();
-    return store.getBoolean(PRINT_MARGIN);
-  }
+//  private void startBracketHighlighting() {
+//    if (fBracketPainter == null) {
+//      ISourceViewer sourceViewer = getSourceViewer();
+//      fBracketPainter = new BracketPainter(sourceViewer);
+//      fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+//      //      fPaintManager.addPainter(fBracketPainter);
+//    }
+//  }
+//
+//  private void stopBracketHighlighting() {
+//    if (fBracketPainter != null) {
+//      //      fPaintManager.removePainter(fBracketPainter);
+//      fBracketPainter.deactivate(true);
+//      fBracketPainter.dispose();
+//      fBracketPainter = null;
+//    }
+//  }
+
+//  private boolean isBracketHighlightingEnabled() {
+//    IPreferenceStore store = getPreferenceStore();
+//    return store.getBoolean(MATCHING_BRACKETS);
+//  }
+
+//  private void startLineHighlighting() {
+//    if (fLinePainter == null) {
+//      ISourceViewer sourceViewer = getSourceViewer();
+//      fLinePainter = new LinePainter(sourceViewer);
+//      fLinePainter.setHighlightColor(getColor(CURRENT_LINE_COLOR));
+//      //      fPaintManager.addPainter(fLinePainter);
+//    }
+//  }
+
+//  private void stopLineHighlighting() {
+//    if (fLinePainter != null) {
+//      //      fPaintManager.removePainter(fLinePainter);
+//      fLinePainter.deactivate(true);
+//      fLinePainter.dispose();
+//      fLinePainter = null;
+//    }
+//  }
+
+//  private boolean isLineHighlightingEnabled() {
+//    IPreferenceStore store = getPreferenceStore();
+//    return store.getBoolean(CURRENT_LINE);
+//  }
+
+//  private void showPrintMargin() {
+//    if (fPrintMarginPainter == null) {
+//      fPrintMarginPainter = new PrintMarginPainter(getSourceViewer());
+//      fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+//      fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+//      //      fPaintManager.addPainter(fPrintMarginPainter);
+//    }
+//  }
+
+//  private void hidePrintMargin() {
+//    if (fPrintMarginPainter != null) {
+//      //      fPaintManager.removePainter(fPrintMarginPainter);
+//      fPrintMarginPainter.deactivate(true);
+//      fPrintMarginPainter.dispose();
+//      fPrintMarginPainter = null;
+//    }
+//  }
+
+//  private boolean isPrintMarginVisible() {
+//    IPreferenceStore store = getPreferenceStore();
+//    return store.getBoolean(PRINT_MARGIN);
+//  }
 
   //  private void startAnnotationIndication(AnnotationType annotationType) {
   //    if (fProblemPainter == null) {
@@ -1914,49 +1914,49 @@ public class PHPUnitEditor extends PHPEditor { //implements
             stopTabConversion();
           return;
         }
-        if (MATCHING_BRACKETS.equals(p)) {
-          if (isBracketHighlightingEnabled())
-            startBracketHighlighting();
-          else
-            stopBracketHighlighting();
-          return;
-        }
-        if (MATCHING_BRACKETS_COLOR.equals(p)) {
-          if (fBracketPainter != null)
-            fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
-          return;
-        }
-        if (CURRENT_LINE.equals(p)) {
-          if (isLineHighlightingEnabled())
-            startLineHighlighting();
-          else
-            stopLineHighlighting();
-          return;
-        }
-        if (CURRENT_LINE_COLOR.equals(p)) {
-          if (fLinePainter != null) {
-            stopLineHighlighting();
-            startLineHighlighting();
-          }
-          return;
-        }
-        if (PRINT_MARGIN.equals(p)) {
-          if (isPrintMarginVisible())
-            showPrintMargin();
-          else
-            hidePrintMargin();
-          return;
-        }
-        if (PRINT_MARGIN_COLOR.equals(p)) {
-          if (fPrintMarginPainter != null)
-            fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
-          return;
-        }
-        if (PRINT_MARGIN_COLUMN.equals(p)) {
-          if (fPrintMarginPainter != null)
-            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
-          return;
-        }
+//        if (MATCHING_BRACKETS.equals(p)) {
+//          if (isBracketHighlightingEnabled())
+//            startBracketHighlighting();
+//          else
+//            stopBracketHighlighting();
+//          return;
+//        }
+//        if (MATCHING_BRACKETS_COLOR.equals(p)) {
+//          if (fBracketPainter != null)
+//            fBracketPainter.setHighlightColor(getColor(MATCHING_BRACKETS_COLOR));
+//          return;
+//        }
+//        if (CURRENT_LINE.equals(p)) {
+//          if (isLineHighlightingEnabled())
+//            startLineHighlighting();
+//          else
+//            stopLineHighlighting();
+//          return;
+//        }
+//        if (CURRENT_LINE_COLOR.equals(p)) {
+//          if (fLinePainter != null) {
+//            stopLineHighlighting();
+//            startLineHighlighting();
+//          }
+//          return;
+//        }
+//        if (PRINT_MARGIN.equals(p)) {
+//          if (isPrintMarginVisible())
+//            showPrintMargin();
+//          else
+//            hidePrintMargin();
+//          return;
+//        }
+//        if (PRINT_MARGIN_COLOR.equals(p)) {
+//          if (fPrintMarginPainter != null)
+//            fPrintMarginPainter.setMarginRulerColor(getColor(PRINT_MARGIN_COLOR));
+//          return;
+//        }
+//        if (PRINT_MARGIN_COLUMN.equals(p)) {
+//          if (fPrintMarginPainter != null)
+//            fPrintMarginPainter.setMarginRulerColumn(getPreferenceStore().getInt(PRINT_MARGIN_COLUMN));
+//          return;
+//        }
         //        if (OVERVIEW_RULER.equals(p)) {
         //          if (isOverviewRulerVisible())
         //            showOverviewRuler();
index 95360b8..685f2d8 100644 (file)
@@ -15,11 +15,12 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
+import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpdt.internal.ui.text.java.PHPCompletionProposalComparator;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine;
+import net.sourceforge.phpdt.internal.ui.text.template.contentassist.TemplateEngine;
+import net.sourceforge.phpdt.ui.IWorkingCopyManager;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITextViewer;
@@ -30,7 +31,9 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.jface.text.contentassist.IContextInformationExtension;
 import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.text.templates.TemplateContextType;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorPart;
 
 /**
  * HTML completion processor.
@@ -115,9 +118,15 @@ public class HTMLCompletionProcessor implements IContentAssistProcessor {
   private PHPCompletionProposalComparator fComparator;
   private int fNumberOfComputedResults = 0;
 
-  public HTMLCompletionProcessor() {
+  private IEditorPart fEditor;
 
-    ContextType contextType = ContextTypeRegistry.getInstance().getContextType("html"); //$NON-NLS-1$
+  protected IWorkingCopyManager fManager;
+
+  public HTMLCompletionProcessor(IEditorPart editor) {
+      fEditor = editor;
+      fManager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
+      
+    TemplateContextType contextType = PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType("html"); //$NON-NLS-1$
     if (contextType != null)
       fTemplateEngine = new TemplateEngine(contextType);
 
@@ -134,12 +143,13 @@ public class HTMLCompletionProcessor implements IContentAssistProcessor {
 
   private ICompletionProposal[] internalComputeCompletionProposals(ITextViewer viewer, int offset, int contextOffset) {
     IDocument document = viewer.getDocument();
+    ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput());
     
     if (fTemplateEngine != null) {
       ICompletionProposal[] results;
       //      try {
       fTemplateEngine.reset();
-      fTemplateEngine.complete(viewer, offset); //, unit);
+      fTemplateEngine.complete(viewer, offset, unit);
       //      } catch (JavaModelException x) {
       //        Shell shell= viewer.getTextWidget().getShell();
       //        ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
index 5e324f1..7e5c2cb 100644 (file)
@@ -300,76 +300,6 @@ public class PHPCodeScanner extends AbstractJavaScanner {
   protected String[] getTokenProperties() {
     return fgTokenProperties;
   }
-  //  public void updateToken(JavaColorManager provider) {
-  //    final IPreferenceStore store =
-  // PHPeclipsePlugin.getDefault().getPreferenceStore();
-  //
-  //    Color BackgroundColor =
-  // provider.getColor(PreferenceConverter.getColor(store,
-  // PHP_EDITOR_BACKGROUND));
-  //
-  //    variable.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_VARIABLE)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_VARIABLE_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_VARIABLE_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //    keyword.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_KEYWORD)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_KEYWORD_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_KEYWORD_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //    type.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_TYPE)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_TYPE_BOLD) ? SWT.BOLD : SWT.NONE) +
-  // (store.getBoolean(PHP_TYPE_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //    functionName.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_FUNCTIONNAME)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_FUNCTIONNAME_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_FUNCTIONNAME_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //    constant.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_CONSTANT)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_CONSTANT_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_CONSTANT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //    string.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_STRING)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_STRING_BOLD) ? SWT.BOLD : SWT.NONE) +
-  // (store.getBoolean(PHP_STRING_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //    comment.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store,
-  // PHP_SINGLELINE_COMMENT)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_SINGLELINE_COMMENT_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_SINGLELINE_COMMENT_ITALIC) ? SWT.ITALIC :
-  // SWT.NONE)));
-  //    multi_comment.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store,
-  // PHP_MULTILINE_COMMENT)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_MULTILINE_COMMENT_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_MULTILINE_COMMENT_ITALIC) ? SWT.ITALIC :
-  // SWT.NONE)));
-  //    other.setData(
-  //      new TextAttribute(
-  //        provider.getColor(PreferenceConverter.getColor(store, PHP_DEFAULT)),
-  //        BackgroundColor,
-  //        (store.getBoolean(PHP_DEFAULT_BOLD) ? SWT.BOLD : SWT.NONE)
-  //          + (store.getBoolean(PHP_DEFAULT_ITALIC) ? SWT.ITALIC : SWT.NONE)));
-  //  }
-
-  // public void updateWordRules() {
-
 
   /*
    * @see AbstractJavaScanner#createRules()
index 84bfadb..5d50dee 100644 (file)
@@ -20,14 +20,14 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.SortedMap;
 
+import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.ToolFactory;
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
 import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
 import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
-import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContext;
+import net.sourceforge.phpdt.internal.corext.template.php.JavaContextType;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpdt.internal.ui.text.java.PHPCompletionProposalComparator;
@@ -35,7 +35,7 @@ import net.sourceforge.phpdt.internal.ui.text.template.BuiltInEngine;
 import net.sourceforge.phpdt.internal.ui.text.template.DeclarationEngine;
 import net.sourceforge.phpdt.internal.ui.text.template.IdentifierEngine;
 import net.sourceforge.phpdt.internal.ui.text.template.SQLProposal;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine;
+import net.sourceforge.phpdt.internal.ui.text.template.contentassist.TemplateEngine;
 import net.sourceforge.phpdt.ui.IWorkingCopyManager;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
@@ -58,7 +58,9 @@ import org.eclipse.jface.text.contentassist.IContextInformation;
 import org.eclipse.jface.text.contentassist.IContextInformationExtension;
 import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
 import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.text.templates.TemplateContextType;
 import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IFileEditorInput;
 
@@ -190,7 +192,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
   public PHPCompletionProcessor(IEditorPart editor) {
     fEditor = editor;
     fManager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
-    ContextType contextType = ContextTypeRegistry.getInstance().getContextType(
+    TemplateContextType contextType = PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
         "php"); //$NON-NLS-1$
     if (contextType != null)
       fTemplateEngine = new TemplateEngine(contextType);
@@ -230,7 +232,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
   }
 
   private int getLastToken(ITextViewer viewer, int completionPosition,
-      PHPUnitContext context, TableName tableName) {
+      JavaContext context, TableName tableName) {
     IDocument document = viewer.getDocument();
     int start = context.getStart();
     int end = context.getEnd();
@@ -514,7 +516,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
 
   private ICompletionProposal[] internalComputeCompletionProposals(
       ITextViewer viewer, int offset, int contextOffset) {
-
+    ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput());
     IDocument document = viewer.getDocument();
     Object[] identifiers = null;
     IFile file = null;
@@ -525,19 +527,25 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
         editor = (PHPEditor) fEditor;
         file = ((IFileEditorInput) editor.getEditorInput()).getFile();
         project = file.getProject();
-        //        outlinePage = editor.getfOutlinePage();
-        // TODO: get the identifiers from the new model
-        //        if (outlinePage instanceof PHPContentOutlinePage) {
-        //          identifiers = ((PHPContentOutlinePage) outlinePage).getVariables();
-        //        }
       }
     }
     
-    ContextType phpContextType = ContextTypeRegistry.getInstance()
-        .getContextType("php"); //$NON-NLS-1$
-    ((CompilationUnitContextType) phpContextType).setContextParameters(
-        document, offset, 0);
-    PHPUnitContext context = (PHPUnitContext) phpContextType.createContext();
+    Point selection= viewer.getSelectedRange();
+
+       // remember selected text
+       String selectedText= null;
+       if (selection.y != 0) {
+               try {
+                       selectedText= document.get(selection.x, selection.y);
+               } catch (BadLocationException e) {}
+       }
+
+    JavaContextType phpContextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
+    "php"); //$NON-NLS-1$
+//    ((CompilationUnitContextType) phpContextType).setContextParameters(
+//        document, offset, 0);
+    JavaContext context = (JavaContext) phpContextType.createContext(document, offset,selection.y,unit);
+    context.setVariable("selection", selectedText); //$NON-NLS-1$
     String prefix = context.getKey();
     TableName sqlTable = new TableName();
     int lastSignificantToken = getLastToken(viewer, offset, context, sqlTable);
@@ -551,17 +559,17 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       ICompletionProposal[] results;
       if (!emptyPrefix) {
         fTemplateEngine.reset();
-        fTemplateEngine.complete(viewer, offset); //, unit);
+        fTemplateEngine.complete(viewer, offset, unit);
         templateResults = fTemplateEngine.getResults();
       }
       IPHPCompletionProposal[] identifierResults = new IPHPCompletionProposal[0];
       if ((!useClassMembers) && identifiers != null) {
         IdentifierEngine identifierEngine;
-        ContextType contextType = ContextTypeRegistry.getInstance()
-            .getContextType("php"); //$NON-NLS-1$
+        JavaContextType contextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
+        "php"); //$NON-NLS-1$
         if (contextType != null) {
           identifierEngine = new IdentifierEngine(contextType);
-          identifierEngine.complete(viewer, offset, identifiers);
+          identifierEngine.complete(viewer, offset, identifiers,unit);
           identifierResults = identifierEngine.getResults();
         }
       }
@@ -569,15 +577,15 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       IPHPCompletionProposal[] declarationResults = new IPHPCompletionProposal[0];
       if (project != null) {
         DeclarationEngine declarationEngine;
-        ContextType contextType = ContextTypeRegistry.getInstance()
-            .getContextType("php"); //$NON-NLS-1$
+        JavaContextType contextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
+        "php"); //$NON-NLS-1$
         if (contextType != null) {
           IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
               .getIndexManager(project);
           SortedMap sortedMap = indexManager.getIdentifierMap();
           declarationEngine = new DeclarationEngine(project, contextType,
               lastSignificantToken, file);
-          declarationEngine.complete(viewer, offset, sortedMap);
+          declarationEngine.complete(viewer, offset, sortedMap,unit);
           declarationResults = declarationEngine.getResults();
         }
       }
@@ -587,11 +595,11 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       if ((!useClassMembers) && syntaxbuffer != null) {
         BuiltInEngine builtinEngine;
         String proposal;
-        ContextType contextType = ContextTypeRegistry.getInstance()
-            .getContextType("php"); //$NON-NLS-1$
+        JavaContextType contextType = (JavaContextType)PHPeclipsePlugin.getDefault().getTemplateContextRegistry().getContextType(
+        "php"); //$NON-NLS-1$
         if (contextType != null) {
           builtinEngine = new BuiltInEngine(contextType);
-          builtinEngine.complete(viewer, offset, syntaxbuffer);
+          builtinEngine.complete(viewer, offset, syntaxbuffer, unit);
           builtinResults = builtinEngine.getResults();
         }
       }
diff --git a/net.sourceforge.phpeclipse/templates/default-codetemplates.xml b/net.sourceforge.phpeclipse/templates/default-codetemplates.xml
new file mode 100644 (file)
index 0000000..645b950
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * 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
+ *******************************************************************************/ 
+-->
+
+<templates>
+<template name="gettercomment" id="net.sourceforge.phpdt.ui.text.codetemplates.gettercomment" description="%CodeTemplates.gettercomment" context="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">/**
+ * @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">/**
+ * ${tags}
+ */</template>
+
+<template name="typecomment" id="net.sourceforge.phpdt.ui.text.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="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">/**
+ * %CodeTemplates.fieldcomment.content
+ */</template>
+<template name="methodcomment" id="net.sourceforge.phpdt.ui.text.codetemplates.methodcomment" description="%CodeTemplates.nonoverridingcomment" context="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
+ * ${see_to_overridden}
+ */</template>
+
+<template name="newtype" id="net.sourceforge.phpdt.ui.text.codetemplates.newtype" description="%CodeTemplates.newfile" context="newtype_context" enabled="true">/*
+ * %CodeTemplates.newfile.content1
+ *
+ * ${todo} %CodeTemplates.newfile.content2
+ * %CodeTemplates.newfile.content3
+ */
+${package_declaration}
+
+${typecomment}
+${type_declaration}</template>
+
+<template name="catchblock" id="net.sourceforge.phpdt.ui.text.codetemplates.catchblock" description="%CodeTemplates.catchblock" context="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
+${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="setterbody" id="net.sourceforge.phpdt.ui.text.codetemplates.setterbody" description="%CodeTemplates.setterstub" context="setterbody_context" enabled="true">${field} = ${param};</template>
+
+</templates>
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/templates/default-templates.properties b/net.sourceforge.phpeclipse/templates/default-templates.properties
new file mode 100644 (file)
index 0000000..ca68397
--- /dev/null
@@ -0,0 +1,142 @@
+###############################################################################
+# Copyright (c) 2000, 2004 IBM Corporation and others.
+# 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
+###############################################################################
+
+Templates.for_array=iterate over array
+Templates.for_temp=iterate over array with temporary variable
+Templates.for_collection=iterate over collection
+Templates.while_enumeration=iterate with enumeration
+Templates.while_iterator=iterate with iterator
+Templates.do=do while statement
+Templates.switch=switch case statement
+Templates.if=if statement
+Templates.ifelse=if else statement
+Templates.elseif=else if block
+Templates.else=else block
+Templates.try=try catch block
+Templates.catch=catch block
+Templates.main=main method
+Templates.public_method=public method
+Templates.protected_method=protected method
+Templates.private_method=private method
+Templates.private_static_method=private static method
+Templates.instanceof=dynamic type test and cast
+Templates.cast=dynamic cast
+Templates.toarray=convert collection to array
+Templates.test=test method
+Templates.systrace=print current method to standard out
+Templates.sysout=print to standard out
+Templates.syserr=print to standard error
+Templates.code_tag=<code></code>
+Templates.code_tag_null=<code>null</code>
+Templates.code_tag_true=<code>true</code>
+Templates.code_tag_false=<code>false</code>
+Templates.pre_tag=<pre></pre>
+Templates.b_tag=<b></b>
+Templates.i_tag=<i></i>
+Templates.author=author name
+Templates.new=create new object
+Templates.lazy=lazy creation
+Templates.while_condition=while loop with condition
+Templates.non-nls= non-externalized string marker
+Templates.synchronized= blocksynchronized block
+Templates.runnable= runnable
+
+# Java Only stuff
+CompilationUnitContextType.variable.description.file=Filename of compilation unit
+CompilationUnitContextType.variable.description.primary.type.name=Filename without extension
+CompilationUnitContextType.variable.description.enclosing.method=Enclosing method name
+CompilationUnitContextType.variable.description.enclosing.type=Enclosing type name
+CompilationUnitContextType.variable.description.enclosing.package=Enclosing package name
+CompilationUnitContextType.variable.description.enclosing.project=Enclosing project name
+CompilationUnitContextType.variable.description.enclosing.method.arguments=Argument names of enclosing method
+CompilationUnitContextType.variable.description.return.type=Enclosing method return type
+
+JavaContextType.variable.description.array=A proposal for an array
+JavaContextType.variable.description.array.type=A proposal for the element type of an array
+JavaContextType.variable.description.array.element=A proposal for the element name of an array
+JavaContextType.variable.description.index=A proposal for an index (int)
+JavaContextType.variable.description.collection=A proposal for a collection (java.util.Collection)
+JavaContextType.variable.description.iterator=A proposal for an iterator (java.util.Iterator)
+JavaContextType.variable.description.todo=Todo task tag
+
+JavaContext.error.title=Template Error
+JavaContext.error.message=Template file incomplete or has errors.  You can load the default templates from the template preference page (Java>Templates).
+
+CodeTemplateContextType.variable.description.todo=Todo task tag
+CodeTemplateContextType.variable.description.packdeclaration=Package declaration of the new type
+CodeTemplateContextType.variable.description.typedeclaration=Generated type declaration
+CodeTemplateContextType.variable.description.getterfieldname=The name of field to set or get
+CodeTemplateContextType.variable.description.getterfieldtype=The type of the field to set or get
+CodeTemplateContextType.variable.description.fieldname=The name of field
+CodeTemplateContextType.variable.description.fieldtype=The type of the field
+CodeTemplateContextType.variable.description.barefieldname=The name of field to set or get without prefix or suffix
+CodeTemplateContextType.variable.description.param=The parameter passed into the setter method
+CodeTemplateContextType.variable.description.typecomment=Content of code template 'typecomment'
+CodeTemplateContextType.variable.description.exceptiontype=The type of the caught exception
+CodeTemplateContextType.variable.description.exceptionvar=The variable name of the caught exception
+CodeTemplateContextType.variable.description.enclosingtype=The type enclosing this method
+CodeTemplateContextType.variable.description.typename=Name of the current type
+CodeTemplateContextType.variable.description.enclosingmethod=The enclosing method
+CodeTemplateContextType.variable.description.bodystatement=Return statement or super call
+CodeTemplateContextType.variable.description.returntype=Return type of the enclosing method
+CodeTemplateContextType.variable.description.tags=Generated Javadoc tags (@param, @return...)
+CodeTemplateContextType.variable.description.seetag=See tag pointing to the overridden method (@see T#m())
+
+CodeTemplateContextType.variable.description.filename=Name of the enclosing compilation unit
+CodeTemplateContextType.variable.description.packagename=Name of the enclosing package
+CodeTemplateContextType.variable.description.projectname=Name of the enclosing project
+
+CodeTemplateContextType.validate.unknownvariable=Variable ''{0}'' is unknown.
+CodeTemplateContextType.validate.missingvariable=Variable ''{0}'' is required.
+CodeTemplateContextType.validate.invalidcomment=Pattern is not a valid Java comment.
+
+
+
+CodeTemplates.error.title=Error accessing code templates.
+
+# strings in default templates
+CodeTemplates.constructorcomment=Comment for created constructors
+CodeTemplates.typecomment=Comment for created types
+CodeTemplates.fieldcomment=Comment for fields
+CodeTemplates.nonoverridingcomment=Comment for non-overriding methods
+CodeTemplates.overridecomment=Comment for overriding methods
+CodeTemplates.gettercomment=Comment for getter method
+# ! Do not translate ${bare_field_name} !
+CodeTemplates.gettercomment.returntagcontent=Returns the ${bare_field_name}.
+CodeTemplates.settercomment=Comment for setter method
+# ! Do not translate ${bare_field_name} !
+CodeTemplates.settercomment.paramtagcontent=The ${bare_field_name} to set.
+
+CodeTemplates.newfile=Newly created files
+CodeTemplates.catchblock=Code in new catch blocks
+CodeTemplates.methodstub=Code in created method stubs
+CodeTemplates.constructorstub=Code in created constructor stubs
+CodeTemplates.getterstub=Code in created getters
+CodeTemplates.setterstub=Code in created setters
+
+# ! Do not translate @todo !
+CodeTemplates.typecomment.content1=To change the template for this generated type comment go to
+CodeTemplates.typecomment.content2=Window - Preferences - Java - Code Style - Code Templates
+
+# ! Do not translate ${field} !
+CodeTemplates.fieldcomment.content=Comment for <code>${field}</code>
+
+CodeTemplates.overridecomment.nonjd=(non-Javadoc)
+
+# ! Do not translate ${date} !
+CodeTemplates.newfile.content1=Created on ${date}
+CodeTemplates.newfile.content2=To change the template for this generated file go to
+CodeTemplates.newfile.content3=Window - Preferences - Java - Code Style - Code Templates
+
+CodeTemplates.catchblock.tododesc=Auto-generated catch block
+CodeTemplates.methodstub.tododesc=Auto-generated method stub
+CodeTemplates.constructorstub.tododesc=Auto-generated constructor stub
+
diff --git a/net.sourceforge.phpeclipse/templates/default-templates.xml b/net.sourceforge.phpeclipse/templates/default-templates.xml
new file mode 100644 (file)
index 0000000..352bfbf
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates>
+<template name="class" description="class template with constructor" id="net.sourceforge.phpdt.php.class1" context="php" enabled="true">class ${class_name} {
+  function ${class_name}() {
+         ${cursor}
+  }
+}</template>
+<template name="class" description="class with attribute" id="net.sourceforge.phpdt.php.class2" context="php" enabled="true">class ${class_name} {
+  var $$${attribute};
+  function ${class_name}() {
+         ${cursor}
+  }
+  
+  function set_${attribute}( $$${attr} ) {
+    $$this->${attribute} = $$${attr};
+       }
+
+       function get_${attribute}() {
+    return $$this->${attribute};
+       }
+}</template>
+<template name="for" description="iterate over array" id="net.sourceforge.phpdt.php.for1" context="php" enabled="true">for ($$${index} = 0; $$${index} &lt; sizeof($$${array}); $$${index}++) {
+       ${cursor}
+}</template>
+<template name="for" description="iterate over array w/ temporary variable" id="net.sourceforge.phpdt.php.for2" context="php" enabled="true">for ($$${index} = 0; $$${index} &lt; sizeof($$${array}); $$${index}++) {
+       $$${array_element} = $$${array}[$$${index}];
+       ${cursor}
+}</template>
+<template name="function" description="function template" id="net.sourceforge.phpdt.php.function1" context="php" enabled="true">function ${function_name} () {
+       ${cursor}
+}</template>
+<template name="function" description="function template with return" id="net.sourceforge.phpdt.php.function2" context="php" enabled="true">function ${function_name} () {
+       return (${cursor});
+}</template>
+<template name="while" description="while iteration" id="net.sourceforge.phpdt.php.while" context="php" enabled="true">while (${condition}) {
+       ${cursor}
+}</template>
+<template name="do" description="do iteraation" id="net.sourceforge.phpdt.php.do" context="php" enabled="true">do {
+       ${line_selection}${cursor}
+} while (${condition});</template>
+<template name="switch" description="switch case statement" id="net.sourceforge.phpdt.php.switch" context="php" enabled="true">switch (${key}) {
+       case ${value}:
+               ${cursor}
+               break;
+
+       default:
+               break;
+}</template><template name="if" description="if statement" id="net.sourceforge.phpdt.php.if" context="php" enabled="true">if (${condition}) {
+       ${cursor}
+}</template><template name="ifelse" description="if else statement" id="net.sourceforge.phpdt.php.ifelse" context="php" enabled="true">if (${condition}) {
+       ${cursor}
+} else {
+       
+}</template><template name="elseif" description="else if block" id="net.sourceforge.phpdt.php.elseif" context="php" enabled="true">elseif (${condition}) {
+       ${cursor}
+}</template><template name="else" description="else block" id="net.sourceforge.phpdt.php.else" context="php" enabled="true">else {
+       ${cursor}
+}</template>
+<template name="filecomment" description="file comment used by the class and interface wizards" id="net.sourceforge.phpdt.php.filecomment" context="php" enabled="true">/**
+ * Created on ${date} by ${user}
+ *
+ */</template><template name="functioncomment" description="function comment" id="net.sourceforge.phpdt.php.functioncomment" context="php" enabled="true">/**
+ * @author ${user}
+ *
+ */</template>
+ <template name="echo" description="echo a string" id="net.sourceforge.phpdt.php.echo" context="php" enabled="true">echo "${string}";
+  ${cursor}</template>
+
+  <!-- phpdoc -->
+
+  <template description="&lt;code&gt;&lt;/code&gt;" name="&lt;code&gt;" id="net.sourceforge.phpdt.phpdoc.code1" context="phpdoc"
+  >&lt;code&gt;${cursor}&lt;/code&gt;</template>
+
+  <template description="&lt;code&gt;null&lt;/code&gt;" name="&lt;code&gt;" id="net.sourceforge.phpdt.phpdoc.code2" context="phpdoc"
+  >&lt;code&gt;null&lt;/code&gt;</template>
+
+  <template description="&lt;pre&gt;&lt;/pre&gt;" name="&lt;pre&gt;" id="net.sourceforge.phpdt.phpdoc.pre" context="phpdoc"
+  >&lt;pre&gt;${cursor}&lt;/pre&gt;</template>
+
+  <template description="&lt;b&gt;&lt;/b&gt;" name="&lt;b&gt;" id="net.sourceforge.phpdt.phpdoc.b" context="phpdoc"
+  >&lt;b&gt;${cursor}&lt;/b&gt;</template>
+
+  <template description="&lt;i&gt;&lt;/i&gt;" name="&lt;i&gt;" id="net.sourceforge.phpdt.phpdoc.i" context="phpdoc">&lt;i&gt;${cursor}&lt;/i&gt;</template>
+
+  <template description="author name" name="@author" id="net.sourceforge.phpdt.phpdoc.author" context="phpdoc">@author ${user}</template>
+
+  <template name="@author" description="author name email" id="net.sourceforge.phpdt.phpdoc.author" context="phpdoc" enabled="true">@author ${user} &lt;${email}&gt;</template>
+  <template name="@access" description="access private" id="net.sourceforge.phpdt.phpdoc.access1" context="phpdoc" enabled="true">@access private</template>
+  <template name="@access" description="access protected" id="net.sourceforge.phpdt.phpdoc.access2" context="phpdoc" enabled="true">@access protected</template>
+  <template name="@access" description="access public" id="net.sourceforge.phpdt.phpdoc.access3" context="phpdoc" enabled="true">@access public</template>
+  <template name="@category" description="category" id="net.sourceforge.phpdt.phpdoc.category" context="phpdoc" enabled="true">@category ${categoryname}</template>
+  <template name="@copyright" description="copyright" id="net.sourceforge.phpdt.phpdoc.copyright" context="phpdoc" enabled="true">@copyright Copyright &amp;copy; ${year}, ${user}</template>
+  <template name="@deprecated" description="deprecated version date" id="net.sourceforge.phpdt.phpdoc.deprected" context="phpdoc" enabled="true">@deprecated ${version} - ${date}</template>
+  <template name="@example" description="example path description" id="net.sourceforge.phpdt.phpdoc.example" context="phpdoc" enabled="true">@example ${path} ${description}</template>
+  <template name="@abstract" description="abstract" id="net.sourceforge.phpdt.phpdoc.abstract" context="phpdoc" enabled="true">@abstract</template>
+  <template name="@final" description="final" id="net.sourceforge.phpdt.phpdoc.final" context="phpdoc" enabled="true">@final</template>
+  <template name="@filesource" description="filesource" id="net.sourceforge.phpdt.phpdoc.filesource" context="phpdoc" enabled="true">@filesource</template>
+  <template name="@global" description="global datatype globalvariable" id="net.sourceforge.phpdt.phpdoc.global1" context="phpdoc" enabled="true">@global ${datatype} ${globalvariable}</template>
+  <template name="@global" description="global datatype description" id="net.sourceforge.phpdt.phpdoc.global2" context="phpdoc" enabled="true">@global ${datatype} ${description}</template>
+  <template name="@ignore" description="ignore" id="net.sourceforge.phpdt.phpdoc.ignore" context="phpdoc" enabled="true">@ignore</template>
+  <template name="@internal " description="internal comment" id="net.sourceforge.phpdt.phpdoc.internal" context="phpdoc" enabled="true">@internal ${comment}</template>
+  <template name="@license" description="license url name" id="net.sourceforge.phpdt.phpdoc.license" context="phpdoc" enabled="true">@license ${url} ${nameoflicense}</template>
+  <template name="@link" description="link url description" id="net.sourceforge.phpdt.phpdoc.link" context="phpdoc" enabled="true">@link ${url} ${description}</template>
+  <template name="@name" description="name globalvariable" id="net.sourceforge.phpdt.phpdoc.name" context="phpdoc" enabled="true">@name ${globalvariable}</template>
+  <template name="@package" description="package packagename" id="net.sourceforge.phpdt.phpdoc.package" context="phpdoc" enabled="true">@package ${packagename}</template>
+  <template name="@param" description="param datatype paramname description" id="net.sourceforge.phpdt.phpdoc.param1" context="phpdoc" enabled="true">@param ${datatype} ${paramname} ${description}</template>
+  <template name="@param" description="param datatype paramname" id="net.sourceforge.phpdt.phpdoc.param2" context="phpdoc" enabled="true">@param ${datatype} ${paramname}</template>
+  <template name="@return" description="return datatype description" id="net.sourceforge.phpdt.phpdoc.return" context="phpdoc" enabled="true">@return ${datatype} ${description}</template>
+  <template name="@see" description="see element" id="net.sourceforge.phpdt.phpdoc" context="phpdoc.see" enabled="true">@see ${element}</template><template name="@since" description="since version date" id="net.sourceforge.phpdt.phpdoc" context="phpdoc" enabled="true">@since ${version} - ${date}</template>
+  <template name="@staticvar" description="staticvar datatype description" id="net.sourceforge.phpdt.phpdoc.staticvar" context="phpdoc" enabled="true">@staticvar ${datatype} ${description}</template>
+  <template name="@subpackage" description="subpackage subpackagename" id="net.sourceforge.phpdt.phpdoc.subpackage" context="phpdoc" enabled="true">@subpackage ${subpackagename}</template>
+  <template name="@todo" description="@todo information_string" id="net.sourceforge.phpdt.phpdoc.todo" context="phpdoc" enabled="true">@todo ${information_string}</template>
+  <template name="@tutorial" description="tutorial string description" id="net.sourceforge.phpdt.phpdoc.tutorial" context="phpdoc" enabled="true">@tutorial ${string} ${description}</template>
+  <template name="@uses" description="uses element description" id="net.sourceforge.phpdt.phpdoc.uses" context="phpdoc" enabled="true">@uses ${element} ${description}</template>
+  <template name="@var" description="var datatype description" id="net.sourceforge.phpdt.phpdoc.var" context="phpdoc" enabled="true">@var ${datatype} ${description}</template>
+  <template name="@version" description="version versionstring" id="net.sourceforge.phpdt.phpdoc.version" context="phpdoc" enabled="true">@version ${versionstring}</template>
+ </templates> 
\ No newline at end of file