public final class ScoreProfile extends Object
"Better" depends on the intended style (river-aligned Celko layout vs the
compact sqlfmt look vs the ISF default), so every threshold, weight, target
width and alignment expectation lives in a JSON resource under
/gudusoft/gsqlparser/pp/score/profiles/ and nothing numeric is
hard-coded in the rules. Three profiles ship: isf-default,
river, compact. A user profile file may set
"extends": "isf-default" to inherit everything it does not override.
Scores are only comparable within one profile and one corpus while the
profile's calibration is heuristic-v0.
| Modifier and Type | Class and Description |
|---|---|
static class |
ScoreProfile.ClauseAlign |
static class |
ScoreProfile.JoinIndent
Where JOIN clause keywords sit: on the clause spine, or at the block's content column (ISF style).
|
static class |
ScoreProfile.JoinOnIndent |
| Modifier and Type | Field and Description |
|---|---|
static String |
COMPACT |
static String |
ISF_DEFAULT |
static String |
RESOURCE_DIR
Where the built-in profiles live on the classpath.
|
static String |
RIVER |
| Modifier and Type | Method and Description |
|---|---|
static ScoreProfile |
builtin(String name)
Load a built-in profile by name (
isf-default, river, compact). |
static ScoreProfile |
defaults()
The default profile (
isf-default). |
static ScoreProfile |
fromJson(String json)
Parse a profile from JSON text, honouring
"extends". |
String |
getCalibration()
heuristic-v0 until pairwise human votes re-fit the weights (bt-v1). |
ScoreProfile.ClauseAlign |
getClauseAlign() |
String |
getDescription() |
int |
getIndentUnit()
U: indent unit;
0 means auto-detect from the output. |
int |
getIndentUnitFallback() |
int |
getInlineBlockMaxLen() |
int |
getInlineListMaxItems() |
int |
getInlineListMaxLen() |
ScoreProfile.JoinIndent |
getJoinIndent() |
ScoreProfile.JoinOnIndent |
getJoinOnIndent() |
String |
getName() |
int |
getTabSize() |
int |
getTargetWidth()
W: target line width.
|
Map<String,Double> |
getThresholds()
All rule thresholds (
RULE.param keys). |
Map<String,Double> |
getWeights()
Dimension id to weight, as declared (before any automatic adjustment).
|
boolean |
hasThr(String key)
Whether the profile defines a threshold.
|
boolean |
isAliasAlign() |
boolean |
isAndOrLineStart()
True: AND/OR start their line; false: AND/OR end the previous line.
|
boolean |
isBlankBetweenStatements() |
boolean |
isErrorRegionPreserve() |
boolean |
isJoinOnNewLine() |
boolean |
isStrictIdentifierCase()
When true, an unquoted identifier whose case changed between original and
formatted text fails the
IDENTIFIER_CASE gate check (relevant for
case-sensitive object names, e.g. |
static ScoreProfile |
load(String nameOrPath)
Resolve a profile from a built-in name or a file path.
|
double |
thr(String key)
A rule threshold.
|
String |
toString() |
double |
weight(String dimension) |
public static final String RESOURCE_DIR
public static final String ISF_DEFAULT
public static final String RIVER
public static final String COMPACT
public static ScoreProfile builtin(String name)
isf-default, river, compact).public static ScoreProfile defaults()
isf-default).public static ScoreProfile load(String nameOrPath) throws IOException
.json.IOExceptionpublic static ScoreProfile fromJson(String json)
"extends".public String getCalibration()
heuristic-v0 until pairwise human votes re-fit the weights (bt-v1).public String getDescription()
public int getTargetWidth()
public int getIndentUnit()
0 means auto-detect from the output.public int getIndentUnitFallback()
public int getTabSize()
public ScoreProfile.ClauseAlign getClauseAlign()
public boolean isAndOrLineStart()
public ScoreProfile.JoinOnIndent getJoinOnIndent()
public ScoreProfile.JoinIndent getJoinIndent()
public boolean isJoinOnNewLine()
public boolean isAliasAlign()
public boolean isBlankBetweenStatements()
public boolean isErrorRegionPreserve()
public boolean isStrictIdentifierCase()
IDENTIFIER_CASE gate check (relevant for
case-sensitive object names, e.g. MySQL with lower_case_table_names=0).
Off by default because formatters recase identifiers on purpose
(GFmtOpt.caseIdentifier, function names); the count is always reported.public int getInlineListMaxItems()
public int getInlineListMaxLen()
public int getInlineBlockMaxLen()
public Map<String,Double> getWeights()
public Map<String,Double> getThresholds()
RULE.param keys).public double thr(String key)