Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.eclipse.xtext.EcoreUtil2
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext

import static extension nl.esi.xtext.actions.utilities.ActionsUtilities.*
import nl.esi.comma.assertthat.assertThat.DataAssertions

/**
* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#content-assist
Expand All @@ -49,7 +50,7 @@ class ProductIdeProposalProvider extends AbstractProductIdeProposalProvider {
case expressionGrammarAccess.expressionLevel8Access.fieldRecordFieldCrossReference_1_0_2_0,
case actionsGrammarAccess.fieldAccessExpAccess.fieldRecordFieldCrossReference_1_2_0: [
val field = EObjectOrProxy as RecordField
return context.isReferenceUpdate
return context.isReferenceUpdate || context.isAssertion
? !context.suppressedFields.contains(field)
: field.kind != RecordFieldKind.SYMBOLIC
]
Expand Down Expand Up @@ -77,6 +78,10 @@ class ProductIdeProposalProvider extends AbstractProductIdeProposalProvider {
return EcoreUtil2.getContainerOfType(context.currentModel, DataReferences) !== null
}

protected def boolean isAssertion(ContentAssistContext context) {
return EcoreUtil2.getContainerOfType(context.currentModel, DataAssertions) !== null
}

protected def getSuppressedFields(ContentAssistContext context) {
val suppressedVarFields = EcoreUtil2.getContainerOfType(context.currentModel, UpdateOutVar)?.suppress?.
varFields ?: Collections.emptyList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import "http://www.esi.nl/xtext/expressions/Expression" as expr

DataAssertions: {DataAssertions}
'assertions' name = ID '{'
constr += DataAssertionItem+
'}'
constr += DataAssertionItem*
'}'
;

DataAssertionItem:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
/**
* Copyright (c) 2024, 2025 TNO-ESI
*
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
*
* This program and the accompanying materials are made available
* under the terms of the MIT License which is available at
* https://opensource.org/licenses/MIT
*
*
* SPDX-License-Identifier: MIT
*/
/*
* generated by Xtext 2.36.0
*/
package nl.esi.comma.assertthat.validation

import nl.esi.comma.assertthat.assertThat.AssertThatPackage
import nl.esi.comma.assertthat.assertThat.DataAssertions
import org.eclipse.xtext.validation.Check

/**
* This class contains custom validation rules.
*
*
* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
*/
class AssertThatValidator extends AbstractAssertThatValidator {

// public static val INVALID_NAME = 'invalidName'
//
// @Check
// def checkGreetingStartsWithCapital(Greeting greeting) {
// if (!Character.isUpperCase(greeting.name.charAt(0))) {
// warning('Name should start with a capital',
// AssertThatPackage.Literals.GREETING__NAME,
// INVALID_NAME)
// }
// }

@Check
def checkGreetingStartsWithCapital(DataAssertions dataAssertions) {
if (dataAssertions.constr.isNullOrEmpty) {
error('At least 1 assertion is required', AssertThatPackage.Literals.DATA_ASSERTIONS__CONSTR)
}
}
}
Loading