A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / phpdoc / PHPDocUtil.java
index 1ef819f..0d477e1 100644 (file)
@@ -10,75 +10,84 @@ import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation;
  */
 public class PHPDocUtil {
 
-  /**
-   * Generate a PHPDoc hover text if possible
-   * 
-   * @param hoverInfoBuffer
-   * @param filename
-   * @param location
-   */
-  public static void appendPHPDoc(StringBuffer hoverInfoBuffer, String filename, PHPIdentifierLocation location) {
-    FileReader phpFileReader;
-    hoverInfoBuffer.append(location.toString());
-    hoverInfoBuffer.append(" - <b>");
-    try {
-                       hoverInfoBuffer.append( getUsage(filename, location) );
+       /**
+        * Generate a PHPDoc hover text if possible
+        * 
+        * @param hoverInfoBuffer
+        * @param filename
+        * @param location
+        */
+       public static void appendPHPDoc(StringBuffer hoverInfoBuffer,
+                       String filename, PHPIdentifierLocation location) {
+               FileReader phpFileReader;
+               hoverInfoBuffer.append(location.toString());
+               hoverInfoBuffer.append(" - <b>");
+               try {
+                       hoverInfoBuffer.append(getUsage(filename, location));
                        hoverInfoBuffer.append("</b><br>");
 
-      //       read the phpdoc for the function
-      if (location.getPHPDocOffset() >= 0) {
-        phpFileReader = new FileReader(filename);
-        char[] phpDocDeclarationCharArray = new char[location.getPHPDocLength()];
-        phpFileReader.skip(location.getPHPDocOffset());
-        phpFileReader.read(phpDocDeclarationCharArray, 0, location.getPHPDocLength());
-        PHPDocCharArrayCommentReader phpdocConverter = new PHPDocCharArrayCommentReader(phpDocDeclarationCharArray);
-        hoverInfoBuffer.append(phpdocConverter.getString());
-//        hoverInfoBuffer.append("<br><br>");
-        phpFileReader.close();
-      }
+                       // read the phpdoc for the function
+                       if (location.getPHPDocOffset() >= 0) {
+                               phpFileReader = new FileReader(filename);
+                               char[] phpDocDeclarationCharArray = new char[location
+                                               .getPHPDocLength()];
+                               phpFileReader.skip(location.getPHPDocOffset());
+                               phpFileReader.read(phpDocDeclarationCharArray, 0, location
+                                               .getPHPDocLength());
+                               PHPDocCharArrayCommentReader phpdocConverter = new PHPDocCharArrayCommentReader(
+                                               phpDocDeclarationCharArray);
+                               hoverInfoBuffer.append(phpdocConverter.getString());
+                               // hoverInfoBuffer.append("<br><br>");
+                               phpFileReader.close();
+                       }
 
-    } catch (IOException e) {
-      return;
-    }
-  }
+               } catch (IOException e) {
+                       return;
+               }
+       }
 
-  public static String getUsage(String filename, PHPIdentifierLocation location) {
-    FileReader phpFileReader;
-    String usage = location.getUsage();
-    if (usage!=null) {
-       return usage;
-    }
-    usage = "";
-    try {
-                       
-      phpFileReader = new FileReader(filename);
-      // read the function declaration
-      if (location.getOffset() >= 0 && (location.isMethod() || location.isConstructor() || location.isFunction() || location.isDefine())) {
-        char[] functionDeclarationCharArray = new char[256];
-        int offset = location.getOffset();
-        phpFileReader.skip(offset);
-        int length = phpFileReader.read(functionDeclarationCharArray, 0, 256);
-        if (length == -1) {
-          length = 256;
-        }
-        for (int i = 0; i < length; i++) {
-          if (functionDeclarationCharArray[i] == ')') {
-            length = i + 1;
-            break;
-          }
-          if (functionDeclarationCharArray[i] == '{' || functionDeclarationCharArray[i] == '}') {
-            length = i;
-            break;
-          }
-        }
+       public static String getUsage(String filename,
+                       PHPIdentifierLocation location) {
+               FileReader phpFileReader;
+               String usage = location.getUsage();
+               if (usage != null) {
+                       return usage;
+               }
+               usage = "";
+               try {
+
+                       phpFileReader = new FileReader(filename);
+                       // read the function declaration
+                       if (location.getOffset() >= 0
+                                       && (location.isMethod() || location.isConstructor()
+                                                       || location.isFunction() || location.isDefine())) {
+                               char[] functionDeclarationCharArray = new char[256];
+                               int offset = location.getOffset();
+                               phpFileReader.skip(offset);
+                               int length = phpFileReader.read(functionDeclarationCharArray,
+                                               0, 256);
+                               if (length == -1) {
+                                       length = 256;
+                               }
+                               for (int i = 0; i < length; i++) {
+                                       if (functionDeclarationCharArray[i] == ')') {
+                                               length = i + 1;
+                                               break;
+                                       }
+                                       if (functionDeclarationCharArray[i] == '{'
+                                                       || functionDeclarationCharArray[i] == '}') {
+                                               length = i;
+                                               break;
+                                       }
+                               }
                                usage = new String(functionDeclarationCharArray, 0, length);
-      }
-      phpFileReader.close();
-    } catch (IOException e) {
-      // do nothing
-    }
-    // cache the usage string:
+                       }
+                       phpFileReader.close();
+               } catch (IOException e) {
+                       // do nothing
+               }
+               // cache the usage string:
                location.setUsage(usage);
-    return usage;
-  }
+               return usage;
+       }
 }