Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.Refactorer$PrettyPrint


        }
       
        // Okay, the basics check out.
        System.out.print("Renaming " + oldNameString + " to " + newNameString + "...");
        CompilerMessageLogger messageLogger = new MessageLogger();
        Refactorer refactorer = new Refactorer.Rename(getWorkspaceManager().getWorkspace().asModuleContainer(), getWorkspaceManager().getTypeChecker(), oldName, newName, category);

        refactorer.setStatusListener(new Refactorer.StatusListener() {
            public void willUseResource(ModuleSourceDefinition resource) {
                System.out.print(".");
            }
            public void doneUsingResource(ModuleSourceDefinition resource) {
            }
        });

        refactorer.calculateModifications(messageLogger);

        if(messageLogger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
            System.out.println("");
            dumpCompilerMessages(messageLogger);
            return;
        }

        refactorer.apply(messageLogger);
        System.out.println("");

        if(messageLogger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
            dumpCompilerMessages(messageLogger);
            return;
        }

        if(!compileWorkspace(false, true, false)) {
            System.out.print("Compile failed, rolling back changes...");
            refactorer.undo(messageLogger);
            System.out.println("");
            return;
        }

        if(category == Category.MODULE_NAME) {
View Full Code Here


        }

        iceLogger.log(Level.INFO, "Pretty printing " + moduleName + "...");

        Refactorer refactorer = new Refactorer.PrettyPrint(
                getWorkspaceManager().getWorkspace().asModuleContainer(),
                moduleName, startLine, 0, endLine, 0, functionNames);

        CompilerMessageLogger messageLogger = new MessageLogger();

        refactorer.calculateModifications(messageLogger);

        if (messageLogger.getNErrors() == 0) {
            // apply the changes, unless we encountered errors while calculating them
            refactorer.apply(messageLogger);
        }

        if (messageLogger.getNErrors() > 0) {
            dumpCompilerMessages(messageLogger);
            return;
View Full Code Here

    /**
     * Perform a simple (ie, non-renaming) factoring
     * @param info
     */
    private void command_refactor(String info) {
        Refactorer refactorer = null;
        boolean noGrouping = false;
       
        String[] args = info.split(" ");
        if(args[0].equals("import") || args[0].equals("imports")) {
            ModuleName moduleName = targetModule;
            if(args.length >= 3) {
                moduleName = ModuleName.maybeMake(args[1]);
                if(moduleName == null) {
                    iceLogger.log(Level.INFO, "Invalid module name '" + args[1] + "'");
                    return;
                }
               
                if(args[2].equals("nogroup")) {
                    noGrouping = true;
               
                } else {
                    iceLogger.log(Level.INFO, "Unrecognized option '" + args[2]);
                    return;
                }
               
            } else if(args.length >= 2) {
                moduleName = ModuleName.maybeMake(args[1]);
                if (moduleName == null) {
                    if(args[1].equals("nogroup")){
                        moduleName = targetModule;
                        noGrouping = true;
                    } else {
                        iceLogger.log(Level.INFO, "Unrecognized option '" + args[1]);
                        return;
                    }
                }
            }
           
            moduleName = resolveModuleNameInWorkspace(moduleName.toSourceText(), true);
            if (moduleName == null) {
                return;
            }
           
            refactorer = new Refactorer.CleanImports(getWorkspaceManager().getWorkspace().asModuleContainer(), moduleName, noGrouping);
            iceLogger.log(Level.INFO, "Cleaning imports in module " + moduleName + "...");
           
        } else if(args[0].equals("typeDecls")) {
            final ModuleName moduleName;
            if(args.length > 1) {
                moduleName = resolveModuleNameInWorkspace(args[1], true);
                if (moduleName == null) {
                    return;
                }
            } else {
                moduleName = targetModule;
            }
           
            refactorer = new Refactorer.InsertTypeDeclarations(getWorkspaceManager().getWorkspace().asModuleContainer(), moduleName, -1, -1, -1, -1);
            iceLogger.log(Level.INFO, "Adding type declarations to module " + moduleName + "...");
           
        } else {
            iceLogger.log(Level.INFO, "unrecognized refactoring type '" + args[0] + "'");
            return;
        }
       
        CompilerMessageLogger messageLogger = new MessageLogger();
       
        refactorer.calculateModifications(messageLogger);

        if (messageLogger.getNErrors() == 0) {
            // apply the changes, unless we encountered errors while calculating them
            refactorer.apply(messageLogger);
        }
           
        if (messageLogger.getNErrors() > 0) {
            dumpCompilerMessages(messageLogger);
            return;
View Full Code Here

    void doAddTypeDeclsUserAction(final ModuleName targetModule) {

        Thread refactoringThread = new AbstractThreadWithSimpleModalProgressDialog("type-decl adder thread", this, GemCutterMessages.getString("AddTypedeclsTitle"), 0, 3) {
            public void run() {
               
                Refactorer typeDeclsAdder = new Refactorer.InsertTypeDeclarations(perspective.getWorkspace().asModuleContainer(), targetModule, -1, -1, -1, -1);
               
                showMonitor();
                setStatus(GemCutterMessages.getString("CalculatingModificationsStatus"));
               
                try {
                    ExtendedUndoableEditSupport undoableEditSupport = tableTop.getUndoableEditSupport();
                    undoableEditSupport.beginUpdate();
           
                    CompilerMessageLogger logger = new MessageLogger();
                    typeDeclsAdder.calculateModifications(logger);
                   
                    if(logger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
                        closeMonitor();
                        showCompilationErrors(logger, getResourceString("ErrorWhileCalculatingModifications"));
                        return;
                    }
                   
                    incrementProgress();
                    setStatus(GemCutterMessages.getString("ApplyingModificationsStatus"));
                   
                    typeDeclsAdder.apply(logger);
                   
                    if(logger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
                        closeMonitor();
                        showCompilationErrors(logger, getResourceString("ErrorWhileApplyingModifications"));
                        return;
View Full Code Here

    void doCleanImportsUserAction(final ModuleName targetModule) {

        Thread refactoringThread = new AbstractThreadWithSimpleModalProgressDialog("import-cleaner thread", this, GemCutterMessages.getString("CleanImportsTitle"), 0, 3) {
            public void run() {
               
                Refactorer importCleaner = new Refactorer.CleanImports(perspective.getWorkspace().asModuleContainer(), targetModule, false);
               
                showMonitor();
                setStatus(GemCutterMessages.getString("CalculatingModificationsStatus"));
               
                try {
                    ExtendedUndoableEditSupport undoableEditSupport = tableTop.getUndoableEditSupport();
                    undoableEditSupport.beginUpdate();
           
                    CompilerMessageLogger logger = new MessageLogger();
                    importCleaner.calculateModifications(logger);
                   
                    if(logger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
                        closeMonitor();
                        showCompilationErrors(logger, getResourceString("ErrorWhileCalculatingModifications"));
                        return;
                    }
                   
                    incrementProgress();
                    setStatus(GemCutterMessages.getString("ApplyingModificationsStatus"));
                   
                    importCleaner.apply(logger);
                   
                    if(logger.getMaxSeverity().compareTo(CompilerMessage.Severity.ERROR) >= 0) {
                        closeMonitor();
                        showCompilationErrors(logger, getResourceString("ErrorWhileApplyingModifications"));
                        return;
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.Refactorer$PrettyPrint

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.