package org.sahagin.share;

import org.sahagin.share.srctree.SrcTree;
import org.sahagin.share.srctree.TestFunction;

public class SrcTreeChecker {
    // TODO throw error if sub class has root method
    // TODO throw error if class for root method is not root class
    // TODO throw error if root class is page class

    private static final String MSG_INVALID_PLACEHOLDER
    = "TestDoc of \"%s\" contains invalid keyword \"%s\"";

    public static void check(SrcTree srcTree) throws IllegalTestScriptException {
        for (TestFunction func : srcTree.getRootFuncTable().getTestFunctions()) {
            String invalidKeyword = TestDocResolver.searchInvalidPlaceholder(func);
            if (invalidKeyword != null) {
                throw new IllegalTestScriptException(String.format(MSG_INVALID_PLACEHOLDER,
                        func.getQualifiedName(), invalidKeyword));
            }
        }
        for (TestFunction func : srcTree.getSubFuncTable().getTestFunctions()) {
            String invalidKeyword = TestDocResolver.searchInvalidPlaceholder(func);
            if (invalidKeyword != null) {
                throw new IllegalTestScriptException(String.format(MSG_INVALID_PLACEHOLDER,
                        func.getQualifiedName(), invalidKeyword));
            }
        }
    }

}

@@ -63,16 +63,60 @@
 rcTree;%0A
+import org.sahagin.share.srctree.TestClass;%0A
 import o
@@ -630,32 +630,308 @@
 tFunctions()) %7B%0A
+            if (func.getTestDoc() != null && func.getTestDoc().contains(%22%5C%5C%22)) %7B%0A                // TODO support back slash%0A                throw new RuntimeException(String.format(%0A                        %22back slash is not supported: %25s%22, func.getTestDoc()));%0A            %7D%0A
             Stri
@@ -1320,277 +1320,1318 @@
     
-String invalidKeyword = TestDocResolver.searchInvalidPlaceholder(func);%0A            if (invalidKeyword != null) %7B%0A                throw new IllegalTestScriptException(String.format(MSG_INVALID_PLACEHOLDER,%0A                        func.getQualifiedName(), invalidKeyword
+if (func.getTestDoc() != null && func.getTestDoc().contains(%22%5C%5C%22)) %7B%0A                // TODO support back slash%0A                throw new RuntimeException(String.format(%0A                        %22back slash is not supported: %25s%22, func.getTestDoc()));%0A            %7D%0A            String invalidKeyword = TestDocResolver.searchInvalidPlaceholder(func);%0A            if (invalidKeyword != null) %7B%0A                throw new IllegalTestScriptException(String.format(MSG_INVALID_PLACEHOLDER,%0A                        func.getQualifiedName(), invalidKeyword));%0A            %7D%0A        %7D%0A        for (TestClass testClass: srcTree.getRootClassTable().getTestClasses()) %7B%0A            if (testClass.getTestDoc() != null && testClass.getTestDoc().contains(%22%5C%5C%22)) %7B%0A                // TODO support back slash%0A                throw new RuntimeException(String.format(%0A                        %22back slash is not supported: %25s%22, testClass.getTestDoc()));%0A            %7D%0A        %7D%0A        for (TestClass testClass: srcTree.getSubClassTable().getTestClasses()) %7B%0A            if (testClass.getTestDoc() != null && testClass.getTestDoc().contains(%22%5C%5C%22)) %7B%0A                // TODO support back slash%0A                throw new RuntimeException(String.format(%0A                        %22back slash is not supported: %25s%22, testClass.getTestDoc()
 ));%0A

Check reserved word "\"