PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/cpp/src/main/java/com/google/test/metric/cpp/FunctionDefinitionBuilder.java

http://testability-explorer.googlecode.com/
Java | 74 lines | 47 code | 12 blank | 15 comment | 0 complexity | 399b71f23ad6bc8c304fdfc957b5cebf MD5 | raw file
 1/*
 2 * Copyright 2008 Google Inc.
 3 *
 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 5 * use this file except in compliance with the License. You may obtain a copy of
 6 * the License at
 7 *
 8 * http://www.apache.org/licenses/LICENSE-2.0
 9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16package com.google.test.metric.cpp;
17
18import com.google.test.metric.ParameterInfo;
19import com.google.test.metric.Visibility;
20import com.google.test.metric.cpp.dom.FunctionDefinition;
21import com.google.test.metric.cpp.dom.Node;
22
23import java.util.ArrayList;
24import java.util.List;
25
26class FunctionDefinitionBuilder extends DefaultBuilder {
27
28  private final Node parent;
29  private Node node;
30  private final int line;
31  private final List<ParameterInfo> parameters = new ArrayList<ParameterInfo>();
32  private final Visibility visibility;
33
34  public FunctionDefinitionBuilder(Node parent, int line) {
35    this.parent = parent;
36    this.line = line;
37    this.visibility = Visibility.PUBLIC;
38  }
39
40  public FunctionDefinitionBuilder(Node parent, int line, Visibility visibility) {
41    this.parent = parent;
42    this.line = line;
43    this.visibility = visibility;
44  }
45
46  @Override
47  public void functionDirectDeclarator(String name) {
48    node = new FunctionDefinition(name, line, parameters, visibility);
49    parent.addChild(node);
50  }
51
52  @Override
53  public void endFunctionDefinition() {
54    finished();
55  }
56
57  @Override
58  public void beginParameterDeclaration() {
59    pushBuilder(new ParameterDeclarationBuilder(parameters));
60  }
61
62  @Override
63  public void directDeclarator(String id) {
64  }
65
66  @Override
67  public void simpleTypeSpecifier(List<String> sts) {
68  }
69
70  @Override
71  public void beginCompoundStatement() {
72    pushBuilder(new StatementBuilder(node));
73  }
74}