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

http://testability-explorer.googlecode.com/ · Java · 48 lines · 25 code · 8 blank · 15 comment · 0 complexity · 4f3625202e88adc8467c1e846b168e3f 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. */
  16. package com.google.test.metric.cpp;
  17. import com.google.test.metric.ParameterInfo;
  18. import java.util.List;
  19. public class ParameterDeclarationBuilder extends DefaultBuilder {
  20. private final List<ParameterInfo> parameters;
  21. private List<String> typeSpecifier;
  22. private String name;
  23. public ParameterDeclarationBuilder(List<ParameterInfo> parameters) {
  24. this.parameters = parameters;
  25. }
  26. @Override
  27. public void simpleTypeSpecifier(List<String> sts) {
  28. typeSpecifier = sts;
  29. }
  30. @Override
  31. public void directDeclarator(String id) {
  32. name = id;
  33. }
  34. @Override
  35. public void endParameterDeclaration() {
  36. parameters.add(new ParameterInfo(name,
  37. CppType.fromName(typeSpecifier.get(0))));
  38. finished();
  39. }
  40. }