mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C#: Autoformat QLL files
This commit is contained in:
@@ -14,16 +14,13 @@
|
||||
import csharp
|
||||
|
||||
/** An element that should be in the generated code. */
|
||||
abstract class GeneratedElement extends Element {
|
||||
}
|
||||
abstract class GeneratedElement extends Element { }
|
||||
|
||||
/** A member that should be in the generated code. */
|
||||
abstract class GeneratedMember extends Member, GeneratedElement {
|
||||
}
|
||||
abstract class GeneratedMember extends Member, GeneratedElement { }
|
||||
|
||||
/** A type that should be in the generated code. */
|
||||
private abstract class GeneratedType extends ValueOrRefType, GeneratedElement {
|
||||
|
||||
abstract private class GeneratedType extends ValueOrRefType, GeneratedElement {
|
||||
GeneratedType() {
|
||||
(
|
||||
this instanceof Interface
|
||||
@@ -35,12 +32,9 @@ private abstract class GeneratedType extends ValueOrRefType, GeneratedElement {
|
||||
this instanceof Enum
|
||||
or
|
||||
this instanceof DelegateType
|
||||
)
|
||||
and
|
||||
not this instanceof ConstructedType
|
||||
and
|
||||
not this.getALocation() instanceof ExcludedAssembly
|
||||
and
|
||||
) and
|
||||
not this instanceof ConstructedType and
|
||||
not this.getALocation() instanceof ExcludedAssembly and
|
||||
this.fromLibrary()
|
||||
}
|
||||
|
||||
@@ -66,53 +60,37 @@ private abstract class GeneratedType extends ValueOrRefType, GeneratedElement {
|
||||
}
|
||||
|
||||
private string stubAbstractModifier() {
|
||||
if this.(Class).isAbstract() then
|
||||
result = "abstract "
|
||||
else
|
||||
result = ""
|
||||
if this.(Class).isAbstract() then result = "abstract " else result = ""
|
||||
}
|
||||
|
||||
private string stubStaticModifier() {
|
||||
if this.isStatic() then result = "static "
|
||||
else result = ""
|
||||
if this.isStatic() then result = "static " else result = ""
|
||||
}
|
||||
|
||||
private string stubAttributes() {
|
||||
if this.getAnAttribute().getType().getQualifiedName() = "System.FlagsAttribute" then
|
||||
result = "[System.Flags]\n"
|
||||
else
|
||||
result = ""
|
||||
if this.getAnAttribute().getType().getQualifiedName() = "System.FlagsAttribute"
|
||||
then result = "[System.Flags]\n"
|
||||
else result = ""
|
||||
}
|
||||
|
||||
private string stubComment() {
|
||||
result = "// Generated from `" + this.getQualifiedName() + "` in `" +
|
||||
min(this.getLocation().toString()) + "`\n"
|
||||
min(this.getLocation().toString()) + "`\n"
|
||||
}
|
||||
|
||||
private string stubAccessibilityModifier() {
|
||||
if this.isPublic() then
|
||||
result = "public "
|
||||
else
|
||||
result = ""
|
||||
if this.isPublic() then result = "public " else result = ""
|
||||
}
|
||||
|
||||
/** Gets the entire C# stub code for this type. */
|
||||
final string getStub() {
|
||||
if this.isDuplicate() then
|
||||
result = ""
|
||||
if this.isDuplicate()
|
||||
then result = ""
|
||||
else
|
||||
result = this.stubComment() +
|
||||
this.stubAttributes() +
|
||||
this.stubAbstractModifier() +
|
||||
this.stubStaticModifier() +
|
||||
this.stubAccessibilityModifier() +
|
||||
this.stubKeyword() + " " +
|
||||
this.getUndecoratedName() +
|
||||
stubGenericArguments(this) +
|
||||
stubBaseTypesString() +
|
||||
"\n{\n" +
|
||||
stubMembers() +
|
||||
"}\n\n"
|
||||
result = this.stubComment() + this.stubAttributes() + this.stubAbstractModifier() +
|
||||
this.stubStaticModifier() + this.stubAccessibilityModifier() + this.stubKeyword() + " " +
|
||||
this.getUndecoratedName() + stubGenericArguments(this) + stubBaseTypesString() + "\n{\n" +
|
||||
stubMembers() + "}\n\n"
|
||||
}
|
||||
|
||||
private ValueOrRefType getAnInterestingBaseType() {
|
||||
@@ -122,25 +100,26 @@ private abstract class GeneratedType extends ValueOrRefType, GeneratedElement {
|
||||
}
|
||||
|
||||
private string stubBaseTypesString() {
|
||||
if this instanceof Enum then
|
||||
result = ""
|
||||
else if exists(getAnInterestingBaseType()) then
|
||||
result = " : " +
|
||||
concat(int i, ValueOrRefType t |
|
||||
t = this.getAnInterestingBaseType() and (if t instanceof Class then i=0 else i=1) |
|
||||
stubClassName(t), ", " order by i
|
||||
)
|
||||
if this instanceof Enum
|
||||
then result = ""
|
||||
else
|
||||
result = ""
|
||||
if exists(getAnInterestingBaseType())
|
||||
then
|
||||
result = " : " +
|
||||
concat(int i, ValueOrRefType t |
|
||||
t = this.getAnInterestingBaseType() and
|
||||
(if t instanceof Class then i = 0 else i = 1)
|
||||
|
|
||||
stubClassName(t), ", "
|
||||
order by
|
||||
i
|
||||
)
|
||||
else result = ""
|
||||
}
|
||||
|
||||
private string stubMembers() {
|
||||
result = concat(stubMember(this.getAGeneratedMember()))
|
||||
}
|
||||
private string stubMembers() { result = concat(stubMember(this.getAGeneratedMember())) }
|
||||
|
||||
private GeneratedMember getAGeneratedMember() {
|
||||
result.getDeclaringType() = this
|
||||
}
|
||||
private GeneratedMember getAGeneratedMember() { result.getDeclaringType() = this }
|
||||
|
||||
final Type getAGeneratedType() {
|
||||
result = getAnInterestingBaseType()
|
||||
@@ -160,11 +139,9 @@ private abstract class GeneratedType extends ValueOrRefType, GeneratedElement {
|
||||
* This is extended in client code to identify the actual
|
||||
* declarations that should be generated.
|
||||
*/
|
||||
abstract class GeneratedDeclaration extends Declaration {
|
||||
}
|
||||
abstract class GeneratedDeclaration extends Declaration { }
|
||||
|
||||
private class IndirectType extends GeneratedType {
|
||||
|
||||
IndirectType() {
|
||||
this.getASubType() instanceof GeneratedType
|
||||
or
|
||||
@@ -174,14 +151,14 @@ private class IndirectType extends GeneratedType {
|
||||
or
|
||||
exists(GeneratedType t | this = getAContainedType(t.getAGeneratedType()).getSourceDeclaration())
|
||||
or
|
||||
exists(GeneratedDeclaration decl | decl.(Member).getDeclaringType().getSourceDeclaration() = this)
|
||||
exists(GeneratedDeclaration decl |
|
||||
decl.(Member).getDeclaringType().getSourceDeclaration() = this
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private class RootGeneratedType extends GeneratedType {
|
||||
RootGeneratedType() {
|
||||
this = any(GeneratedDeclaration decl).getSourceDeclaration()
|
||||
}
|
||||
RootGeneratedType() { this = any(GeneratedDeclaration decl).getSourceDeclaration() }
|
||||
}
|
||||
|
||||
private Type getAContainedType(Type t) {
|
||||
@@ -191,9 +168,7 @@ private Type getAContainedType(Type t) {
|
||||
}
|
||||
|
||||
private class RootGeneratedMember extends GeneratedMember {
|
||||
RootGeneratedMember() {
|
||||
this = any(GeneratedDeclaration d).getSourceDeclaration()
|
||||
}
|
||||
RootGeneratedMember() { this = any(GeneratedDeclaration d).getSourceDeclaration() }
|
||||
}
|
||||
|
||||
private predicate declarationExists(Virtualizable m) {
|
||||
@@ -223,31 +198,26 @@ private class GeneratedNamespace extends Namespace, GeneratedElement {
|
||||
}
|
||||
|
||||
private string getPreamble() {
|
||||
if this.isGlobalNamespace() then
|
||||
result = ""
|
||||
else
|
||||
result = "namespace " + this.getName() + "\n{\n"
|
||||
if this.isGlobalNamespace()
|
||||
then result = ""
|
||||
else result = "namespace " + this.getName() + "\n{\n"
|
||||
}
|
||||
|
||||
private string getPostAmble() {
|
||||
if this.isGlobalNamespace() then
|
||||
result = ""
|
||||
else
|
||||
result = "}\n"
|
||||
}
|
||||
private string getPostAmble() { if this.isGlobalNamespace() then result = "" else result = "}\n" }
|
||||
|
||||
final string getStubs() {
|
||||
result = getPreamble() +
|
||||
getTypeStubs() +
|
||||
getSubNamespaces() +
|
||||
getPostAmble()
|
||||
result = getPreamble() + getTypeStubs() + getSubNamespaces() + getPostAmble()
|
||||
}
|
||||
|
||||
/** Gets the `n`th generated child namespace, indexed from 0. */
|
||||
pragma[nomagic]
|
||||
final GeneratedNamespace getChildNamespace(int n) {
|
||||
result.getParentNamespace() = this and
|
||||
result.getName() = rank[n+1](GeneratedNamespace g | g.getParentNamespace() = this | g.getName())
|
||||
result.getName() = rank[n + 1](GeneratedNamespace g |
|
||||
g.getParentNamespace() = this
|
||||
|
|
||||
g.getName()
|
||||
)
|
||||
}
|
||||
|
||||
final int getChildNamespaceCount() {
|
||||
@@ -260,7 +230,9 @@ private class GeneratedNamespace extends Namespace, GeneratedElement {
|
||||
}
|
||||
|
||||
private string getTypeStubs() {
|
||||
result = concat(string s | s = any(GeneratedType gt | gt.getDeclaringNamespace() = this).getStub())
|
||||
result = concat(string s |
|
||||
s = any(GeneratedType gt | gt.getDeclaringNamespace() = this).getStub()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,25 +240,32 @@ private class GeneratedNamespace extends Namespace, GeneratedElement {
|
||||
* Specify assemblies to exclude.
|
||||
* Do not generate any types from these assemblies.
|
||||
*/
|
||||
abstract class ExcludedAssembly extends Assembly {
|
||||
}
|
||||
abstract class ExcludedAssembly extends Assembly { }
|
||||
|
||||
/** Exclude types from these standard assemblies. */
|
||||
private class DefaultLibs extends ExcludedAssembly {
|
||||
DefaultLibs() {
|
||||
this.getName() = "System.Private.CoreLib"
|
||||
or this.getName() = "mscorlib"
|
||||
or this.getName() = "System.Runtime"
|
||||
this.getName() = "System.Private.CoreLib" or
|
||||
this.getName() = "mscorlib" or
|
||||
this.getName() = "System.Runtime"
|
||||
}
|
||||
}
|
||||
|
||||
private string stubAccessibility(Member m) {
|
||||
if m.getDeclaringType() instanceof Interface or exists(m.(Virtualizable).getExplicitlyImplementedInterface()) then result = ""
|
||||
else if m.isPublic() then result = "public "
|
||||
else if m.isProtected() then result = "protected "
|
||||
else if m.isPrivate() then result = "private "
|
||||
else if m.isInternal() then result = "internal "
|
||||
else result = "unknown-accessibility"
|
||||
if
|
||||
m.getDeclaringType() instanceof Interface or
|
||||
exists(m.(Virtualizable).getExplicitlyImplementedInterface())
|
||||
then result = ""
|
||||
else
|
||||
if m.isPublic()
|
||||
then result = "public "
|
||||
else
|
||||
if m.isProtected()
|
||||
then result = "protected "
|
||||
else
|
||||
if m.isPrivate()
|
||||
then result = "private "
|
||||
else if m.isInternal() then result = "internal " else result = "unknown-accessibility"
|
||||
}
|
||||
|
||||
private string stubModifiers(Member m) {
|
||||
@@ -294,71 +273,121 @@ private string stubModifiers(Member m) {
|
||||
}
|
||||
|
||||
private string stubStatic(Member m) {
|
||||
if m.(Modifiable).isStatic() then result = "static "
|
||||
else result = ""
|
||||
if m.(Modifiable).isStatic() then result = "static " else result = ""
|
||||
}
|
||||
|
||||
private string stubOverride(Member m) {
|
||||
if m.getDeclaringType() instanceof Interface then result = ""
|
||||
else if m.(Virtualizable).isVirtual() then result = "virtual "
|
||||
else if m.(Virtualizable).isAbstract() then result = "abstract "
|
||||
else if m.(Virtualizable).isOverride() then result = "override "
|
||||
else result = ""
|
||||
if m.getDeclaringType() instanceof Interface
|
||||
then result = ""
|
||||
else
|
||||
if m.(Virtualizable).isVirtual()
|
||||
then result = "virtual "
|
||||
else
|
||||
if m.(Virtualizable).isAbstract()
|
||||
then result = "abstract "
|
||||
else if m.(Virtualizable).isOverride() then result = "override " else result = ""
|
||||
}
|
||||
|
||||
private string stubQualifiedNamePrefix(ValueOrRefType t) {
|
||||
if t.getParent() instanceof GlobalNamespace then result=""
|
||||
else if t.getParent() instanceof Namespace then result = t.getParent().(Namespace).getQualifiedName() + "."
|
||||
else result = stubQualifiedNamePrefix(t.getParent()) + "."
|
||||
if t.getParent() instanceof GlobalNamespace
|
||||
then result = ""
|
||||
else
|
||||
if t.getParent() instanceof Namespace
|
||||
then result = t.getParent().(Namespace).getQualifiedName() + "."
|
||||
else result = stubQualifiedNamePrefix(t.getParent()) + "."
|
||||
}
|
||||
|
||||
language[monotonicAggregates]
|
||||
private string stubClassName(Type t) {
|
||||
if t instanceof ObjectType then
|
||||
result = "object"
|
||||
else if t instanceof StringType then
|
||||
result = "string"
|
||||
else if t instanceof IntType then
|
||||
result = "int"
|
||||
else if t instanceof BoolType then
|
||||
result = "bool"
|
||||
else if t instanceof VoidType then
|
||||
result = "void"
|
||||
else if t instanceof FloatType then
|
||||
result = "float"
|
||||
else if t instanceof DoubleType then
|
||||
result = "double"
|
||||
else if t instanceof NullableType then
|
||||
result = stubClassName(t.(NullableType).getUnderlyingType()) + "?"
|
||||
else if t instanceof TypeParameter then
|
||||
result = t.getName()
|
||||
else if t instanceof ArrayType then
|
||||
result = stubClassName(t.(ArrayType).getElementType()) + "[]"
|
||||
else if t instanceof PointerType then
|
||||
result = stubClassName(t.(PointerType).getReferentType()) + "*"
|
||||
else if t instanceof TupleType then
|
||||
result = "(" + concat(int i, Type element | element = t.(TupleType).getElementType(i) | stubClassName(element), "," order by i) + ")"
|
||||
else if t instanceof ValueOrRefType then
|
||||
result = stubQualifiedNamePrefix(t) + t.getUndecoratedName() + stubGenericArguments(t)
|
||||
if t instanceof ObjectType
|
||||
then result = "object"
|
||||
else
|
||||
result = "<error>"
|
||||
if t instanceof StringType
|
||||
then result = "string"
|
||||
else
|
||||
if t instanceof IntType
|
||||
then result = "int"
|
||||
else
|
||||
if t instanceof BoolType
|
||||
then result = "bool"
|
||||
else
|
||||
if t instanceof VoidType
|
||||
then result = "void"
|
||||
else
|
||||
if t instanceof FloatType
|
||||
then result = "float"
|
||||
else
|
||||
if t instanceof DoubleType
|
||||
then result = "double"
|
||||
else
|
||||
if t instanceof NullableType
|
||||
then result = stubClassName(t.(NullableType).getUnderlyingType()) + "?"
|
||||
else
|
||||
if t instanceof TypeParameter
|
||||
then result = t.getName()
|
||||
else
|
||||
if t instanceof ArrayType
|
||||
then result = stubClassName(t.(ArrayType).getElementType()) + "[]"
|
||||
else
|
||||
if t instanceof PointerType
|
||||
then result = stubClassName(t.(PointerType).getReferentType()) + "*"
|
||||
else
|
||||
if t instanceof TupleType
|
||||
then
|
||||
result = "(" +
|
||||
concat(int i, Type element |
|
||||
element = t.(TupleType).getElementType(i)
|
||||
|
|
||||
stubClassName(element), ","
|
||||
order by
|
||||
i
|
||||
) + ")"
|
||||
else
|
||||
if t instanceof ValueOrRefType
|
||||
then
|
||||
result = stubQualifiedNamePrefix(t) + t.getUndecoratedName() +
|
||||
stubGenericArguments(t)
|
||||
else result = "<error>"
|
||||
}
|
||||
|
||||
language[monotonicAggregates]
|
||||
private string stubGenericArguments(ValueOrRefType t) {
|
||||
if t instanceof UnboundGenericType then
|
||||
result = "<" + concat(int n | exists(t.(UnboundGenericType).getTypeParameter(n)) | t.(UnboundGenericType).getTypeParameter(n).getName(),"," order by n) + ">"
|
||||
else if t instanceof ConstructedType then
|
||||
result = "<" + concat(int n | exists(t.(ConstructedType).getTypeArgument(n)) | stubClassName(t.(ConstructedType).getTypeArgument(n)),"," order by n) + ">"
|
||||
if t instanceof UnboundGenericType
|
||||
then
|
||||
result = "<" +
|
||||
concat(int n |
|
||||
exists(t.(UnboundGenericType).getTypeParameter(n))
|
||||
|
|
||||
t.(UnboundGenericType).getTypeParameter(n).getName(), ","
|
||||
order by
|
||||
n
|
||||
) + ">"
|
||||
else
|
||||
result = ""
|
||||
if t instanceof ConstructedType
|
||||
then
|
||||
result = "<" +
|
||||
concat(int n |
|
||||
exists(t.(ConstructedType).getTypeArgument(n))
|
||||
|
|
||||
stubClassName(t.(ConstructedType).getTypeArgument(n)), ","
|
||||
order by
|
||||
n
|
||||
) + ">"
|
||||
else result = ""
|
||||
}
|
||||
|
||||
private string stubGenericMethodParams(Method m) {
|
||||
if m instanceof UnboundGenericMethod then
|
||||
result = "<" + concat(int n, TypeParameter param | param = m.(UnboundGenericMethod).getTypeParameter(n) | param.getName(), "," order by n) + ">"
|
||||
else
|
||||
result = ""
|
||||
if m instanceof UnboundGenericMethod
|
||||
then
|
||||
result = "<" +
|
||||
concat(int n, TypeParameter param |
|
||||
param = m.(UnboundGenericMethod).getTypeParameter(n)
|
||||
|
|
||||
param.getName(), ","
|
||||
order by
|
||||
n
|
||||
) + ">"
|
||||
else result = ""
|
||||
}
|
||||
|
||||
private string stubImplementation(Virtualizable c) {
|
||||
@@ -368,17 +397,29 @@ private string stubImplementation(Virtualizable c) {
|
||||
}
|
||||
|
||||
private string stubParameters(Parameterizable p) {
|
||||
result = concat(int i, Parameter param | param = p.getParameter(i) and not param.getType() instanceof ArglistType |
|
||||
stubParameterModifiers(param) + stubClassName(param.getType()) + " " + param.getName() + stubDefaultValue(param), ", " order by i)
|
||||
result = concat(int i, Parameter param |
|
||||
param = p.getParameter(i) and not param.getType() instanceof ArglistType
|
||||
|
|
||||
stubParameterModifiers(param) + stubClassName(param.getType()) + " " + param.getName() +
|
||||
stubDefaultValue(param), ", "
|
||||
order by
|
||||
i
|
||||
)
|
||||
}
|
||||
|
||||
private string stubParameterModifiers(Parameter p) {
|
||||
if p.isOut() then result = "out "
|
||||
else if p.isRef() then result = "ref "
|
||||
else if p.isParams() then result = "params "
|
||||
else if p.isIn() then result = "" // Only C# 7.1 so ignore
|
||||
else if p.hasExtensionMethodModifier() then result = "this "
|
||||
else result = ""
|
||||
if p.isOut()
|
||||
then result = "out "
|
||||
else
|
||||
if p.isRef()
|
||||
then result = "ref "
|
||||
else
|
||||
if p.isParams()
|
||||
then result = "params "
|
||||
else
|
||||
if p.isIn()
|
||||
then result = "" // Only C# 7.1 so ignore
|
||||
else if p.hasExtensionMethodModifier() then result = "this " else result = ""
|
||||
}
|
||||
|
||||
private string stubDefaultValue(Parameter p) {
|
||||
@@ -395,37 +436,41 @@ private string stubExplicitImplementation(Member c) {
|
||||
|
||||
private string stubMember(Member m) {
|
||||
exists(Method c | m = c and not m.getDeclaringType() instanceof Enum |
|
||||
result = " " + stubModifiers(c) + stubClassName(c.getReturnType()) + " " +
|
||||
stubExplicitImplementation(c) + c.getName() + stubGenericMethodParams(c) +
|
||||
"(" + stubParameters(c) + ")" + stubImplementation(c) + ";\n"
|
||||
result = " " + stubModifiers(c) + stubClassName(c.getReturnType()) + " " +
|
||||
stubExplicitImplementation(c) + c.getName() + stubGenericMethodParams(c) + "(" +
|
||||
stubParameters(c) + ")" + stubImplementation(c) + ";\n"
|
||||
)
|
||||
or
|
||||
exists(Operator op | m = op and not m.getDeclaringType() instanceof Enum and not op instanceof ConversionOperator |
|
||||
exists(Operator op |
|
||||
m = op and not m.getDeclaringType() instanceof Enum and not op instanceof ConversionOperator
|
||||
|
|
||||
result = " " + stubModifiers(op) + stubClassName(op.getReturnType()) + " operator " +
|
||||
op.getName() +"(" + stubParameters(op) + ") => throw null;\n"
|
||||
op.getName() + "(" + stubParameters(op) + ") => throw null;\n"
|
||||
)
|
||||
or
|
||||
exists(ConversionOperator op | m = op |
|
||||
result = " " + stubModifiers(op) + stubExplicit(op) + "operator " +
|
||||
stubClassName(op.getReturnType()) + "(" + stubParameters(op) +
|
||||
") => throw null;\n"
|
||||
stubClassName(op.getReturnType()) + "(" + stubParameters(op) + ") => throw null;\n"
|
||||
)
|
||||
or
|
||||
result = " " + m.(EnumConstant).getName() + ",\n"
|
||||
or
|
||||
exists(Property p | m = p |
|
||||
result = " " + stubModifiers(m) + stubClassName(p.getType()) + " " +
|
||||
stubExplicitImplementation(p) + p.getName() + " { " + stubGetter(p) + stubSetter(p) + "}\n"
|
||||
stubExplicitImplementation(p) + p.getName() + " { " + stubGetter(p) + stubSetter(p) + "}\n"
|
||||
)
|
||||
or exists(Constructor c | m = c and not c.getDeclaringType() instanceof Enum |
|
||||
or
|
||||
exists(Constructor c | m = c and not c.getDeclaringType() instanceof Enum |
|
||||
result = " " + stubModifiers(m) + c.getName() + "(" + stubParameters(c) +
|
||||
") => throw null;\n"
|
||||
") => throw null;\n"
|
||||
)
|
||||
or exists(Indexer i | m = i |
|
||||
or
|
||||
exists(Indexer i | m = i |
|
||||
result = " " + stubModifiers(m) + stubClassName(i.getType()) + " this[" + stubParameters(i) +
|
||||
"] { " + stubGetter(i) + stubSetter(i) + "}\n"
|
||||
"] { " + stubGetter(i) + stubSetter(i) + "}\n"
|
||||
)
|
||||
or exists(Field f | f = m and not f instanceof EnumConstant |
|
||||
or
|
||||
exists(Field f | f = m and not f instanceof EnumConstant |
|
||||
result = " " + stubModifiers(m) + stubClassName(f.getType()) + " " + f.getName() + ";\n"
|
||||
)
|
||||
}
|
||||
@@ -437,36 +482,34 @@ private string stubExplicit(ConversionOperator op) {
|
||||
}
|
||||
|
||||
private string stubGetter(DeclarationWithGetSetAccessors p) {
|
||||
if exists(p.getGetter()) then (
|
||||
if p.isAbstract() or p.getDeclaringType() instanceof Interface then
|
||||
result = "get; "
|
||||
else
|
||||
result = "get => throw null; "
|
||||
) else
|
||||
result = ""
|
||||
if exists(p.getGetter())
|
||||
then
|
||||
if p.isAbstract() or p.getDeclaringType() instanceof Interface
|
||||
then result = "get; "
|
||||
else result = "get => throw null; "
|
||||
else result = ""
|
||||
}
|
||||
|
||||
private string stubSetter(DeclarationWithGetSetAccessors p) {
|
||||
if exists(p.getSetter()) then (
|
||||
if p.isAbstract() or p.getDeclaringType() instanceof Interface then
|
||||
result = "set; "
|
||||
else
|
||||
result = "set => throw null; "
|
||||
) else
|
||||
result = ""
|
||||
if exists(p.getSetter())
|
||||
then
|
||||
if p.isAbstract() or p.getDeclaringType() instanceof Interface
|
||||
then result = "set; "
|
||||
else result = "set => throw null; "
|
||||
else result = ""
|
||||
}
|
||||
|
||||
private string stubSemmleExtractorOptions() {
|
||||
result = concat(string s |
|
||||
exists(CommentLine comment |
|
||||
s = "// original-extractor-options:" + comment.getText().regexpCapture("\\w*semmle-extractor-options:(.*)", 1) + "\n"
|
||||
exists(CommentLine comment |
|
||||
s = "// original-extractor-options:" +
|
||||
comment.getText().regexpCapture("\\w*semmle-extractor-options:(.*)", 1) + "\n"
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the generated C# code. */
|
||||
string generatedCode() {
|
||||
result = "// This file contains auto-generated code.\n" +
|
||||
stubSemmleExtractorOptions() + "\n" +
|
||||
any(GeneratedNamespace ns | ns.isGlobalNamespace()).getStubs()
|
||||
result = "// This file contains auto-generated code.\n" + stubSemmleExtractorOptions() + "\n" +
|
||||
any(GeneratedNamespace ns | ns.isGlobalNamespace()).getStubs()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user