From 57db96be725935efce57a4d1560eefaf9793019b Mon Sep 17 00:00:00 2001 From: Martin Jobst Date: Fri, 24 Jan 2025 15:03:40 +0100 Subject: [PATCH] Fix data type keywords in ST highlighting --- .../STCoreAntlrTokenToAttributeIdMapper.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.fordiac.ide.structuredtextcore.ui/src/org/eclipse/fordiac/ide/structuredtextcore/ui/syntaxcoloring/STCoreAntlrTokenToAttributeIdMapper.java b/plugins/org.eclipse.fordiac.ide.structuredtextcore.ui/src/org/eclipse/fordiac/ide/structuredtextcore/ui/syntaxcoloring/STCoreAntlrTokenToAttributeIdMapper.java index b03c14c41e..2c0893acfa 100644 --- a/plugins/org.eclipse.fordiac.ide.structuredtextcore.ui/src/org/eclipse/fordiac/ide/structuredtextcore/ui/syntaxcoloring/STCoreAntlrTokenToAttributeIdMapper.java +++ b/plugins/org.eclipse.fordiac.ide.structuredtextcore.ui/src/org/eclipse/fordiac/ide/structuredtextcore/ui/syntaxcoloring/STCoreAntlrTokenToAttributeIdMapper.java @@ -1,5 +1,6 @@ /** - * Copyright (c) 2022 Primetals Technologies Austria GmbH + * Copyright (c) 2022, 2025 Primetals Technologies Austria GmbH + * Martin Erich Jobst * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -10,11 +11,16 @@ * Contributors: * Hesam Rezaee * - initial API and implementation and/or initial documentation + * Martin Jobst + * - fix data type keywords */ package org.eclipse.fordiac.ide.structuredtextcore.ui.syntaxcoloring; import java.util.Set; +import java.util.stream.Collectors; +import org.eclipse.fordiac.ide.model.data.DataType; +import org.eclipse.fordiac.ide.model.typelibrary.DataTypeLibrary; import org.eclipse.xtext.ide.editor.syntaxcoloring.HighlightingStyles; import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultAntlrTokenToAttributeIdMapper; @@ -23,10 +29,8 @@ public class STCoreAntlrTokenToAttributeIdMapper extends DefaultAntlrTokenToAttr private static final Set VAR_DECLARATION_KEYWORDS = Set.of("\'VAR\'", "\'VAR_TEMP\'", "\'VAR_INPUT\'", "\'VAR_OUTPUT\'", "\'VAR_IN_OUT\'", "\'END_VAR\'", "\'VAR_EXTERNAL\'", "\'VAR_GLOBAL\'", "\'VAR_ACCESS\'", "\'RETAIN\'", "\'CONSTANT\'", "\'AT\'"); - private static final Set DATA_TYPES_KEYWORDS = Set.of("\'CHAR\'", "\'WCHAR\'", "\'SINT\'", "\'INT\'", - "\'DINT\'", "\'LINT\'", "\'LINT\'", "\'USINT\'", "\'UINT\'", "\'LDINT\'", "\'ULINT\'", "\'REAL\'", - "\'LREAL\'", "\'TIME\'", "\'DATE\'", "\'TIME_OF_DAY\'", "\'DATE_AND_TIME\'", "\'STRING\'", "\'WSTRING\'", - "\'BOOL\'", "\'BYTE\'", "\'WORD\'", "\'DWORD\'", "\'LWORD\'", "\'ARRAY\'"); + private static final Set DATA_TYPES_KEYWORDS = DataTypeLibrary.getNonUserDefinedDataTypes().stream() + .map(DataType::getName).map(name -> "'" + name + "'").collect(Collectors.toUnmodifiableSet()); private static final Set FUNCTIONS_KEYWORDS = Set.of("\'FUNCTION\'", "\'END_FUNCTION\'"); private static final Set FUNCTION_BLOCK_KEYWORDS = Set.of("\'FUNCTION_BLOCK\'", "\'END_FUNCTION_BLOCK\'"); private static final Set METHOD_BLOCK_KEYWORDS = Set.of("\'METHOD\'", "\'END_METHOD\'");