Package net.sf.gluebooster.java.booster.essentials.sourcecode

Examples of net.sf.gluebooster.java.booster.essentials.sourcecode.ClassOrInterfaceSource


  @Test
  public void testGetSourcecode() throws Exception{
    String text = "line1;\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9";
   
    ClassOrInterfaceSource source = new ClassOrInterfaceSource(text);
   
    String code = source.getSourcecode(3, Integer.MAX_VALUE);
    Assert.assertTrue(code.contains("3"));
  }
View Full Code Here


   *            the file which source is wanted
   * @return the source of the file
   */
  private ClassOrInterfaceSource getSourceFile(File file) throws IOException{
    if (! sourceFiles.containsKey(file)){
      ClassOrInterfaceSource source = new ClassOrInterfaceSource(file);
      sourceFiles.put(file, source);
    }
     
    return sourceFiles.get(file);
  }
View Full Code Here

    if (endline == -1 || endline < startline)
      endline = Integer.MAX_VALUE;

    
   
    ClassOrInterfaceSource source = getSourceFile(method.position().file());
    String result = source.getSourcecode(startline, endline);
    // the result may still contain the documenation and annotation parts of
    // the next method

    // so remove everything after the end of the method
    int index = result.lastIndexOf('}'); // the end of the method
View Full Code Here

    if (constructorcount > 1)
      return false;
   
   
    SourcePosition sourcecodePosition = constructor.position();
    ClassOrInterfaceSource source =  new DocBoostUtils().getSourceFile(sourcecodePosition.file());
    String declarationLine = source.getSourcecode(sourcecodePosition.line(), sourcecodePosition.line() +1);
    for (String word: declarationLine.split("\\s")) {//whitespace
      if ("class".equals(word)) //then the line is probable the class definition line
        return true;
    }
   
View Full Code Here

TOP

Related Classes of net.sf.gluebooster.java.booster.essentials.sourcecode.ClassOrInterfaceSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.