⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coverage.java

📁 非常棒的java数据库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }
        } while (true);
    }

    void processClass() throws Exception {
        int type = 0;
        while (true) {
            if (token == null) {
                break;
            } else if (token.equals("class")) {
                read();
                type = 1;
            } else if (token.equals("=")) {
                read();
                type = 2;
            } else if (token.equals("static")) {
                word = "static";
                read();
                type = 3;
            } else if (token.equals("(")) {
                word = last + "(";
                read();
                if (!token.equals(")")) {
                    word = word + token;
                }
                type = 3;
            } else if (token.equals(",")) {
                read();
                word = word + "," + token;
            } else if (token.equals(")")) {
                word = word + ")";
                read();
            } else if (token.equals(";")) {
                read();
                type = 0;
            } else if (token.equals("{")) {
                read();
                if (type == 1) {
                    processClass();
                } else if (type == 2) {
                    processInit();
                } else if (type == 3) {
                    writeLine();
                    setLine();
                    processFunction();
                    writeLine();
                }
            } else if (token.equals("}")) {
                read();
                break;
            } else {
                read();
            }
        }
    }

    void processBracket() throws Exception {
        do {
            if (token.equals("(")) {
                read();
                processBracket();
            } else if (token.equals(")")) {
                read();
                return;
            } else {
                read();
            }
        } while (true);
    }

    void processFunction() throws Exception {
        function = word;
        writeLine();
        do {
            processStatement();
        } while (!token.equals("}"));
        read();
        writeLine();
    }

    void processBlockOrStatement() throws Exception {
        if (!token.equals("{")) {
            write("{ //++");
            writeLine();
            setLine();
            processStatement();
            write("} //++");
            writeLine();
        } else {
            read();
            setLine();
            processFunction();
        }
    }

    void processStatement() throws Exception {
        while (true) {
            if (token.equals("while") || token.equals("for") || token.equals("synchronized")) {
                read();
                readThis("(");
                processBracket();
                indent++;
                processBlockOrStatement();
                indent--;
                return;
            } else if (token.equals("if")) {
                read();
                readThis("(");
                processBracket();
                indent++;
                processBlockOrStatement();
                indent--;
                if (token.equals("else")) {
                    read();
                    indent++;
                    processBlockOrStatement();
                    indent--;
                }
                return;
            } else if (token.equals("try")) {
                read();
                indent++;
                processBlockOrStatement();
                indent--;
                while (true) {
                    if (token.equals("catch")) {
                        read();
                        readThis("(");
                        processBracket();
                        indent++;
                        processBlockOrStatement();
                        indent--;
                    } else if (token.equals("finally")) {
                        read();
                        indent++;
                        processBlockOrStatement();
                        indent--;
                    } else {
                        break;
                    }
                }
                return;
            } else if (token.equals("{")) {
                if (last.equals(")")) {
                    // process anonymous inner classes (this is a hack)
                    read();
                    processClass();
                    return;
                } else if (last.equals("]")) {
                    // process object array initialization (another hack)
                    while (!token.equals("}")) {
                        read();
                    }
                    read();
                    return;
                }
                indent++;
                processBlockOrStatement();
                indent--;
                return;
            } else if (token.equals("do")) {
                read();
                indent++;
                processBlockOrStatement();
                readThis("while");
                readThis("(");
                processBracket();
                readThis(";");
                setLine();
                indent--;
                return;
            } else if (token.equals("case")) {
                add = "";
                read();
                while (!token.equals(":")) {
                    read();
                }
                read();
                setLine();
            } else if (token.equals("default")) {
                add = "";
                read();
                readThis(":");
                setLine();
            } else if (token.equals("switch")) {
                read();
                readThis("(");
                processBracket();
                indent++;
                processBlockOrStatement();
                indent--;
                return;
            } else if (token.equals("class")) {
                read();
                processClass();
                return;
            } else if (token.equals("(")) {
                read();
                processBracket();
            } else if (token.equals("=")) {
                read();
                if (token.equals("{")) {
                    read();
                    processInit();
                }
            } else if (token.equals(";")) {
                read();
                setLine();
                return;
            } else if (token.equals("}")) {
                return;
            } else {
                read();
            }
        }
    }

    void setLine() throws Exception {
        add += "Profile.visit(" + index + ");";
        line = tokenizer.getLine();
    }

    void nextDebug() throws Exception {
        if (perFunction) {
            int i = function.indexOf("(");
            String func = i < 0 ? function : function.substring(0, i);
            String fileLine = file + "." + func + "(";
            i = file.lastIndexOf('.');
            String className = i < 0 ? file : file.substring(i + 1);
            fileLine += className + ".java:" + line + ")";
            data.write(fileLine + " " + last + "\r\n");
        } else {
            data.write(file + " " + line + "\r\n");
        }
        index++;
    }

    void writeLine() throws Exception {
        write("\r\n");
        for (int i = 0; i < indent; i++) {
            writer.write(' ');
        }
    }

    void write(String s) throws Exception {
        writer.write(s);
        // System.out.print(s);
    }

    void printError(String error) {
        System.out.println("");
        System.out.println("File:" + file);
        System.out.println("ERROR: " + error);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -