Skip to content

Commit

Permalink
Refactoring (finos#828)
Browse files Browse the repository at this point in the history
* added unit test

* Fixes finos#785

* Fixed test

* Cleaned

* WIP

* WIP

* WIP

* Initial fixes

* WIP

* Fixed tests

* Cleaned

* Fixed

* Cleaned

* Fixed

* Cleaned
  • Loading branch information
SimonCockx authored Sep 6, 2024
1 parent 1fe2d32 commit c20eb67
Show file tree
Hide file tree
Showing 90 changed files with 2,394 additions and 2,073 deletions.
42 changes: 30 additions & 12 deletions .github/workflows/branch-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Deploy a branch as a snapshot version.

on:
workflow_dispatch:
inputs:
run-tests:
type: boolean
description: Run tests
default: true

# Cancel previous jobs
concurrency:
Expand All @@ -12,15 +17,28 @@ jobs:
deploy-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Normalize branch name
id: normalize-branch-name
uses: ./.github/actions/normalize-branch-name
- name: Set version
run: mvn -B versions:set -DnewVersion=0.0.0.${{ steps.normalize-branch-name.outputs.normalized }}-SNAPSHOT
- uses: ./.github/actions/maven-build
with:
build-command: deploy # Deploy a snapshot build of main
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
- uses: actions/checkout@v4
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
architecture: x64
cache: maven
server-id: ossrh
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD
gpg-private-key: ${{ secrets.RUNE_GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Normalize branch name
id: normalize-branch-name
uses: ./.github/actions/normalize-branch-name
- name: Set version
run: mvn -B versions:set -DgenerateBackupPoms=false -DnewVersion=0.0.0.${{ steps.normalize-branch-name.outputs.normalized }}-SNAPSHOT
- uses: ./.github/actions/maven-build
with:
build-command: deploy
run-tests: ${{ inputs.run-tests }}
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
106 changes: 58 additions & 48 deletions rosetta-ide/rosetta.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ variables:
# - keywords that may also be used as an identifier (e.g., `version`),
# - keywords that may also be used as another keyword in a certain context (e.g., `synonym`),
# - keywords that are unambiguous, i.e., all other keywords indicating the start of a root element.
identifiersConflictingWithRootStart: '{{wordStart}}(version){{wordEnd}}'
identifiersConflictingWithNamespace: '{{wordStart}}(version){{wordEnd}}'
ambiguousRootStart: '{{wordStart}}(synonym|rule){{wordEnd}}'
unambiguousRootStart: '{{wordStart}}(namespace|import|isEvent|isProduct|body|corpus|segment|basicType|recordType|typeAlias|library|reporting|eligibility|metaType|report|annotation|enum|type|choice|func){{wordEnd}}'
rootStart: '{{identifiersConflictingWithRootStart}}|{{ambiguousRootStart}}|{{unambiguousRootStart}}'
strictRootEnd: (?={{rootStart}})
rootStart: '{{ambiguousRootStart}}|{{unambiguousRootStart}}'
namespaceEnd: (?={{identifiersConflictingWithNamespace}}|{{ambiguousRootStart}}|{{unambiguousRootStart}})
rootEnd: (?={{ambiguousRootStart}}|{{unambiguousRootStart}})
unambiguousRootEnd: (?={{unambiguousRootStart}})

sectionStart: '{{wordStart}}((\Qpost-\E)?condition|set|add|inputs|output|alias){{wordEnd}}'
sectionEnd: (?={{sectionStart}}|{{rootStart}})(?!\bcondition\b)|(?=\bcondition\b\s*({{identifier}})?:)
functionalOperation: '{{wordStart}}(reduce|filter|map|extract|sort|min|max){{wordEnd}}'
Expand All @@ -45,7 +44,8 @@ variables:
synonymAnnotationSectionEnd: (?={{synonymAnnotationSection}})|(?=\])|{{rootEnd}}
docReferenceAnnotationSection: '{{wordStart}}(rationale|rationale_author|structured_provision|provision|reportedField){{wordEnd}}'
docReferenceAnnotationSectionEnd: (?={{docReferenceAnnotationSection}}|\])|{{sectionEnd}}
expressionEnd: '(?=,|\)|\])|{{sectionEnd}}'
expressionEndIgnoringComma: '(?=\)|\]|\})|(?={{wordStart}}to{{wordEnd}}\s)|{{sectionEnd}}'
expressionEnd: '(?=,)|{{expressionEndIgnoringComma}}'
functionalOperationEnd: (?={{listOperation}}|{{wordStart}}(else|then){{wordEnd}})|{{expressionEnd}}

patterns:
Expand All @@ -55,30 +55,20 @@ patterns:
repository:
model:
patterns:
- include: '#override'
- include: '#namespace'
- include: '#version'
- include: '#import'
- include: '#configuration'
- include: '#rootElement'

repository:
override:
name: meta.override.rosetta
begin: '{{wordStart}}override{{wordEnd}}'
beginCaptures:
0: { name: keyword.other.override.rosetta }
end: '{{rootEnd}}'
patterns:
- include: '#comment'
- include: '#string'

namespace:
name: meta.namespace.rosetta
begin: '{{wordStart}}namespace{{wordEnd}}'
begin: '(?:{{wordStart}}(override){{wordEnd}}\s+)?{{wordStart}}(namespace){{wordEnd}}'
beginCaptures:
0: { name: keyword.other.namespace.rosetta }
end: '{{strictRootEnd}}'
1: { name: keyword.other.override.rosetta }
2: { name: keyword.other.namespace.rosetta }
end: '{{namespaceEnd}}'
patterns:
- include: '#comment'
- include: '#documentation'
Expand Down Expand Up @@ -108,6 +98,8 @@ repository:
patterns:
- include: '#comment'
- include: '#string'
- name: keyword.other.as.rosetta
match: '{{wordStart}}as{{wordEnd}}'
- name: entity.name.namespace.rosetta
match: '{{identifier}}'
- name: punctuation.separator.dot.rosetta
Expand Down Expand Up @@ -1044,18 +1036,18 @@ repository:
match: '{{identifier}}'
- include: '#comment'
- include: '#documentationFollowedByExpression'

expression:
name: meta.expression.rosetta
begin: (?!,|\(|\s|^|$)
begin: (?!,|\s|^|$)
end: '{{expressionEnd}}'
patterns:
- include: '#comment'
- name: meta.parens.rosetta
begin: (\()
beginCaptures:
1: { name: punctuation.group.begin.rosetta }
end: (\))|{{sectionEnd}}
end: (\))|({{sectionEnd}})
endCaptures:
1: { name: punctuation.group.end.rosetta }
patterns:
Expand All @@ -1065,33 +1057,13 @@ repository:
begin: (\[)
beginCaptures:
1: { name: punctuation.list.begin.rosetta }
end: (\])|(?=\))|{{sectionEnd}}
end: (\])|({{expressionEndIgnoringComma}})
endCaptures:
1: { name: punctuation.list.end.rosetta }
patterns:
- include: '#expression'
- include: '#comma'
- name: meta.constructor.rosetta
begin: (\{)
beginCaptures:
1: { name: punctuation.constructor.begin.rosetta }
end: (\})|(?=\))|{{sectionEnd}}
endCaptures:
1: { name: punctuation.constructor.end.rosetta }
patterns:
- include: '#comment'
- name: meta.constructor.key-value.rosetta
begin: '{{identifier}}'
beginCaptures:
0: { name: variable.other.member.rosetta }
end: (?=,|\}|\))|{{sectionEnd}}
patterns:
- include: '#comment'
- include: '#colon'
- include: '#expression'
- include: '#comma'
- name: keyword.other.triple-dot.rosetta
match: '\.\.\.'
- include: '#constructorExpression'
- include: '#functionalOperation'
- name: meta.then-operation.rosetta
begin: '{{wordStart}}then{{wordEnd}}'
Expand All @@ -1103,7 +1075,7 @@ repository:
- begin: \[
beginCaptures:
0: { name: punctuation.definition.inline-function.begin.rosetta }
end: \]|{{expressionEnd}}
end: \]|({{expressionEnd}})
patterns:
- include: '#comment'
- include: '#expression'
Expand Down Expand Up @@ -1144,7 +1116,7 @@ repository:
- begin: '{{wordStart}}(optional|required){{wordEnd}}'
beginCaptures:
0: { name: keyword.operator.word.rosetta }
end: '{{expressionEnd}}'
end: '{{expressionEndIgnoringComma}}'
patterns:
- name: keyword.operator.word.rosetta
match: '{{wordStart}}choice{{wordEnd}}'
Expand All @@ -1156,18 +1128,56 @@ repository:
begin: '{{wordStart}}to-enum{{wordEnd}}'
beginCaptures:
0: { name: keyword.operator.word.rosetta }
end: '{{identifier}}'
end: '{{qualifiedIdentifier}}'
endCaptures:
0: { name: entity.name.type.enum.rosetta }
patterns:
- include: '#comment'
- name: meta.switch-operation.rosetta
begin: '{{wordStart}}switch{{wordEnd}}'
beginCaptures:
0: { name: keyword.operator.word.rosetta }
end: '{{expressionEndIgnoringComma}}'
patterns:
- include: '#comment'
- begin: '{{wordStart}}then{{wordEnd}}'
beginCaptures:
0: { name: keyword.control.conditional.then.rosetta }
end: '{{expressionEnd}}'
patterns:
- include: '#comment'
- include: '#expression'
- include: '#expression'
- name: keyword.operator.word.rosetta
match: '{{listOperationWord}}|{{wordStart}}(any|all|or|and|contains|default|disjoint|join|only|exists|as-key|one-of|as|to-number|to-int|to-time|to-date|to-date-time|to-zoned-date-time|to-string){{wordEnd}}'
match: '{{listOperationWord}}|{{wordStart}}(any|all|or|and|contains|default|disjoint|join|only|exists|as-key|one-of|as(?!-)|to-number|to-int|to-time|to-date|to-date-time|to-zoned-date-time|to-string){{wordEnd}}'
- name: keyword.operator.rosetta
match: =|<>|>=|<=|>|<|\+|-|\*|\/
- name: variable.rosetta # Need semantic tokens to specify variable
match: '{{identifier}}'

constructorExpression:
name: meta.constructor.rosetta
begin: (\{)
beginCaptures:
1: { name: punctuation.constructor.begin.rosetta }
end: (\})|({{expressionEndIgnoringComma}})
endCaptures:
1: { name: punctuation.constructor.end.rosetta }
patterns:
- include: '#comment'
- name: meta.constructor.key-value.rosetta
begin: '{{identifier}}'
beginCaptures:
0: { name: variable.other.member.output.rosetta }
end: (?=,|\})|({{expressionEnd}})
patterns:
- include: '#comment'
- include: '#colon'
- include: '#expression'
- include: '#comma'
- name: keyword.other.triple-dot.rosetta
match: '\.\.\.'

literal:
patterns:
- include: '#string'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.nodemodel.util.NodeModelUtils;

import com.regnosys.rosetta.RosettaExtensions;
import com.regnosys.rosetta.RosettaEcoreUtil;
import com.regnosys.rosetta.types.CardinalityProvider;
import com.regnosys.rosetta.rosetta.expression.InlineFunction;
import com.regnosys.rosetta.rosetta.expression.MapOperation;
Expand All @@ -37,7 +37,7 @@

public class RosettaInlayHintsService extends AbstractInlayHintsService {
@Inject
private RosettaExtensions extensions;
private RosettaEcoreUtil extensions;
@Inject
private RosettaTypeProvider types;
@Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.regnosys.rosetta.ide.semantictokens;

public enum AttributeType {
INPUT,
OUTPUT,
OTHER;
}
Loading

0 comments on commit c20eb67

Please sign in to comment.