mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: rename doc to description in properties
This commit is contained in:
@@ -67,7 +67,7 @@ def get_ql_property(cls: schema.Class, prop: schema.Property, prev_child: str =
|
||||
prev_child=prev_child if prop.is_child else None,
|
||||
is_optional=prop.is_optional,
|
||||
is_predicate=prop.is_predicate,
|
||||
doc=prop.doc,
|
||||
description=prop.description,
|
||||
)
|
||||
if prop.is_single:
|
||||
args.update(
|
||||
|
||||
@@ -38,7 +38,7 @@ class Property:
|
||||
is_predicate: bool = False
|
||||
prev_child: Optional[str] = None
|
||||
qltest_skip: bool = False
|
||||
doc: List[str] = field(default_factory=list)
|
||||
description: List[str] = field(default_factory=list)
|
||||
doc_name: Optional[str] = None
|
||||
doc_name_plural: Optional[str] = None
|
||||
|
||||
@@ -74,8 +74,8 @@ class Property:
|
||||
return self.prev_child is not None
|
||||
|
||||
@property
|
||||
def has_doc(self) -> bool:
|
||||
return bool(self.doc)
|
||||
def has_description(self) -> bool:
|
||||
return bool(self.description)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -26,7 +26,7 @@ class _DescModifier(_schema.PropertyModifier):
|
||||
description: str
|
||||
|
||||
def modify(self, prop: _schema.Property):
|
||||
prop.doc = _schema.split_doc(self.description)
|
||||
prop.description = _schema.split_doc(self.description)
|
||||
|
||||
|
||||
def include(source: str):
|
||||
|
||||
@@ -37,7 +37,7 @@ class Property:
|
||||
is_child: bool = False
|
||||
pragmas: List[str] = field(default_factory=list)
|
||||
doc_name: Optional[str] = None
|
||||
doc: List[str] = field(default_factory=list)
|
||||
description: List[str] = field(default_factory=list)
|
||||
|
||||
@property
|
||||
def is_single(self) -> bool:
|
||||
|
||||
@@ -71,9 +71,9 @@ module Generated {
|
||||
}
|
||||
|
||||
/**
|
||||
* {{>ql_property_doc}}{{#has_doc}}{{#doc}} * {{.}}
|
||||
{{/doc}}
|
||||
{{/has_doc}}
|
||||
* {{>ql_property_doc}}{{#has_description}}{{#description}} * {{.}}
|
||||
{{/description}}
|
||||
{{/has_description}}
|
||||
*/
|
||||
final {{type}} {{getter}}({{#is_repeated}}int index{{/is_repeated}}) {
|
||||
result = getImmediate{{singular}}({{#is_repeated}}index{{/is_repeated}}).resolve()
|
||||
@@ -83,9 +83,9 @@ module Generated {
|
||||
{{^type_is_class}}
|
||||
{{^is_predicate}}
|
||||
/**
|
||||
* {{>ql_property_doc}}{{#has_doc}}{{#doc}} * {{.}}
|
||||
{{/doc}}
|
||||
{{/has_doc}}
|
||||
* {{>ql_property_doc}}{{#has_description}}{{#description}} * {{.}}
|
||||
{{/description}}
|
||||
{{/has_description}}
|
||||
*/
|
||||
{{/is_predicate}}
|
||||
{{#is_predicate}}
|
||||
|
||||
@@ -137,14 +137,14 @@ def test_class_without_doc():
|
||||
assert cls.has_doc is False
|
||||
|
||||
|
||||
def test_property_with_doc():
|
||||
prop = ql.Property("X", "int", doc=["foo", "bar"])
|
||||
assert prop.has_doc is True
|
||||
def test_property_with_description():
|
||||
prop = ql.Property("X", "int", description=["foo", "bar"])
|
||||
assert prop.has_description is True
|
||||
|
||||
|
||||
def test_class_without_doc():
|
||||
def test_class_without_description():
|
||||
prop = ql.Property("X", "int")
|
||||
assert prop.has_doc is False
|
||||
assert prop.has_description is False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -633,18 +633,19 @@ def test_test_class_hierarchy_uncollapse_at_final(opts, generate_tests):
|
||||
}
|
||||
|
||||
|
||||
def test_property_doc(generate_classes):
|
||||
doc = ["Lorem", "Ipsum"]
|
||||
def test_property_description(generate_classes):
|
||||
description = ["Lorem", "Ipsum"]
|
||||
assert generate_classes([
|
||||
schema.Class("MyObject", properties=[
|
||||
schema.SingleProperty("foo", "bar", doc=doc),
|
||||
schema.SingleProperty("foo", "bar", description=description),
|
||||
]),
|
||||
]) == {
|
||||
"MyObject.qll": (ql.Stub(name="MyObject", base_import=gen_import_prefix + "MyObject"),
|
||||
ql.Class(name="MyObject", final=True,
|
||||
properties=[
|
||||
ql.Property(singular="Foo", type="bar", tablename="my_objects",
|
||||
tableparams=["this", "result"], doc_name="foo", doc=doc),
|
||||
tableparams=["this", "result"], doc_name="foo",
|
||||
description=description),
|
||||
])),
|
||||
}
|
||||
|
||||
|
||||
@@ -428,7 +428,7 @@ def test_property_docstring():
|
||||
x: int | defs.desc("very important property.")
|
||||
|
||||
assert data.classes == {
|
||||
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', doc=["very important property."])])
|
||||
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', description=["very important property."])])
|
||||
}
|
||||
|
||||
|
||||
@@ -452,7 +452,7 @@ def test_property_docstring_newline():
|
||||
property.""")
|
||||
|
||||
assert data.classes == {
|
||||
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', doc=["very important", "property."])])
|
||||
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', description=["very important", "property."])])
|
||||
}
|
||||
|
||||
|
||||
@@ -482,7 +482,7 @@ def test_property_docstring_stripped():
|
||||
""")
|
||||
|
||||
assert data.classes == {
|
||||
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', doc=["very important property."])])
|
||||
'A': schema.Class('A', properties=[schema.SingleProperty('x', 'int', description=["very important property."])])
|
||||
}
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ def test_property_docstring_split():
|
||||
|
||||
assert data.classes == {
|
||||
'A': schema.Class('A', properties=[
|
||||
schema.SingleProperty('x', 'int', doc=["very important property.", "", "Very very important."])])
|
||||
schema.SingleProperty('x', 'int', description=["very important property.", "", "Very very important."])])
|
||||
}
|
||||
|
||||
|
||||
@@ -538,7 +538,7 @@ def test_property_docstring_indent():
|
||||
|
||||
assert data.classes == {
|
||||
'A': schema.Class('A', properties=[
|
||||
schema.SingleProperty('x', 'int', doc=["very important property.", " Very very important."])])
|
||||
schema.SingleProperty('x', 'int', description=["very important property.", " Very very important."])])
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user