Skip to content

Commit

Permalink
Fixes eclipse-vorto#956 - Allow FB section names as property names.
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Pizonka <[email protected]>
  • Loading branch information
Ebolon committed Jun 14, 2018
1 parent 6236635 commit 41a0a55
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ Bundle-SymbolicName: org.eclipse.vorto.editor.datatype.ide;singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.vorto.editor.datatype,
org.eclipse.xtext.ide,
org.eclipse.xtext.xbase.ide
org.eclipse.xtext.xbase.ide,
org.eclipse.vorto.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.vorto.editor.datatype.ide.contentassist.an
tlr,org.eclipse.vorto.editor.datatype.ide.contentassist.antlr.internal
Export-Package: org.eclipse.vorto.editor.datatype.ide.contentassist.antlr,
org.eclipse.vorto.editor.datatype.ide.contentassist.antlr.internal,
org.eclipse.vorto.editor.datatype.ide.syntaxcoloring
Import-Package: org.eclipse.vorto.editor.datatype.services
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2018 Bosch Software Innovations GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* The Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Bosch Software Innovations GmbH - Please refer to git log
*/
package org.eclipse.vorto.editor.datatype.ide.syntaxcoloring

import javax.inject.Inject
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.ide.editor.syntaxcoloring.DefaultSemanticHighlightingCalculator
import org.eclipse.xtext.ide.editor.syntaxcoloring.IHighlightedPositionAcceptor
import org.eclipse.xtext.util.CancelIndicator

import org.eclipse.vorto.core.api.model.datatype.Property
import org.eclipse.vorto.core.api.model.datatype.DatatypePackage
import org.eclipse.vorto.editor.datatype.services.DatatypeGrammarAccess
import org.eclipse.xtext.ide.editor.syntaxcoloring.HighlightingStyles

class PropertyNameSemanticHighlightingCalculator extends DefaultSemanticHighlightingCalculator {
@Inject package DatatypeGrammarAccess grammar

override protected boolean highlightElement(EObject object, IHighlightedPositionAcceptor acceptor,
CancelIndicator cancelIndicator) {
switch (object) {
Property: {
highlightFeature(acceptor, object, DatatypePackage.eINSTANCE.property_Name, HighlightingStyles.DEFAULT_ID)
return true
}
default: false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others.
* Copyright (c) 2015-2018 Bosch Software Innovations GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
Expand All @@ -17,6 +17,8 @@ package
org.eclipse.vorto.editor.datatype.ui

import org.eclipse.ui.plugin.AbstractUIPlugin
import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator
import org.eclipse.vorto.editor.datatype.ide.syntaxcoloring.PropertyNameSemanticHighlightingCalculator

/**
* Use this class to register components to be used within the IDE.
Expand All @@ -25,4 +27,7 @@ class DatatypeUiModule extends org.eclipse.vorto.editor.datatype.ui.AbstractData
new(AbstractUIPlugin plugin) {
super(plugin)
}
def Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator () {
PropertyNameSemanticHighlightingCalculator
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014 Bosch Software Innovations GmbH and others.
* Copyright (c) 2014-2018 Bosch Software Innovations GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
Expand Down Expand Up @@ -63,7 +63,7 @@ EnumLiteral:
;

Property:
(extension ?= 'extension')? (presence = Presence)? (multiplicity ?= 'multiple')? name = ID 'as' type = PropertyType
(extension ?= 'extension')? (presence = Presence)? (multiplicity ?= 'multiple')? name = ValidID 'as' type = PropertyType
('with' '{' propertyAttributes+=PropertyAttribute (',' propertyAttributes+=PropertyAttribute)* '}')?
('<' constraintRule = ConstraintRule '>')?
(description=STRING)?
Expand Down Expand Up @@ -141,6 +141,10 @@ BOOLEAN:

CATEGORY: ID ('/' ID)*;

ValidID: ID | KEYWORD;

KEYWORD: 'status'|'events'|'operations'|'configuration'|'fault';

terminal SIGNEDINT :
'-'INT
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.xtext.ui,
org.eclipse.vorto.editor.functionblock.ide,
org.eclipse.vorto.core,
org.eclipse.xtext.xbase.lib,
org.eclipse.xtend.lib;resolution:=optional
org.eclipse.xtend.lib;resolution:=optional,
org.eclipse.vorto.editor.datatype.ide
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.vorto.editor.functionblock.ui,org.eclipse.
vorto.editor.functionblock.ui.contentassist,org.eclipse.vorto.editor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package
org.eclipse.vorto.editor.functionblock.ui

import org.eclipse.ui.plugin.AbstractUIPlugin
import org.eclipse.xtext.ide.editor.syntaxcoloring.ISemanticHighlightingCalculator
import org.eclipse.vorto.editor.datatype.ide.syntaxcoloring.PropertyNameSemanticHighlightingCalculator

/**
* Use this class to register components to be used within the IDE.
Expand All @@ -25,4 +27,7 @@ class FunctionblockUiModule extends org.eclipse.vorto.editor.functionblock.ui.Ab
new(AbstractUIPlugin plugin) {
super(plugin)
}
def Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator () {
PropertyNameSemanticHighlightingCalculator
}
}

0 comments on commit 41a0a55

Please sign in to comment.