Examples of Jalopy


Examples of de.hunsicker.jalopy.Jalopy

      org.hybridlabs.source.beautifier.CharacterSequence sequence,
      File file) {
    initialize();

    JavaNode node = null;
    Jalopy jalopy = initializeJalopy();
    final PrintStream out = System.out;
    try {
      // redirecting System.out to log4j appender
      System.setOut(outToLog4J(out));

      jalopy.setInput(sequence.getString(), file.getAbsolutePath());

      node = jalopy.parse();
    } catch (NoClassDefFoundError e) {
      e.printStackTrace();
    } finally {
      cleanupJalopy();
      System.setOut(out);
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

    return pos;
  }

  protected void format(CharacterSequence sequence, File file) {
    Jalopy jalopy = initializeJalopy();
    try {
      jalopy.setInput(sequence.getString(), file.getAbsolutePath());
      StringBuffer sb = new StringBuffer();
      jalopy.setOutput(sb);
      jalopy.format();
      sequence.set(sb);
    } finally {
      cleanupJalopy();
    }
  }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

      cleanupJalopy();
    }
  }

  private Jalopy initializeJalopy() {
    Jalopy jalopy = new Jalopy();
    jalopy.setInspect(false);
    jalopy.setBackup(false);
    jalopy.setForce(false);
    // NOTE: the convention file is static (done during first initialize()
    // invocation)
    return jalopy;
  }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

            public void run() {
                try {
                    String input = doc.getText(0,doc.getLength());
                    StringWriter output = new StringWriter();
                   
                    Jalopy jal = new Jalopy();
                    if (rule!=null && rule.exists() && rule.isFile()){
                        try {
                            jal.setConvention(rule);
                        } catch (IOException ex) {
                            ex.printStackTrace();
                        }
                    }
                    jal.setInput(input,"what is this?");
                    jal.setOutput(output);
                    jal.format();
                    doc.remove(0,doc.getLength());
                    doc.insertString(0,output.getBuffer().toString(),null);
                } catch (BadLocationException ex) {
                    ex.printStackTrace();
                }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

     * @throws Exception Exception
     */
    private void formatFiles( File directory, String[] filesToFormat )
        throws FileNotFoundException, Exception
    {
        Jalopy jalopy = createJalopy();

        for ( int i = 0; i < filesToFormat.length; i++ )
        {
            File currentFile = new File( directory, filesToFormat[i] );

            jalopy.setInput( currentFile );

            jalopy.setOutput( currentFile );

            if ( isBackup() )
            {
                jalopy.setBackupDirectory( currentFile.getParentFile() );
            }

            jalopy.format();

            logMessage( jalopy, currentFile );
        }
    }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

     *
     * @return Jalopy
     */
    private Jalopy createJalopy()
    {
        Jalopy jalopy = new Jalopy();

        try
        {
            if ( ( convention != null ) && convention.exists() )
            {
                LOG.debug( "[jalopy] Using convention file : " + convention.getAbsoluteFile() );
                Jalopy.setConvention( convention );
            }
            else
            {
                LOG.warn( "[jalopy] Convention file does not exist: " + convention.getAbsoluteFile() );
                LOG.warn( "[jalopy] Using default convention : jalopy.xml");
                InputStream in = this.getClass().getClassLoader().getResourceAsStream( "plugin-resources/jalopy.xml" );
                Convention.importSettings( in, Convention.EXTENSION_XML );
            }
        }
        catch ( IOException ex )
        {
            ex.printStackTrace();
        }

        jalopy.setFileFormat( getFileFormat() );

        jalopy.setInspect( isInspect() );

        if ( !getHistoryPolicy().equalsIgnoreCase( "none" ) )
        {
            jalopy.setHistoryPolicy( History.Policy.valueOf( getHistoryPolicy() ) );
        }

        // TODO: what are the allowed values for historyMethod?
        //Convention settings = Convention.getInstance();
        //History.Method historyMethod = History.Method.valueOf( settings.get( ConventionKeys.HISTORY_METHOD,
        //                                                                     ConventionDefaults.HISTORY_METHOD ) );
        //jalopy.setHistoryMethod( historyMethod );

        jalopy.setBackup( isBackup() );

        jalopy.setForce( isForce() );

        return jalopy;
    }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

        // Beautify

        StringBuffer sb = new StringBuffer();

        Jalopy jalopy = new Jalopy();

        jalopy.setFileFormat(FileFormat.UNIX);
        jalopy.setInput(tempFile);
        jalopy.setOutput(sb);

        File jalopyXmlFile = new File("tools/jalopy.xml");

        if (!jalopyXmlFile.exists()) {
            jalopyXmlFile = new File("../tools/jalopy.xml");
        }

        if (!jalopyXmlFile.exists()) {
            jalopyXmlFile = new File("misc/jalopy.xml");
        }

        if (!jalopyXmlFile.exists()) {
            jalopyXmlFile = new File("../misc/jalopy.xml");
        }

        if (!jalopyXmlFile.exists()) {
            jalopyXmlFile = new File("../../misc/jalopy.xml");
        }

        try {
            Jalopy.setConvention(jalopyXmlFile);
        }
        catch (FileNotFoundException fnfe) {
        }

        if (jalopySettings == null) {
            jalopySettings = new HashMap<String, Object>();
        }

        Environment env = Environment.getInstance();

        // Author

        author = GetterUtil.getString(
                (String)jalopySettings.get("author"), author);

        env.set("author", author);

        // File name

        env.set("fileName", file.getName());

        Convention convention = Convention.getInstance();

        String classMask = "/**\n * @author $author$\n*/";

        convention.put(
                ConventionKeys.COMMENT_JAVADOC_TEMPLATE_CLASS,
                env.interpolate(classMask));

        convention.put(
                ConventionKeys.COMMENT_JAVADOC_TEMPLATE_INTERFACE,
                env.interpolate(classMask));

        jalopy.format();

        String newContent = sb.toString();

        // Remove double blank lines after the package or last import

View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

    }

    protected JavaNode createJavaNode(org.hybridlabs.source.beautifier.CharacterSequence sequence, File file) {
        initialize();

        Jalopy jalopy = initializeJalopy();
        jalopy.setInput(sequence.getString(), file.getAbsolutePath());
       
        JavaNode node = jalopy.parse();

        return node;
    }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

       
        return pos;
    }

    protected void format(CharacterSequence sequence, File file) {
        Jalopy jalopy = initializeJalopy();
        jalopy.setInput(sequence.getString(), file.getAbsolutePath());
        StringBuffer sb = new StringBuffer();
        jalopy.setOutput(sb);
        jalopy.format();
        sequence.set(sb);
    }
View Full Code Here

Examples of de.hunsicker.jalopy.Jalopy

        jalopy.format();
        sequence.set(sb);
    }

    private Jalopy initializeJalopy() {
        Jalopy jalopy = new Jalopy();
        jalopy.setInspect(false);
        jalopy.setBackup(false);
        jalopy.setForce(false);
        // NOTE: the convention file is static (done during first initialize() invocation)
        return jalopy;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.