Skip to content

Commit

Permalink
Merge 8443e1b into ea3916e
Browse files Browse the repository at this point in the history
  • Loading branch information
albertleigh committed Jan 9, 2022
2 parents ea3916e + 8443e1b commit 1b7ec23
Show file tree
Hide file tree
Showing 29 changed files with 414 additions and 348 deletions.
3 changes: 1 addition & 2 deletions examples/easy-example/src/editors/DummyEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,8 @@ const useStyles = makeStyles((theme) => ({

// @item().one['two'].


const sampleCodes =
`@activity('GetMetadata 2').output.structure[1].`;
`@min(pipeline().globalParameters.oneTypedObj.anotherGlobalFloat,activity('Lookup 3').output.firstRow.count)`;

const MONACO_EDITOR_ID = 'first-dummy-monaco-editor';

Expand Down
1 change: 1 addition & 0 deletions examples/easy-example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"strictNullChecks": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export const mount = (root:HTMLDivElement)=> {
MONACO_EDITOR_ID,
rootSymbolTable
)
AzLogicAppExpressionLangMonacoEditor.init.then(()=>{
AzLogicAppExpressionLangMonacoEditor.init?.then(()=>{
theEditor.azLgcExpDocEventEmitter?.subscribe(subscribeCodeDoc);
theEditor.validationResultEventEmitter?.subscribe(subscribeValidateResult);
(window as any).regenerateNextSymbolTable = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ function generateValidationTests(openOnePage, closeOnePage) {
"@concat('Baba', '''s ', 'book store')",
"@if(contains(json(item().DataLoadingBehaviorSettings).watermarkColumnType, 'Int'),'','''')",
"@equals(pipeline().globalParameters.firstGlobalStrPara, '0')",
"@array('abc', 'defg')",
"@union([1, 2, 3], [101, 2, 1, 10])",
"@min(pipeline().globalParameters.oneTypedObj.anotherGlobalFloat,activity('Lookup 3').output.firstRow.count)",
"@max(pipeline().globalParameters.oneTypedObj.anotherGlobalNumber,activity('Lookup 4').output.firstRow.count)",
"@coalesce(1,2,'',true, false, xml(''))",
"@createArray(1,2,'',true, false, json(''))",
"@float('0.777')",
"@subtractFromTime('',1, string( json('')))",
"@subtractFromTime('',1, string( json('')), 'another')",
].forEach((value, index)=>{
it(`Valid expression ${index}`, async ()=>{
let nextText, content, problems;
Expand Down
1 change: 1 addition & 0 deletions languages/monaco-az-logic-app-lang-e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"strictNullChecks": true,
"isolatedModules": false,
"noEmit": true,
"jsx": "react",
Expand Down
2 changes: 1 addition & 1 deletion languages/monaco-az-logic-app-lang/src/azLgcNodesUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export abstract class AbstractReturnChainType {
let isPropertyLiteral = false;
if (node.children?.length){
firstChildAstNode = node.children[0] as AzLogicAppNode;
switch (firstChildAstNode.$impostureLang.dataType) {
switch (firstChildAstNode.$impostureLang?.dataType) {
case 'string':
identifierName = codeDocument.getNodeContent(firstChildAstNode).replace(/'/gm, '');
label = identifierName;
Expand Down
2 changes: 1 addition & 1 deletion languages/monaco-az-logic-app-lang/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class AzLogicAppLangConstants{
static _init: Promise<any> | undefined = undefined;
static _registry: Registry | undefined = undefined;

static _grammar: IGrammar | undefined = undefined;
static _grammar: IGrammar | null | undefined = undefined;
static _theme: IRawTheme = themes['default'];
static _usingBuiltInTheme = true;

Expand Down
87 changes: 45 additions & 42 deletions languages/monaco-az-logic-app-lang/src/completionProviderHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ function buildCompletionItemKindFromValueDescription(vd: ValueDescription): lang
switch (vd._$type) {
case DescriptionType.OverloadedFunctionValue:
case DescriptionType.FunctionValue:
return AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Function;
return AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Function;
case DescriptionType.ReferenceValue:
return AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Variable;
return AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Variable;
case DescriptionType.PackageReference:
return AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Reference;
return AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Reference;
}
return AzLogicAppLangConstants._monaco.languages.CompletionItemKind.User;
return AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.User;
}

function buildCompletionItemFromDescriptorCollectionEntry(
Expand Down Expand Up @@ -136,7 +136,7 @@ function buildCompletionItemFromDescriptorCollectionEntry(
new Array(getFunctionParaCntFromDc(dci)).fill('').join(', ');
return {
label: buildFunctionLabelWithPara(dciPaths, dci),
kind: AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Function,
kind: AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Function,
insertText: `${paths}(${innerParaCommas})${paramComma}`,
range: contentRange,
};
Expand Down Expand Up @@ -201,7 +201,7 @@ function generateCompletionListByConstantArray(
.map(value => ({
label: value.constantStringValue,
insertText: value.constantStringValue,
kind: AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Constant,
kind: AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Constant,
range: contentRange,
}))
}
Expand Down Expand Up @@ -252,7 +252,7 @@ export function generateCompletion(
// populate the whole functions list directly
const startPos = model.getPositionAt(offset);
const endPos = model.getPositionAt(offset);
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand All @@ -272,7 +272,7 @@ export function generateCompletion(
new Array(getFunctionParaCntFromDc(valDci)).fill('').join(', ');
return {
label: buildFunctionLabelWithPara(value.paths, value.valDescCollItem),
kind: AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Function,
kind: AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Function,
insertText: `${paths}(${paraCommas})`,
range: contentRange,
};
Expand Down Expand Up @@ -354,7 +354,7 @@ export function generateCompletion(
// root function after at symbol
const startPos = model.getPositionAt(node.atSymbolNode.offset + node.atSymbolNode.length);
const endPos = model.getPositionAt(offset);
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand All @@ -374,7 +374,7 @@ export function generateCompletion(
new Array(getFunctionParaCntFromDc(valDci)).fill('').join(', ');
return {
label: buildFunctionLabelWithPara(value.paths, value.valDescCollItem),
kind: AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Function,
kind: AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Function,
insertText: `${paths}(${paraCommas})`,
range: contentRange,
};
Expand Down Expand Up @@ -465,8 +465,8 @@ export function generateCompletion(
}
}else if (
// todo "identifiers-capture" might be inappropriate over here, consider changing it
originalAstNode.$impostureLang.dataType === "identifiers-capture" &&
originalAstNode.parent.$impostureLang.dataType === "identifiers:wPunctuation" &&
originalAstNode.$impostureLang?.dataType === "identifiers-capture" &&
originalAstNode.parent?.$impostureLang?.dataType === "identifiers:wPunctuation" &&
!(node instanceof IdentifierNode) &&
node instanceof ParenthesisNode &&
node.offset < offset &&
Expand All @@ -476,12 +476,14 @@ export function generateCompletion(
){
// incomplete identifier
const thePara = node.parameter(node.paramIndexByOffset(offset));
const chain = AbstractReturnChainType.findCompleteIdentifiersChain(
thePara.astNode as any, azLgcExpDoc.codeDocument
)
if (chain.chain.length) {
identifiersChain = chain.chain;
completionKind = CompletionType.PROPERTY;
if (thePara?.astNode){
const chain = AbstractReturnChainType.findCompleteIdentifiersChain(
thePara.astNode as any, azLgcExpDoc.codeDocument
)
if (chain.chain.length) {
identifiersChain = chain.chain;
completionKind = CompletionType.PROPERTY;
}
}
}else if(
node instanceof ParenthesisNode &&
Expand Down Expand Up @@ -523,7 +525,7 @@ export function generateCompletion(
if (parenthesesNode.parameter(paramIndex)){
// property
const chain = AbstractReturnChainType.findCompleteIdentifiersChain(
parenthesesNode.parameter(paramIndex).astNode as any, azLgcExpDoc.codeDocument
parenthesesNode.parameter(paramIndex)!.astNode as any, azLgcExpDoc.codeDocument
);
if (chain.chain.length) {
identifiersChain = chain.chain;
Expand Down Expand Up @@ -557,7 +559,7 @@ export function generateCompletion(
const lastFunCallId = functionCall.supportFunctionCallIdentifiers[functionCall.supportFunctionCallIdentifiers.length -1];
const startPos = model.getPositionAt(firstFunCallId.offset);
const endPos = model.getPositionAt(lastFunCallId.offset + lastFunCallId.length);
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand All @@ -574,7 +576,7 @@ export function generateCompletion(
// const vd = value.valueDescription;
return {
label: buildFunctionLabelWithPara(value.paths, value.valDescCollItem),
kind: AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Function,
kind: AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Function,
insertText: paths,
range: contentRange,
};
Expand Down Expand Up @@ -607,7 +609,7 @@ export function generateCompletion(
}
let startPos = model.getPositionAt(startOffset);
let endPos = model.getPositionAt(endOffset);
let contentRange = new AzLogicAppLangConstants._monaco.Range(
let contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand All @@ -619,19 +621,19 @@ export function generateCompletion(
// all white space content, reset insert pos
startPos = model.getPositionAt(offset);
endPos = model.getPositionAt(offset);
contentRange = new AzLogicAppLangConstants._monaco.Range(
contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
endPos.column
);
content = model.getValueInRange(contentRange);
}else if (
originalAstNode.$impostureLang.dataType === "identifiers"
originalAstNode.$impostureLang?.dataType === "identifiers"
){
startPos = model.getPositionAt(originalAstNode.offset);
endPos = model.getPositionAt(originalAstNode.offset + originalAstNode.length || 0);
contentRange = new AzLogicAppLangConstants._monaco.Range(
contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand Down Expand Up @@ -670,10 +672,10 @@ export function generateCompletion(
if (theFunDesc._$type === DescriptionType.OverloadedFunctionValue){
theFunDesc._$parameterTypes.forEach((olParaTypes, olParaIndex) => {
if (
olParaIndex !== functionCall.parameterSeq &&
olParaTypes[functionCall.parameterSeq]?.type === IdentifierTypeName.CONSTANT
olParaIndex !== functionCall!.parameterSeq &&
olParaTypes[functionCall!.parameterSeq]?.type === IdentifierTypeName.CONSTANT
){
constantsIdTypes.push(olParaTypes[functionCall.parameterSeq]);
constantsIdTypes.push(olParaTypes[functionCall!.parameterSeq]);
}
})
}
Expand Down Expand Up @@ -768,15 +770,16 @@ export function generateCompletion(
const endOffset = lastPropertyNode.offset + lastPropertyNode.length;
const startPos = model.getPositionAt(startOffset);
const endPos = model.getPositionAt(endOffset);
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
endPos.column
);
const content = model.getValueInRange(contentRange);
let result:languages.CompletionList;

let result:languages.CompletionList = {
suggestions:[]
};
const theReturnValueDescCollection: DescriptorCollection[] = [];
vdPathArr[identifierInBracketNotationIndex].vd.collectAllPathBeneath([], theReturnValueDescCollection)
if (theReturnValueDescCollection.length){
Expand Down Expand Up @@ -823,7 +826,7 @@ export function generateCompletion(
const endOffset = offset;
const startPos = model.getPositionAt(startOffset);
const endPos = model.getPositionAt(endOffset);
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand Down Expand Up @@ -871,7 +874,7 @@ export function generateCompletion(
const endOffset = lastPropertyNode.offset + (lastPropertyNode.length || 0);
const startPos = model.getPositionAt(startOffset);
const endPos = model.getPositionAt(endOffset);
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand Down Expand Up @@ -957,7 +960,7 @@ export function generateCompletion(
let endOffset = thePropertyNode.offset + (thePropertyNode.length || 0);
let startPos = model.getPositionAt(startOffset);
let endPos = model.getPositionAt(endOffset);
let contentRange = new AzLogicAppLangConstants._monaco.Range(
let contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand Down Expand Up @@ -1005,7 +1008,7 @@ export function generateCompletion(
endOffset = startOffset;
startPos = model.getPositionAt(startOffset);
endPos = model.getPositionAt(endOffset);
contentRange = new AzLogicAppLangConstants._monaco.Range(
contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand Down Expand Up @@ -1061,7 +1064,7 @@ export function generateCompletion(

const startPos = model.getPositionAt(node.literalArrayNode.startPosOfItem(0));
const endPos = model.getPositionAt(node.literalArrayNode.endPosOfItem(0));
const contentRange = new AzLogicAppLangConstants._monaco.Range(
const contentRange = new AzLogicAppLangConstants._monaco!.Range(
startPos.lineNumber,
startPos.column,
endPos.lineNumber,
Expand All @@ -1074,10 +1077,10 @@ export function generateCompletion(
node.elderSibling &&
node.elderSibling.rValue
){
let elderVd = node.elderSibling.rValue;
let elderVd:ValueDescription | undefined = node.elderSibling.rValue;
if (
elderVd._$type === DescriptionType.ReferenceValue &&
elderVd._$valueType.type === IdentifierTypeName.FUNCTION_RETURN_TYPE
elderVd?._$type === DescriptionType.ReferenceValue &&
elderVd?._$valueType.type === IdentifierTypeName.FUNCTION_RETURN_TYPE
){
elderVd = theLgcExpDocEditor.rootSymbolTable.findByPath(elderVd._$valueType.returnTypeChainList || []);
}
Expand All @@ -1088,7 +1091,7 @@ export function generateCompletion(
suggestions.push({
label: `'${oneField}'`,
insertText: `'${oneField}'`,
kind: AzLogicAppLangConstants._monaco.languages.CompletionItemKind.Text,
kind: AzLogicAppLangConstants._monaco!.languages.CompletionItemKind.Text,
range: contentRange,
})
})
Expand All @@ -1097,8 +1100,8 @@ export function generateCompletion(

// seize all string and number function call
const allFunctionsReturningStringAndNumber = [
...theLgcExpDocEditor.valueDescriptionDict.get(IdentifierType.String),
...theLgcExpDocEditor.valueDescriptionDict.get(IdentifierType.Number)
...theLgcExpDocEditor.valueDescriptionDict.get(IdentifierType.String)!,
...theLgcExpDocEditor.valueDescriptionDict.get(IdentifierType.Number)!
];

if (allFunctionsReturningStringAndNumber.length){
Expand Down

0 comments on commit 1b7ec23

Please sign in to comment.