blob: a67fff70ed0c7d9c4e2a26ed43ea6b7c3bf3fbdb [file] [log] [blame]
// Copyright 2018 The Bazel Authors. All rights reserved.
//
// 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.google.devtools.build.skydoc.fakebuildapi;
import com.google.devtools.build.lib.skylarkbuildapi.SkylarkAttrApi;
import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter;
import com.google.devtools.build.lib.skylarkinterface.StarlarkContext;
import com.google.devtools.build.lib.syntax.Environment;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.FuncallExpression;
import com.google.devtools.build.lib.syntax.SkylarkDict;
import com.google.devtools.build.lib.syntax.SkylarkList;
import com.google.devtools.build.skydoc.rendering.proto.StardocOutputProtos.AttributeType;
/**
* Fake implementation of {@link SkylarkAttrApi}.
*/
public class FakeSkylarkAttrApi implements SkylarkAttrApi {
@Override
public Descriptor intAttribute(
Integer defaultInt,
String doc,
Boolean mandatory,
SkylarkList<?> values,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.INT, doc, mandatory);
}
@Override
public Descriptor stringAttribute(
String defaultString,
String doc,
Boolean mandatory,
SkylarkList<?> values,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.STRING, doc, mandatory);
}
@Override
public Descriptor labelAttribute(
Object defaultO,
String doc,
Boolean executable,
Object allowFiles,
Object allowSingleFile,
Boolean mandatory,
SkylarkList<?> providers,
Object allowRules,
Boolean singleFile,
Object cfg,
SkylarkList<?> aspects,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.LABEL, doc, mandatory);
}
@Override
public Descriptor stringListAttribute(
Boolean mandatory,
Boolean nonEmpty,
Boolean allowEmpty,
SkylarkList<?> defaultList,
String doc,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.STRING_LIST, doc, mandatory);
}
@Override
public Descriptor intListAttribute(
Boolean mandatory,
Boolean nonEmpty,
Boolean allowEmpty,
SkylarkList<?> defaultList,
String doc,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.INT_LIST, doc, mandatory);
}
@Override
public Descriptor labelListAttribute(
Boolean allowEmpty,
Object defaultList,
String doc,
Object allowFiles,
Object allowRules,
SkylarkList<?> providers,
SkylarkList<?> flags,
Boolean mandatory,
Boolean nonEmpty,
Object cfg,
SkylarkList<?> aspects,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.LABEL_LIST, doc, mandatory);
}
@Override
public Descriptor labelKeyedStringDictAttribute(
Boolean allowEmpty,
Object defaultList,
String doc,
Object allowFiles,
Object allowRules,
SkylarkList<?> providers,
SkylarkList<?> flags,
Boolean mandatory,
Boolean nonEmpty,
Object cfg,
SkylarkList<?> aspects,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.LABEL_STRING_DICT, doc, mandatory);
}
@Override
public Descriptor boolAttribute(
Boolean defaultO,
String doc,
Boolean mandatory,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.BOOLEAN, doc, mandatory);
}
@Override
public Descriptor outputAttribute(
Object defaultO,
String doc,
Boolean mandatory,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.OUTPUT, doc, mandatory);
}
@Override
public Descriptor outputListAttribute(
Boolean allowEmpty,
Object defaultList,
String doc,
Boolean mandatory,
Boolean nonEmpty,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.OUTPUT_LIST, doc, mandatory);
}
@Override
public Descriptor stringDictAttribute(
Boolean allowEmpty,
SkylarkDict<?, ?> defaultO,
String doc,
Boolean mandatory,
Boolean nonEmpty,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.STRING_DICT, doc, mandatory);
}
@Override
public Descriptor stringListDictAttribute(
Boolean allowEmpty,
SkylarkDict<?, ?> defaultO,
String doc,
Boolean mandatory,
Boolean nonEmpty,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.STRING_LIST_DICT, doc, mandatory);
}
@Override
public Descriptor licenseAttribute(
Object defaultO,
String doc,
Boolean mandatory,
FuncallExpression ast,
Environment env,
StarlarkContext context)
throws EvalException {
return new FakeDescriptor(AttributeType.STRING_LIST, doc, mandatory);
}
@Override
public void repr(SkylarkPrinter printer) {}
}