Skip to content

Commit

Permalink
Merge pull request #7 from Avaiga/bug/#130-scope-suffix
Browse files Browse the repository at this point in the history
#130 scope suffix
  • Loading branch information
FredLL-Avaiga committed Jan 19, 2023
2 parents 16959c1 + c8285de commit 8510fa3
Show file tree
Hide file tree
Showing 9 changed files with 290 additions and 263 deletions.
4 changes: 2 additions & 2 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"Enter a name for a new {0} entity.": "Enter a name for a new {0} entity.",
"new {0} name": "new {0} name",
"New module name": "New module name",
"create a new function": "create a new function",
"create a new class": "create a new class",
"Create a new function": "Create a new function",
"Create a new class": "Create a new class",
"function name": "function name",
"class name": "class name",
"No selected element.": "No selected element.",
Expand Down
262 changes: 140 additions & 122 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Taipy Studio Configuration Builder",
"description": "Visual Studio Code extension for Taipy: Configuration Builder",
"publisher": "Taipy",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/Avaiga/taipy-studio-config.git",
"repository": {
"type": "git",
Expand Down
52 changes: 29 additions & 23 deletions schemas/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"description": "An enum value among GLOBAL, CYCLE, SCENARIO or PIPELINE that represents the visibility of the data node in the graph of entities.",
"type": "string",
"enum": [
"GLOBAL",
"CYCLE",
"SCENARIO",
"PIPELINE",
"GLOBAL:SCOPE",
"CYCLE:SCOPE",
"SCENARIO:SCOPE",
"PIPELINE:SCOPE",
""
],
"default": "SCENARIO"
"default": "SCENARIO:SCOPE"
},
"storage_type": {
"description": "An enum value indicating the type of storage of the data node.",
Expand Down Expand Up @@ -231,7 +231,7 @@
"if": {
"properties": {
"storage_type": {
"constant": "sql"
"const": "sql"
}
}
},
Expand All @@ -242,19 +242,15 @@
]
},
"else": {
"then": {
"required": [
"table_name"
]
}
}
},
"else": {
"then": {
"required": [
"collection_name"
"table_name"
]
}
},
"else": {
"required": [
"collection_name"
]
}
}
}
Expand Down Expand Up @@ -342,11 +338,12 @@
"description": "The recurrence of the scenarios instantiated from this configuration. Based on this frequency the scenarios will be attached to the right cycles.",
"type": "string",
"enum": [
"DAILY",
"WEEKLY",
"MONTHLY",
"QUARTERLY",
"YEARLY"
"DAILY:FREQUENCY",
"WEEKLY:FREQUENCY",
"MONTHLY:FREQUENCY",
"QUARTERLY:FREQUENCY",
"YEARLY:FREQUENCY",
""
]
},
"comparators": {
Expand Down Expand Up @@ -374,6 +371,7 @@
},
"clean_entities_enabled": {
"description": "Boolean field to activate/deactivate the clean entities feature.",
"type": "string",
"enum": [
"True:bool",
"False:bool"
Expand All @@ -382,10 +380,14 @@
},
"read_entity_retry": {
"description": "Number of times to retry before return failure to read an entity.",
"type": "int"
"type": [
"integer",
"string"
]
},
"repository_type": {
"description": "The repository type that is used to store the entities.",
"type": "string",
"enum": [
"sql",
"filesystem"
Expand All @@ -402,6 +404,7 @@
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"standalone",
"development"
Expand All @@ -410,7 +413,10 @@
},
"max_nb_of_workers": {
"description": "mode: standalone specific. The maximum number of jobs able to run in parallel.",
"type": "int"
"type": [
"integer",
"string"
]
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/providers/CompletionItemProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const getPythonSymbols = async (isFunction: boolean, lineText: string, position:
return pv;
}, {} as Record<string, string>);
symbolsByUri.forEach((su) => {
su.symbols.forEach((symbol) => {
Array.isArray(su.symbols) && su.symbols.forEach((symbol) => {
if ((isFunction && symbol.kind === SymbolKind.Function) || (!isFunction && symbol.kind === SymbolKind.Class)) {
symbolsWithModule.push(`${modulesByUri[su.uri.path]}.${symbol.name}`);
}
Expand All @@ -180,10 +180,13 @@ const getPythonSymbols = async (isFunction: boolean, lineText: string, position:
const modules = Object.values(modulesByUri);
modules.push(l10n.t("New module name"));
cis.push(
getCompletionItemInString(isFunction ? l10n.t("create a new function") : l10n.t("create a new class"), lineText, position, [
modules.length === 1 ? modules[0] : modules,
isFunction ? l10n.t("function name") : l10n.t("class name"),
], getPythonSuffix(isFunction))
getCompletionItemInString(
isFunction ? l10n.t("Create a new function") : l10n.t("Create a new class"),
lineText,
position,
[modules.length === 1 ? modules[0] : modules, isFunction ? l10n.t("function name") : l10n.t("class name")],
getPythonSuffix(isFunction)
)
);
return cis;
};
Expand Down Expand Up @@ -300,7 +303,7 @@ const appendPlaceHolders = (si: SnippetString, placeHolders?: [string[] | string
} else {
si.appendPlaceholder(ph);
}
});
});
};

const getPosFromMatches = (matches: string[], line: string) => {
Expand Down
4 changes: 2 additions & 2 deletions src/providers/PythonCodeActionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
workspace,
WorkspaceEdit,
} from "vscode";
import { getPythonSuffix } from "../utils/symbols";
import { getPythonSuffix, getUnsuffixedName } from "../utils/symbols";

export class PythonCodeActionProvider implements CodeActionProvider {
private static readonly providedCodeActionKinds = [CodeActionKind.QuickFix];
Expand All @@ -50,7 +50,7 @@ export class PythonCodeActionProvider implements CodeActionProvider {
.map((diagnostic) => {
const code = diagnostic.code as { target: Uri; value: string };
const isFunction = code.target.query.split("&")[0] === "taipy-config=function";
const pythonName = document.getText(diagnostic.range).slice(1, -1);
const pythonName = getUnsuffixedName(document.getText(diagnostic.range).slice(1, -1));
const parts = pythonName.split(".");
const pythonSymbol = parts.at(-1);
parts.pop(); // ignore symbol name
Expand Down
4 changes: 2 additions & 2 deletions src/schema/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ let validationFunction: ValidateFunction<JsonMap>;
export const getValidationFunction = async () => {
if (!validationFunction) {
const schema = await getValidationSchema();
const ajv = new Ajv({ strictTypes: false, allErrors: true, allowUnionTypes: true });
validationFunction = ajv.compile<JsonMap>(schema);
const ajv = new Ajv({ strictTypes: false, allErrors: true, allowUnionTypes: true, keywords: ["taipy_function", "taipy_class"] });
validationFunction = await ajv.compile<JsonMap>(schema);
}
return validationFunction;
};
Expand Down
Loading

0 comments on commit 8510fa3

Please sign in to comment.