Python: Move AdvancedFormatting dependents over to suffixed API

This commit is contained in:
Rebecca Valentine
2020-03-02 16:39:02 -08:00
parent de6ea63fae
commit 7930037bb6
7 changed files with 10 additions and 10 deletions

View File

@@ -13,6 +13,6 @@
import python
import AdvancedFormatting
from AdvancedFormattingCall call, AdvancedFormatString fmt
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt
where call.getAFormat() = fmt and fmt.isImplicitlyNumbered() and fmt.isExplicitlyNumbered()
select fmt, "Formatting string mixes implicitly and explicitly numbered fields."

View File

@@ -16,11 +16,11 @@ import python
import python
import AdvancedFormatting
int field_count(AdvancedFormatString fmt) { result = max(fmt.getFieldNumber(_, _)) + 1 }
int field_count(AdvancedFormatString_objectapi fmt) { result = max(fmt.getFieldNumber(_, _)) + 1 }
from AdvancedFormattingCall call, AdvancedFormatString fmt, int arg_count, int max_field
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt, int arg_count, int max_field
where arg_count = call.providedArgCount() and max_field = field_count(fmt) and
call.getAFormat() = fmt and not exists(call.getStarargs()) and
forall(AdvancedFormatString other | other = call.getAFormat() | field_count(other) < arg_count)
forall(AdvancedFormatString_objectapi other | other = call.getAFormat() | field_count(other) < arg_count)
select call, "Too many arguments for string format. Format $@ requires only " + max_field + ", but " +
arg_count.toString() + " are provided.", fmt, "\"" + fmt.getText() + "\""

View File

@@ -13,10 +13,10 @@
import python
import AdvancedFormatting
from AdvancedFormattingCall call, AdvancedFormatString fmt, string name, string fmt_repr
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt, string name, string fmt_repr
where call.getAFormat() = fmt and
name = call.getAKeyword().getArg() and
forall(AdvancedFormatString format | format = call.getAFormat() | not format.getFieldName(_, _) = name)
forall(AdvancedFormatString_objectapi format | format = call.getAFormat() | not format.getFieldName(_, _) = name)
and not exists(call.getKwargs()) and
(strictcount(call.getAFormat()) = 1 and fmt_repr = "format \"" + fmt.getText() + "\""
or

View File

@@ -14,7 +14,7 @@
import python
import AdvancedFormatting
from AdvancedFormattingCall call, AdvancedFormatString fmt, string name
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt, string name
where call.getAFormat() = fmt and
not name = call.getAKeyword().getArg() and
fmt.getFieldName(_, _) = name

View File

@@ -14,7 +14,7 @@
import python
import AdvancedFormatting
from AdvancedFormattingCall call, AdvancedFormatString fmt,
from AdvancedFormattingCall_objectapi call, AdvancedFormatString_objectapi fmt,
int arg_count, int max_field, string provided
where arg_count = call.providedArgCount() and max_field = max(fmt.getFieldNumber(_, _)) and
call.getAFormat() = fmt and not exists(call.getStarargs()) and arg_count <= max_field and

View File

@@ -2,7 +2,7 @@
import python
import Expressions.Formatting.AdvancedFormatting
from AdvancedFormatString a, string name, int start, int end
from AdvancedFormatString_objectapi a, string name, int start, int end
where
name = "'" + a.getFieldName(start, end) + "'"
or

View File

@@ -2,5 +2,5 @@
import python
import Expressions.Formatting.AdvancedFormatting
from AdvancedFormatString a, int start, int end
from AdvancedFormatString_objectapi a, int start, int end
select a.getLocation().getStartLine(), a.getText(), start, end, a.getField(start, end)