37eee59461ce7961e7210c9562efff1c2d1180b7
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / codemanipulation / StubUtility.java
1 /*
2  * (c) Copyright IBM Corp. 2000, 2001.
3  * All Rights Reserved.
4  */
5 package net.sourceforge.phpdt.internal.corext.codemanipulation;
6
7 import java.util.ArrayList;
8 import java.util.Arrays;
9 import java.util.List;
10
11 import org.eclipse.swt.SWT;
12
13 import org.eclipse.jface.text.BadLocationException;
14 import org.eclipse.jface.text.IDocument;
15
16 //import org.phpeclipse.phpdt.core.Flags;
17 //import org.phpeclipse.phpdt.core.IBuffer;
18 import net.sourceforge.phpdt.core.ICodeFormatter;
19 //import org.phpeclipse.phpdt.core.ICompilationUnit;
20 //import org.phpeclipse.phpdt.core.IJavaElement;
21 //import org.phpeclipse.phpdt.core.IJavaProject;
22 //import org.phpeclipse.phpdt.core.IMethod;
23 //import org.phpeclipse.phpdt.core.IParent;
24 //import org.phpeclipse.phpdt.core.ISourceReference;
25 //import org.phpeclipse.phpdt.core.IType;
26 //import org.phpeclipse.phpdt.core.ITypeHierarchy;
27 import net.sourceforge.phpeclipse.PHPCore;
28 //import org.phpeclipse.phpdt.core.JavaModelException;
29 //import org.phpeclipse.phpdt.core.Signature;
30 import net.sourceforge.phpdt.core.ToolFactory;
31
32 //import net.sourceforge.phpdt.internal.corext.util.CodeFormatterUtil;
33 //import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil;
34 import net.sourceforge.phpdt.internal.corext.util.Strings;
35
36 public class StubUtility {
37         
38         
39 //      public static class GenStubSettings extends CodeGenerationSettings {
40 //      
41 //              public boolean callSuper;
42 //              public boolean methodOverwrites;
43 //              public boolean noBody;
44 //              
45 //              public GenStubSettings(CodeGenerationSettings settings) {
46 //                      settings.setSettings(this);     
47 //              }
48 //              
49 //              public GenStubSettings() {
50 //              }
51 //                      
52 //      }
53 //      
54 //
55 //      /**
56 //       * Generates a stub. Given a template method, a stub with the same signature
57 //       * will be constructed so it can be added to a type.
58 //       * @param destTypeName The name of the type to which the method will be added to (Used for the constructor)
59 //       * @param method A method template (method belongs to different type than the parent)
60 //       * @param options Options as defined above (<code>GenStubSettings</code>)
61 //       * @param imports Imports required by the stub are added to the imports structure. If imports structure is <code>null</code>
62 //       * all type names are qualified.
63 //       * @throws JavaModelException
64 //       */
65 //      public static String genStub(String destTypeName, IMethod method, GenStubSettings settings, IImportsStructure imports) throws JavaModelException {
66 //              IType declaringtype= method.getDeclaringType(); 
67 //              StringBuffer buf= new StringBuffer();
68 //              String methodName= method.getElementName();
69 //              String[] paramTypes= method.getParameterTypes();
70 //              String[] paramNames= method.getParameterNames();
71 //              String[] excTypes= method.getExceptionTypes();
72 //              String retTypeSig= method.getReturnType();
73 //              int flags= method.getFlags();
74 //              boolean isConstructor= method.isConstructor();
75 //              
76 //              int lastParam= paramTypes.length -1;            
77 //              
78 //              
79 //              if (settings.createComments) {
80 //                      if (isConstructor) {
81 //                              String desc= "Constructor for " + destTypeName; //$NON-NLS-1$
82 //                              genJavaDocStub(desc, paramNames, Signature.SIG_VOID, excTypes, buf);
83 //                      } else {                        
84 //                              // php doc
85 //                              if (settings.methodOverwrites) {
86 //                                      boolean isDeprecated= Flags.isDeprecated(flags);
87 //                                      genJavaDocSeeTag(declaringtype, methodName, paramTypes, settings.createNonJavadocComments, isDeprecated, buf);
88 //                              } else {
89 //                                      // generate a default php doc comment
90 //                                      String desc= "Method " + methodName; //$NON-NLS-1$
91 //                                      genJavaDocStub(desc, paramNames, retTypeSig, excTypes, buf);
92 //                              }
93 //                      }
94 //                      buf.append('\n');
95 //              }
96 //              
97 //              if (Flags.isPublic(flags) || isConstructor || (declaringtype.isInterface() && !settings.noBody)) {
98 //                      buf.append("public "); //$NON-NLS-1$
99 //              } else if (Flags.isProtected(flags)) {
100 //                      buf.append("protected "); //$NON-NLS-1$
101 //              } else if (Flags.isPrivate(flags)) {
102 //                      buf.append("private "); //$NON-NLS-1$
103 //              }
104 //              if (Flags.isSynchronized(flags)) {
105 //                      buf.append("synchronized "); //$NON-NLS-1$
106 //              }               
107 //              if (Flags.isVolatile(flags)) {
108 //                      buf.append("volatile "); //$NON-NLS-1$
109 //              }
110 //              if (Flags.isStrictfp(flags)) {
111 //                      buf.append("strictfp "); //$NON-NLS-1$
112 //              }
113 //              if (Flags.isStatic(flags)) {
114 //                      buf.append("static "); //$NON-NLS-1$
115 //              }               
116 //                      
117 //              if (isConstructor) {
118 //                      buf.append(destTypeName);
119 //              } else {
120 //                      String retTypeFrm;
121 //                      if (!isPrimitiveType(retTypeSig)) {
122 //                              retTypeFrm= resolveAndAdd(retTypeSig, declaringtype, imports);
123 //                      } else {
124 //                              retTypeFrm= Signature.toString(retTypeSig);
125 //                      }
126 //                      buf.append(retTypeFrm);
127 //                      buf.append(' ');
128 //                      buf.append(methodName);
129 //              }
130 //              buf.append('(');
131 //              for (int i= 0; i <= lastParam; i++) {
132 //                      String paramTypeSig= paramTypes[i];
133 //                      String paramTypeFrm;
134 //                      
135 //                      if (!isPrimitiveType(paramTypeSig)) {
136 //                              paramTypeFrm= resolveAndAdd(paramTypeSig, declaringtype, imports);
137 //                      } else {
138 //                              paramTypeFrm= Signature.toString(paramTypeSig);
139 //                      }
140 //                      buf.append(paramTypeFrm);
141 //                      buf.append(' ');
142 //                      buf.append(paramNames[i]);
143 //                      if (i < lastParam) {
144 //                              buf.append(", "); //$NON-NLS-1$
145 //                      }
146 //              }
147 //              buf.append(')');
148 //              
149 //              int lastExc= excTypes.length - 1;
150 //              if (lastExc >= 0) {
151 //                      buf.append(" throws "); //$NON-NLS-1$
152 //                      for (int i= 0; i <= lastExc; i++) {
153 //                              String excTypeSig= excTypes[i];
154 //                              String excTypeFrm= resolveAndAdd(excTypeSig, declaringtype, imports);
155 //                              buf.append(excTypeFrm);
156 //                              if (i < lastExc) {
157 //                                      buf.append(", "); //$NON-NLS-1$
158 //                              }
159 //                      }
160 //              }
161 //              if (settings.noBody) {
162 //                      buf.append(";\n\n"); //$NON-NLS-1$
163 //              } else {
164 //                      buf.append(" {\n\t"); //$NON-NLS-1$
165 //                      if (!settings.callSuper) {
166 //                              if (retTypeSig != null && !retTypeSig.equals(Signature.SIG_VOID)) {
167 //                                      buf.append('\t');
168 //                                      if (!isPrimitiveType(retTypeSig) || Signature.getArrayCount(retTypeSig) > 0) {
169 //                                              buf.append("return null;\n\t"); //$NON-NLS-1$
170 //                                      } else if (retTypeSig.equals(Signature.SIG_BOOLEAN)) {
171 //                                              buf.append("return false;\n\t"); //$NON-NLS-1$
172 //                                      } else {
173 //                                              buf.append("return 0;\n\t"); //$NON-NLS-1$
174 //                                      }
175 //                              }
176 //                      } else {
177 //                              buf.append('\t');
178 //                              if (!isConstructor) {
179 //                                      if (!Signature.SIG_VOID.equals(retTypeSig)) {
180 //                                              buf.append("return "); //$NON-NLS-1$
181 //                                      }
182 //                                      buf.append("super."); //$NON-NLS-1$
183 //                                      buf.append(methodName);
184 //                              } else {
185 //                                      buf.append("super"); //$NON-NLS-1$
186 //                              }
187 //                              buf.append('(');                        
188 //                              for (int i= 0; i <= lastParam; i++) {
189 //                                      buf.append(paramNames[i]);
190 //                                      if (i < lastParam) {
191 //                                              buf.append(", "); //$NON-NLS-1$
192 //                                      }
193 //                              }
194 //                              buf.append(");\n\t"); //$NON-NLS-1$
195 //                      }
196 //                      buf.append("}\n");                       //$NON-NLS-1$
197 //              }
198 //              return buf.toString();
199 //      }
200 //      
201 //      private static boolean isSet(int options, int flag) {
202 //              return (options & flag) != 0;
203 //      }       
204 //
205 //      private static boolean isPrimitiveType(String typeName) {
206 //              char first= Signature.getElementType(typeName).charAt(0);
207 //              return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED);
208 //      }
209 //
210 //      private static String resolveAndAdd(String refTypeSig, IType declaringType, IImportsStructure imports) throws JavaModelException {
211 //              String resolvedTypeName= JavaModelUtil.getResolvedTypeName(refTypeSig, declaringType);
212 //              if (resolvedTypeName != null) {
213 //                      StringBuffer buf= new StringBuffer();
214 //                      if (imports != null) {
215 //                              buf.append(imports.addImport(resolvedTypeName));
216 //                      } else {
217 //                              buf.append(resolvedTypeName);
218 //                      }
219 //                      int arrayCount= Signature.getArrayCount(refTypeSig);
220 //                      for (int i= 0; i < arrayCount; i++) {
221 //                              buf.append("[]"); //$NON-NLS-1$
222 //                      }
223 //                      return buf.toString();
224 //              }
225 //              return Signature.toString(refTypeSig);
226 //      }
227 //      
228 //      /**
229 //       * Generates a default JavaDoc comment stub for a method.
230 //       */
231 //      public static void genJavaDocStub(String descr, String[] paramNames, String retTypeSig, String[] excTypeSigs, StringBuffer buf) {
232 //              buf.append("/**\n"); //$NON-NLS-1$
233 //              buf.append(" * "); buf.append(descr); buf.append(".\n"); //$NON-NLS-2$ //$NON-NLS-1$
234 //              for (int i= 0; i < paramNames.length; i++) {
235 //                      buf.append(" * @param "); buf.append(paramNames[i]); buf.append('\n'); //$NON-NLS-1$
236 //              }
237 //              if (retTypeSig != null && !retTypeSig.equals(Signature.SIG_VOID)) {
238 //                      String simpleName= Signature.getSimpleName(Signature.toString(retTypeSig));
239 //                      buf.append(" * @return "); buf.append(simpleName); buf.append('\n'); //$NON-NLS-1$
240 //              }
241 //              if (excTypeSigs != null) {
242 //                      for (int i= 0; i < excTypeSigs.length; i++) {
243 //                              String simpleName= Signature.getSimpleName(Signature.toString(excTypeSigs[i]));
244 //                              buf.append(" * @throws "); buf.append(simpleName); buf.append('\n'); //$NON-NLS-1$
245 //                      }
246 //              }
247 //              buf.append(" */"); //$NON-NLS-1$
248 //      }
249 //      
250 //      /**
251 //       * Generates a '@see' tag to the defined method.
252 //       */
253 //      public static void genJavaDocSeeTag(IType declaringType, String methodName, String[] paramTypes, boolean nonJavaDocComment, boolean isDeprecated, StringBuffer buf) throws JavaModelException {
254 //              String[] fullParamNames= new String[paramTypes.length];
255 //              for (int i= 0; i < paramTypes.length; i++) {
256 //                      fullParamNames[i]= JavaModelUtil.getResolvedTypeName(paramTypes[i], declaringType);
257 //              }
258 //              String fullTypeName= JavaModelUtil.getFullyQualifiedName(declaringType);
259 //              
260 //              genJavaDocSeeTag(fullTypeName, methodName, fullParamNames, nonJavaDocComment, isDeprecated, buf);
261 //      }
262 //      
263 //      /**
264 //       * Generates a '@see' tag to the defined method.
265 //       */
266 //      public static void genJavaDocSeeTag(String fullyQualifiedTypeName, String methodName, String[] fullParamTypeNames, boolean nonJavaDocComment, boolean isDeprecated, StringBuffer buf) throws JavaModelException {
267 //              // create a @see link
268 //              buf.append("/*"); //$NON-NLS-1$
269 //              if (!nonJavaDocComment) {
270 //                      buf.append('*');
271 //              } else {
272 //                      buf.append(" (non-Javadoc)"); //$NON-NLS-1$
273 //              }
274 //              buf.append("\n * @see "); //$NON-NLS-1$
275 //              buf.append(fullyQualifiedTypeName);
276 //              buf.append('#'); 
277 //              buf.append(methodName);
278 //              buf.append('(');
279 //              for (int i= 0; i < fullParamTypeNames.length; i++) {
280 //                      if (i > 0) {
281 //                              buf.append(", "); //$NON-NLS-1$
282 //                      }
283 //                      buf.append(fullParamTypeNames[i]);
284 //              }
285 //              buf.append(")\n"); //$NON-NLS-1$
286 //              if (isDeprecated) {
287 //                      buf.append(" * @deprecated\n"); //$NON-NLS-1$
288 //              }
289 //              buf.append(" */"); //$NON-NLS-1$
290 //      }       
291 //      
292 //      
293 //
294 //      /**
295 //       * Finds a method in a list of methods.
296 //       * @return The found method or null, if nothing found
297 //       */
298 //      private static IMethod findMethod(IMethod method, List allMethods) throws JavaModelException {
299 //              String name= method.getElementName();
300 //              String[] paramTypes= method.getParameterTypes();
301 //              boolean isConstructor= method.isConstructor();
302 //
303 //              for (int i= allMethods.size() - 1; i >= 0; i--) {
304 //                      IMethod curr= (IMethod) allMethods.get(i);
305 //                      if (JavaModelUtil.isSameMethodSignature(name, paramTypes, isConstructor, curr)) {
306 //                              return curr;
307 //                      }                       
308 //              }
309 //              return null;
310 //      }
311
312
313         /**
314          * Creates needed constructors for a type.
315          * @param type The type to create constructors for
316          * @param supertype The type's super type
317          * @param settings Options for comment generation
318          * @param imports Required imports are added to the import structure. Structure can be <code>null</code>, types are qualified then.
319          * @return Returns the generated stubs or <code>null</code> if the creation has been canceled
320          */
321 //      public static String[] evalConstructors(IType type, IType supertype, CodeGenerationSettings settings, IImportsStructure imports) throws JavaModelException {
322 //              IMethod[] superMethods= supertype.getMethods();
323 //              String typeName= type.getElementName();
324 //              IMethod[] methods= type.getMethods();
325 //              GenStubSettings genStubSettings= new GenStubSettings(settings);
326 //              genStubSettings.callSuper= true;
327 //              ArrayList newMethods= new ArrayList(superMethods.length);
328 //              for (int i= 0; i < superMethods.length; i++) {
329 //                      IMethod curr= superMethods[i];
330 //                      if (curr.isConstructor() && (JavaModelUtil.isVisible(curr, type.getPackageFragment()) || Flags.isProtected(curr.getFlags()))) {
331 //                              if (JavaModelUtil.findMethod(typeName, curr.getParameterTypes(), true, methods) == null) {
332 //                                      String newStub= genStub(typeName, superMethods[i], genStubSettings, imports);
333 //                                      newMethods.add(newStub);
334 //                              }
335 //                      }
336 //              }
337 //              return (String[]) newMethods.toArray(new String[newMethods.size()]);
338 //      }
339 //
340 //      /**
341 //       * Searches for unimplemented methods of a type.
342 //       * @param isSubType If set, the evaluation is for a subtype of the given type. If not set, the
343 //       * evaluation is for the type itself.
344 //       * @param settings Options for comment generation
345 //       * @param selectionQuery If not null will select the methods to implement.
346 //       * @param imports Required imports are added to the import structure. Structure can be <code>null</code>, types are qualified then.
347 //       * @return Returns the generated stubs or <code>null</code> if the creation has been canceled
348 //       */
349 //      public static String[] evalUnimplementedMethods(IType type, ITypeHierarchy hierarchy, boolean isSubType, CodeGenerationSettings settings, 
350 //                              IOverrideMethodQuery selectionQuery, IImportsStructure imports) throws JavaModelException {
351 //              List allMethods= new ArrayList();
352 //              List toImplement= new ArrayList();
353 //
354 //              IMethod[] typeMethods= type.getMethods();
355 //              for (int i= 0; i < typeMethods.length; i++) {
356 //                      IMethod curr= typeMethods[i];
357 //                      if (!curr.isConstructor() && !Flags.isStatic(curr.getFlags()) && !Flags.isPrivate(curr.getFlags())) {
358 //                              allMethods.add(curr);
359 //                      }
360 //              }
361 //
362 //              IType[] superTypes= hierarchy.getAllSuperclasses(type);
363 //              for (int i= 0; i < superTypes.length; i++) {
364 //                      IMethod[] methods= superTypes[i].getMethods();
365 //                      for (int k= 0; k < methods.length; k++) {
366 //                              IMethod curr= methods[k];
367 //                              if (!curr.isConstructor() && !Flags.isStatic(curr.getFlags()) && !Flags.isPrivate(curr.getFlags())) {
368 //                                      if (findMethod(curr, allMethods) == null) {
369 //                                              allMethods.add(curr);
370 //                                      }
371 //                              }
372 //                      }
373 //              }
374 //
375 //              // do not call super
376 //              for (int i= 0; i < allMethods.size(); i++) {
377 //                      IMethod curr= (IMethod) allMethods.get(i);
378 //                      if ((Flags.isAbstract(curr.getFlags()) || curr.getDeclaringType().isInterface()) && (isSubType || !type.equals(curr.getDeclaringType()))) {
379 //                              // implement all abstract methods
380 //                              toImplement.add(curr);
381 //                      }
382 //              }
383 //
384 //              IType[] superInterfaces= hierarchy.getAllSuperInterfaces(type);
385 //              for (int i= 0; i < superInterfaces.length; i++) {
386 //                      IMethod[] methods= superInterfaces[i].getMethods();
387 //                      for (int k= 0; k < methods.length; k++) {
388 //                              IMethod curr= methods[k];
389 //
390 //                              // binary interfaces can contain static initializers (variable intializations)
391 //                              // 1G4CKUS
392 //                              if (!Flags.isStatic(curr.getFlags())) {
393 //                                      IMethod impl= findMethod(curr, allMethods);
394 //                                      if (impl == null || ((curr.getExceptionTypes().length < impl.getExceptionTypes().length) && !Flags.isFinal(impl.getFlags()))) {
395 //                                              if (impl != null) {
396 //                                                      allMethods.remove(impl);
397 //                                              }
398 //                                              // implement an interface method when it does not exist in the hierarchy
399 //                                              // or when it throws less exceptions that the implemented
400 //                                              toImplement.add(curr);
401 //                                              allMethods.add(curr);
402 //                                      }
403 //                              }
404 //                      }
405 //              }
406 //              IMethod[] toImplementArray= (IMethod[]) toImplement.toArray(new IMethod[toImplement.size()]);
407 //              if (selectionQuery != null) {
408 //                      if (!isSubType) {
409 //                              allMethods.removeAll(Arrays.asList(typeMethods));
410 //                      }
411 //                      // remove finals
412 //                      for (int i= allMethods.size() - 1; i >= 0; i--) {
413 //                              IMethod curr= (IMethod) allMethods.get(i);
414 //                              if (Flags.isFinal(curr.getFlags())) {
415 //                                      allMethods.remove(i);
416 //                              }
417 //                      }
418 //                      IMethod[] choice= (IMethod[]) allMethods.toArray(new IMethod[allMethods.size()]);
419 //                      toImplementArray= selectionQuery.select(choice, toImplementArray, hierarchy);
420 //                      if (toImplementArray == null) {
421 //                              //cancel pressed
422 //                              return null;
423 //                      }
424 //              }
425 //              GenStubSettings genStubSettings= new GenStubSettings(settings);
426 //              genStubSettings.methodOverwrites= true;
427 //              String[] result= new String[toImplementArray.length];
428 //              for (int i= 0; i < toImplementArray.length; i++) {
429 //                      IMethod curr= toImplementArray[i];
430 //                      IMethod overrides= JavaModelUtil.findMethodImplementationInHierarchy(hierarchy, type, curr.getElementName(), curr.getParameterTypes(), curr.isConstructor());
431 //                      genStubSettings.callSuper= (overrides != null);
432 //                                              
433 //                      IMethod desc= JavaModelUtil.findMethodDeclarationInHierarchy(hierarchy, type, curr.getElementName(), curr.getParameterTypes(), curr.isConstructor());
434 //                      if (desc != null) {
435 //                              curr= desc;
436 //                      }
437 //                      result[i]= genStub(type.getElementName(), curr, genStubSettings, imports);
438 //              }
439 //              return result;
440 //      }
441
442         /**
443          * Examines a string and returns the first line delimiter found.
444          */
445 //      public static String getLineDelimiterUsed(IJavaElement elem) throws JavaModelException {
446 //              ICompilationUnit cu= (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT);
447 //              if (cu != null && cu.exists()) {
448 //                      IBuffer buf= cu.getBuffer();
449 //                      int length= buf.getLength();
450 //                      for (int i= 0; i < length; i++) {
451 //                              char ch= buf.getChar(i);
452 //                              if (ch == SWT.CR) {
453 //                                      if (i + 1 < length) {
454 //                                              if (buf.getChar(i + 1) == SWT.LF) {
455 //                                                      return "\r\n"; //$NON-NLS-1$
456 //                                              }
457 //                                      }
458 //                                      return "\r"; //$NON-NLS-1$
459 //                              } else if (ch == SWT.LF) {
460 //                                      return "\n"; //$NON-NLS-1$
461 //                              }
462 //                      }
463 //              }
464 //              return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
465 //      }
466
467         /**
468          * Embodies the policy which line delimiter to use when inserting into
469          * a document.
470          */     
471         public static String getLineDelimiterFor(IDocument doc) {
472                 // new for: 1GF5UU0: ITPJUI:WIN2000 - "Organize Imports" in php editor inserts lines in wrong format
473                 String lineDelim= null;
474                 try {
475                         lineDelim= doc.getLineDelimiter(0);
476                 } catch (BadLocationException e) {
477                 }
478                 if (lineDelim == null) {
479                         String systemDelimiter= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
480                         String[] lineDelims= doc.getLegalLineDelimiters();
481                         for (int i= 0; i < lineDelims.length; i++) {
482                                 if (lineDelims[i].equals(systemDelimiter)) {
483                                         lineDelim= systemDelimiter;
484                                         break;
485                                 }
486                         }
487                         if (lineDelim == null) {
488                                 lineDelim= lineDelims.length > 0 ? lineDelims[0] : systemDelimiter;
489                         }
490                 }
491                 return lineDelim;
492         }
493
494
495         /**
496          * Evaluates the indention used by a Java element. (in tabulators)
497          */     
498 //      public static int getIndentUsed(IJavaElement elem) throws JavaModelException {
499 //              if (elem instanceof ISourceReference) {
500 //                      ICompilationUnit cu= (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT);
501 //                      if (cu != null) {
502 //                              IBuffer buf= cu.getBuffer();
503 //                              int offset= ((ISourceReference)elem).getSourceRange().getOffset();
504 //                              int i= offset;
505 //                              // find beginning of line
506 //                              while (i > 0 && !Strings.isLineDelimiterChar(buf.getChar(i - 1)) ){
507 //                                      i--;
508 //                              }
509 //                              return Strings.computeIndent(buf.getText(i, offset - i), CodeFormatterUtil.getTabWidth());
510 //                      }
511 //              }
512 //              return 0;
513 //      }
514         
515         public static String codeFormat(String sourceString, int initialIndentationLevel, String lineDelim) {
516                 ICodeFormatter formatter= ToolFactory.createDefaultCodeFormatter(null);
517                 return formatter.format(sourceString, initialIndentationLevel, null, lineDelim);
518         }
519         
520         /**
521          * Returns the element after the give element.
522          */
523 //      public static IJavaElement findNextSibling(IJavaElement member) throws JavaModelException {
524 //              IJavaElement parent= member.getParent();
525 //              if (parent instanceof IParent) {
526 //                      IJavaElement[] elements= ((IParent)parent).getChildren();
527 //                      for (int i= elements.length - 2; i >= 0 ; i--) {
528 //                              if (member.equals(elements[i])) {
529 //                                      return elements[i+1];
530 //                              }
531 //                      }
532 //              }
533 //              return null;
534 //      }
535 //      
536 //      public static String getTodoTaskTag(IJavaProject project) {
537 //              String markers= null;
538 //              if (project == null) {
539 //                      markers= JavaCore.getOption(JavaCore.COMPILER_TASK_TAGS);
540 //              } else {
541 //                      markers= project.getOption(JavaCore.COMPILER_TASK_TAGS, true);
542 //              }
543 //              
544 //              if (markers != null && markers.length() > 0) {
545 //                      int idx= markers.indexOf(',');
546 //                      if (idx == -1) {
547 //                              return markers;
548 //                      } else {
549 //                              return markers.substring(0, idx);
550 //                      }
551 //              }
552 //              return null;
553 //      }
554
555 }