/*
 * Copyright 2013-present Facebook, Inc.
 *
 * 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.
 */

package com.facebook.buck.cxx;

import com.facebook.buck.model.BuildTarget;
import com.facebook.buck.rules.AbstractDescriptionArg;
import com.facebook.buck.rules.BuildRuleParams;
import com.facebook.buck.rules.BuildRuleResolver;
import com.facebook.buck.rules.CellPathResolver;
import com.facebook.buck.rules.Description;
import com.facebook.buck.rules.SourcePath;
import com.facebook.buck.rules.TargetGraph;
import com.facebook.buck.versions.VersionPropagator;
import com.facebook.infer.annotation.SuppressFieldNotInitialized;
import com.google.common.collect.ImmutableSortedSet;

public class CxxPrecompiledHeaderDescription
    implements Description<CxxPrecompiledHeaderDescription.Arg>,
        VersionPropagator<CxxPrecompiledHeaderDescription.Arg> {

  @Override
  public Class<Arg> getConstructorArgType() {
    return Arg.class;
  }

  @Override
  public CxxPrecompiledHeaderTemplate createBuildRule(
      TargetGraph targetGraph,
      BuildRuleParams params,
      BuildRuleResolver ruleResolver,
      CellPathResolver cellRoots,
      Arg args) {
    return new CxxPrecompiledHeaderTemplate(
        params.copyAppendingExtraDeps(ruleResolver.getAllRules(args.deps)), ruleResolver, args.src);
  }

  @SuppressFieldNotInitialized
  public static class Arg extends AbstractDescriptionArg {
    public SourcePath src;
    public ImmutableSortedSet<BuildTarget> deps;
  }
}

@@ -661,25 +661,29 @@
 uck.
-model
+rules
 .Build
-Target
+RuleParams
 ;%0Aim
@@ -711,38 +711,33 @@
 k.rules.
-AbstractDescriptionArg
+BuildRuleResolver
 ;%0Aimport
@@ -757,39 +757,40 @@
 .buck.rules.
-BuildRuleParams
+CellPathResolver
 ;%0Aimport com
@@ -810,33 +810,36 @@
 k.rules.
-BuildRuleResolver
+CommonDescriptionArg
 ;%0Aimport
@@ -863,32 +863,27 @@
 k.rules.
-CellPathResolver
+Description
 ;%0Aimport
@@ -903,35 +903,39 @@
 .buck.rules.
-Description
+HasDeclaredDeps
 ;%0Aimport com
@@ -1040,153 +1040,130 @@
 uck.
-versions.VersionPropagator;%0Aimport com.facebook.infer.annotation.SuppressFieldNotInitialized;%0Aimport com.google.common.collect.ImmutableSortedSet
+util.immutables.BuckStyleImmutable;%0Aimport com.facebook.buck.versions.VersionPropagator;%0Aimport org.immutables.value.Value
 ;%0A%0Ap
@@ -1260,25 +1260,24 @@
 rDescription
-.
 Arg%3E,%0A      
@@ -1327,17 +1327,16 @@
 cription
-.
 Arg%3E %7B%0A%0A
@@ -1362,16 +1362,47 @@
 c Class%3C
+CxxPrecompiledHeaderDescription
 Arg%3E get
@@ -1435,16 +1435,47 @@
  return 
+CxxPrecompiledHeaderDescription
 Arg.clas
@@ -1688,16 +1688,47 @@
 ,%0A      
+CxxPrecompiledHeaderDescription
 Arg args
@@ -1848,15 +1848,28 @@
 rgs.
-d
+getD
 eps
+()
 )),
+%0A       
  rul
@@ -1882,81 +1882,139 @@
 ver,
- args.src);%0A  %7D%0A%0A  @SuppressFieldNotInitialized%0A  public static class Arg
+%0A        args.getSrc());%0A  %7D%0A%0A  @BuckStyleImmutable%0A  @Value.Immutable%0A  interface AbstractCxxPrecompiledHeaderDescriptionArg%0A     
  ext
@@ -2018,24 +2018,22 @@
 extends 
-Abstract
+Common
 Descript
@@ -2042,85 +2042,51 @@
 nArg
- %7B%0A    public SourcePath src;%0A    public ImmutableSortedSet%3CBuildTarget%3E deps
+, HasDeclaredDeps %7B%0A    SourcePath getSrc()
 ;%0A  

Convert cxx_precompiled_header Arg to be an Immutable