/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.core.parsing.antler.phrase.visitor;

import java.util.List;

import org.antlr.v4.runtime.ParserRuleContext;

import io.shardingsphere.core.parsing.antler.utils.TreeUtils;
import io.shardingsphere.core.parsing.parser.sql.SQLStatement;
import io.shardingsphere.core.parsing.parser.sql.ddl.create.table.CreateTableStatement;

public class CreatePrimaryKeyVisitor implements PhraseVisitor {

    @Override
    public void visit(ParserRuleContext ancestorNode, SQLStatement statement) {
        CreateTableStatement createStatement = (CreateTableStatement)statement;
        ParserRuleContext primaryKeyCtx = TreeUtils.getFirstChildByRuleName(ancestorNode, "primaryKey");
        if (null == primaryKeyCtx) {
            return;
        }
        
        ParserRuleContext columnListCtx = TreeUtils.getFirstChildByRuleName(primaryKeyCtx.getParent().getParent(), "columnList");
        if (null == columnListCtx) {
            return;
        }

        List<ParserRuleContext> columnNodes = TreeUtils.getAllDescendantByRuleName(columnListCtx, "columnName");
        if (null == columnNodes) {
            return;
        }
        
        for (final ParserRuleContext each : columnNodes) {
            if(!createStatement.getPrimaryKeyColumns().contains(each.getText())) {
                createStatement.getPrimaryKeyColumns().add(each.getText());
            }
        }
    }

}

@@ -1027,16 +1027,180 @@
 itor %7B%0A%0A
+    /**%0A     * Visit ast.%0A     * %0A     * @param ancestorNode%0A     *            ancestor node of ast%0A     * @param statement%0A     *            sql statement%0A     */%0A
     @Ove
@@ -1227,16 +1227,22 @@
 d visit(
+final 
 ParserRu
@@ -1264,16 +1264,22 @@
 torNode,
+ final
  SQLStat
@@ -1366,16 +1366,17 @@
 atement)
+ 
 statemen
@@ -1546,32 +1546,24 @@
 ;%0A        %7D%0A
-        
 %0A        Par
@@ -1665,16 +1665,32 @@
 arent(),
+%0A               
  %22column
@@ -1947,17 +1947,9 @@
   %7D%0A
-        
 %0A
+
     
@@ -1995,32 +1995,32 @@
  columnNodes) %7B%0A
-
             if(!
@@ -2017,16 +2017,17 @@
       if
+ 
 (!create

Use checkstyle check code