X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java index 582eda6..0d8a251 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/wizards/NewTypeWizardPage.java @@ -18,6 +18,7 @@ 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; @@ -28,6 +29,7 @@ import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo; import net.sourceforge.phpdt.internal.corext.codemanipulation.StubUtility; import net.sourceforge.phpdt.internal.corext.template.php.JavaContext; import net.sourceforge.phpdt.internal.corext.template.php.Templates; +import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpdt.internal.ui.util.SWTUtil; import net.sourceforge.phpdt.internal.ui.wizards.NewWizardMessages; @@ -43,6 +45,7 @@ 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.CodeGeneration; import net.sourceforge.phpdt.ui.PreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -1321,17 +1324,17 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { // if (!isInnerClass) { lineDelimiter = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ // -// ICompilationUnit parentCU = pack.createCompilationUnit(clName + ".php", "", false, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ //$NON-NLS-2$ +// ICompilationUnit parentCU = pack.createCompilationUnit(clName + ".php", "", false, new SubProgressMonitor(monitor, 2)); //$NON-NLS-1$ //$NON-NLS-2$ // createdWorkingCopy = (ICompilationUnit) parentCU.getSharedWorkingCopy(null, JavaUI.getBufferFactory(), null); // // imports = new ImportsStructure(createdWorkingCopy, prefOrder, threshold, false); // // add an import that will be removed again. Having this import solves 14661 // imports.addImport(pack.getElementName(), getTypeName()); // -// String typeContent = constructTypeStub(new ImportsManager(imports), lineDelimiter); -// + String typeContent = constructTypeStub(lineDelimiter);//new ImportsManager(imports), lineDelimiter); + // String cuContent = constructCUContent(parentCU, typeContent, lineDelimiter); -// + // createdWorkingCopy.getBuffer().setContents(cuContent); // createdType = createdWorkingCopy.getType(clName); @@ -1493,25 +1496,25 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { /* * Called from createType to construct the source for this type */ - // private String constructTypeStub(ImportsManager imports, String lineDelimiter) { - // StringBuffer buf= new StringBuffer(); - // - // int modifiers= getModifiers(); - // buf.append(Flags.toString(modifiers)); - // if (modifiers != 0) { - // buf.append(' '); - // } - // buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$ - // buf.append(getTypeName()); - // writeSuperClass(buf, imports); - // writeSuperInterfaces(buf, imports); - // buf.append('{'); - // buf.append(lineDelimiter); - // buf.append(lineDelimiter); - // buf.append('}'); - // buf.append(lineDelimiter); - // return buf.toString(); - // } + private String constructTypeStub(String lineDelimiter) { // ImportsManager imports, String lineDelimiter) { + StringBuffer buf= new StringBuffer(); + + int modifiers= getModifiers(); + buf.append(Flags.toString(modifiers)); + if (modifiers != 0) { + buf.append(' '); + } + buf.append(fIsClass ? "class " : "interface "); //$NON-NLS-2$ //$NON-NLS-1$ + buf.append(getTypeName()); +// writeSuperClass(buf, imports); +// writeSuperInterfaces(buf, imports); + buf.append('{'); + buf.append(lineDelimiter); + buf.append(lineDelimiter); + buf.append('}'); + buf.append(lineDelimiter); + return buf.toString(); + } /** * @deprecated Overwrite createTypeMembers(IType, IImportsManager, IProgressMonitor) instead @@ -1582,24 +1585,24 @@ public abstract class NewTypeWizardPage extends NewContainerWizardPage { * @return the type comment or null if a type comment * is not desired */ - // protected String getTypeComment(ICompilationUnit parentCU) { - // if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEGEN_ADD_COMMENTS)) { - // try { - // StringBuffer typeName= new StringBuffer(); - // if (isEnclosingTypeSelected()) { - // typeName.append(JavaModelUtil.getTypeQualifiedName(getEnclosingType())).append('.'); - // } - // typeName.append(getTypeName()); - // String comment= CodeGeneration.getTypeComment(parentCU, typeName.toString(), String.valueOf('\n')); - // if (comment != null && isValidComment(comment)) { - // return comment; - // } - // } catch (CoreException e) { - // PHPeclipsePlugin.log(e); - // } - // } - // return null; - // } + protected String getTypeComment(ICompilationUnit parentCU) { + if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CODEGEN_ADD_COMMENTS)) { + try { + StringBuffer typeName= new StringBuffer(); + if (isEnclosingTypeSelected()) { + typeName.append(JavaModelUtil.getTypeQualifiedName(getEnclosingType())).append('.'); + } + typeName.append(getTypeName()); + String comment= CodeGeneration.getTypeComment(parentCU, typeName.toString(), String.valueOf('\n')); + if (comment != null && isValidComment(comment)) { + return comment; + } + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + return null; + } /** * @deprecated Use getTemplate(String,ICompilationUnit,int)