mirror of
https://github.com/Minres/RDL-Editor.git
synced 2025-07-01 21:43:26 +02:00
Iniital checkin
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
package com.minres.rdl.ui
|
||||
|
||||
import org.eclipse.emf.ecore.EObject
|
||||
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
|
||||
|
||||
class RDLEObjectDocumentationProvider implements IEObjectDocumentationProvider {
|
||||
override String getDocumentation(EObject o) {
|
||||
// if (o instanceof Greeting) {
|
||||
// return "This is a nice Greeting with nice <b>markup</b> in the <i>documentation</i>";
|
||||
// }
|
||||
return null
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.minres.rdl.ui
|
||||
|
||||
import org.eclipse.emf.ecore.EObject
|
||||
import org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider
|
||||
import com.minres.rdl.rdl.ComponentDefinition
|
||||
import com.minres.rdl.rdl.ComponentInstance
|
||||
import com.minres.rdl.rdl.ImmediateInstantiation
|
||||
import com.minres.rdl.rdl.NamedInstantiation
|
||||
|
||||
class RDLEObjectHoverProvider extends DefaultEObjectHoverProvider {
|
||||
override protected String getFirstLine(EObject o) {
|
||||
switch(o){
|
||||
ComponentDefinition: return 'Component '+o.name+' of type '+o.type.literal
|
||||
ComponentInstance: {
|
||||
val parent = o.eContainer
|
||||
if (parent instanceof ImmediateInstantiation) {
|
||||
val compDef = parent.eContainer as ComponentDefinition
|
||||
return compDef.type.literal+' '+o.name
|
||||
} else if (parent instanceof NamedInstantiation) {
|
||||
return parent.component.type.literal+' '+o.name
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getFirstLine(o)
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.minres.rdl.ui
|
||||
|
||||
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
|
||||
import org.eclipse.xtext.ui.editor.hover.IEObjectHoverProvider
|
||||
import org.eclipse.xtext.documentation.IEObjectDocumentationProvider
|
||||
|
||||
/**
|
||||
* Use this class to register components to be used within the Eclipse IDE.
|
||||
*/
|
||||
@FinalFieldsConstructor
|
||||
class RDLUiModule extends AbstractRDLUiModule {
|
||||
|
||||
def Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
|
||||
typeof(RDLEObjectHoverProvider);
|
||||
}
|
||||
|
||||
def Class<? extends IEObjectDocumentationProvider> bindIEObjectDocumentationProviderr() {
|
||||
typeof(RDLEObjectDocumentationProvider);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.minres.rdl.ui.contentassist
|
||||
|
||||
|
||||
/**
|
||||
* See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#content-assist
|
||||
* on how to customize the content assistant.
|
||||
*/
|
||||
class RDLProposalProvider extends AbstractRDLProposalProvider {
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.minres.rdl.ui.labeling
|
||||
|
||||
import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider
|
||||
|
||||
/**
|
||||
* Provides labels for IEObjectDescriptions and IResourceDescriptions.
|
||||
*
|
||||
* See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#label-provider
|
||||
*/
|
||||
class RDLDescriptionLabelProvider extends DefaultDescriptionLabelProvider {
|
||||
|
||||
// Labels and icons can be computed like this:
|
||||
|
||||
// override text(IEObjectDescription ele) {
|
||||
// ele.name.toString
|
||||
// }
|
||||
//
|
||||
// override image(IEObjectDescription ele) {
|
||||
// ele.EClass.name + '.gif'
|
||||
// }
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.minres.rdl.ui.labeling
|
||||
|
||||
import com.google.inject.Inject
|
||||
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider
|
||||
import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider
|
||||
import com.minres.rdl.rdl.ComponentDefinition
|
||||
import com.minres.rdl.rdl.ExplicitPropertyAssignment
|
||||
import com.minres.rdl.rdl.ImmediateInstantiation
|
||||
import com.minres.rdl.rdl.ComponentInstance
|
||||
import com.minres.rdl.rdl.PropertyAssignment
|
||||
import com.minres.rdl.rdl.PropertyAssignmentRhs
|
||||
import com.minres.rdl.rdl.RValue
|
||||
import com.minres.rdl.IntegerWithRadix
|
||||
import com.minres.rdl.rdl.PropertyEnum
|
||||
import com.minres.rdl.rdl.RValueConstant
|
||||
import com.minres.rdl.rdl.PropertyModifier
|
||||
import com.minres.rdl.rdl.ComponentDefinitionType
|
||||
import com.minres.rdl.rdl.EnumDefinition
|
||||
import com.minres.rdl.rdl.NamedInstantiation
|
||||
import com.minres.rdl.rdl.PostPropertyAssignment
|
||||
import com.minres.rdl.rdl.InstanceRef
|
||||
import com.minres.rdl.rdl.InstancePropertyRef
|
||||
import com.minres.rdl.rdl.EnumEntry
|
||||
import com.minres.rdl.rdl.EnumProperty
|
||||
|
||||
/**
|
||||
* Provides labels for EObjects.
|
||||
*
|
||||
* See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#label-provider
|
||||
*/
|
||||
class RDLLabelProvider extends DefaultEObjectLabelProvider {
|
||||
|
||||
@Inject
|
||||
new(AdapterFactoryLabelProvider delegate) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
// Labels and icons can be computed like this:
|
||||
|
||||
// def text(Greeting ele) {
|
||||
// 'A greeting to ' + ele.name
|
||||
// }
|
||||
//
|
||||
// def image(Greeting ele) {
|
||||
// 'Greeting.gif'
|
||||
// }
|
||||
|
||||
def text(ComponentDefinition e){
|
||||
if(e.immediateInstantiation!==null){
|
||||
if(e.name!==null)
|
||||
text(e.immediateInstantiation)+' ('+e.name+')'
|
||||
else
|
||||
text(e.immediateInstantiation)
|
||||
}else if(e.name!==null){
|
||||
e.type.literal+' '+e.name
|
||||
} else{
|
||||
val pa = e.propertyAssignments.findFirst[PropertyAssignment pa |
|
||||
pa instanceof ExplicitPropertyAssignment && (pa as ExplicitPropertyAssignment).name==PropertyEnum.NAME
|
||||
]
|
||||
e.type.literal+' '+ text((pa as ExplicitPropertyAssignment).rhs)
|
||||
}
|
||||
}
|
||||
|
||||
def text(ExplicitPropertyAssignment e){
|
||||
var res = ""
|
||||
if(e.modifier!=PropertyModifier.UNDEFINED)
|
||||
res+=e.modifier.literal + ' '
|
||||
res+=e.name
|
||||
if(e.rhs!==null)
|
||||
res+=' = '+text(e.rhs)
|
||||
return res
|
||||
}
|
||||
|
||||
def text(PostPropertyAssignment e){
|
||||
var res = ""
|
||||
res+=text(e.instance)
|
||||
if(e.property !== null)
|
||||
res+='->'+e.property.name
|
||||
else if(e.propertyEnum != PropertyEnum.UNSPECIFIED)
|
||||
res+='->'+e.propertyEnum.literal
|
||||
return res
|
||||
}
|
||||
|
||||
def String text(InstanceRef e){
|
||||
if(e.tail!==null)
|
||||
e.instance.name+'.'+text(e.tail)
|
||||
else
|
||||
e.instance.name
|
||||
}
|
||||
|
||||
def text( ImmediateInstantiation e){
|
||||
e.componentInstances.map[text(it)].join(", ")
|
||||
}
|
||||
|
||||
def text( ComponentInstance e){
|
||||
var res = e.name
|
||||
if(e.range !== null)
|
||||
res+='['+(if(e.range.size!==null) e.range.size.toString else e.range.start+':'+e.range.end)+']'
|
||||
if(e.address!==null)
|
||||
res+=' @'+e.address
|
||||
return res
|
||||
}
|
||||
|
||||
def text( PropertyAssignmentRhs e){
|
||||
if(e.value!== null)
|
||||
text(e.value)
|
||||
else if(e.instPropRef!==null)
|
||||
text(e.instPropRef)
|
||||
else if(e.enumRef!==null)
|
||||
text(e.enumRef)
|
||||
}
|
||||
|
||||
def text(InstancePropertyRef ref){
|
||||
text(ref.instance) +
|
||||
if(ref.property!==null) '->' + ref.property.name
|
||||
else if(ref.propertyEnum != PropertyEnum.UNSPECIFIED) '->' +ref.propertyEnum.literal else ''
|
||||
}
|
||||
|
||||
def text( RValue e){
|
||||
if(e.str!==null){
|
||||
elipse(e.str)
|
||||
} else if(e.^val!=RValueConstant.UNDEFINED)
|
||||
return e.^val.literal
|
||||
else if(e.num!==null){
|
||||
val num = e.num as IntegerWithRadix
|
||||
return num.toString
|
||||
}
|
||||
}
|
||||
|
||||
def elipse(String string) {
|
||||
val pos = string.indexOf('\n')
|
||||
if(pos>0)
|
||||
return string.substring(0, pos-1)+'...'
|
||||
else if(string.length>30)
|
||||
return string.substring(0, 30)+'...'
|
||||
else
|
||||
return string
|
||||
}
|
||||
|
||||
def text(NamedInstantiation e){
|
||||
e.componentInstances.map[text(it)].join(", ")+' ('+e.component.name+')'
|
||||
}
|
||||
|
||||
def text(EnumEntry e){
|
||||
if(e.index !== null)
|
||||
e.name + '=' + e.index.toString
|
||||
else
|
||||
e.name+'='+e.properties.map[
|
||||
text(it)
|
||||
].join(',')
|
||||
}
|
||||
|
||||
def text(EnumProperty e){
|
||||
e.name+'='+elipse(e.value)
|
||||
}
|
||||
|
||||
def image(ComponentDefinition e){
|
||||
switch(e.type){
|
||||
case ComponentDefinitionType.ADDRMAP: return 'A.png'
|
||||
case ComponentDefinitionType.FIELD: return 'F.png'
|
||||
case ComponentDefinitionType.REG: return 'R.png'
|
||||
case ComponentDefinitionType.REGFILE: return 'R.png'
|
||||
case ComponentDefinitionType.SIGNAL: return 'S.png'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def image(PropertyAssignmentRhs e){
|
||||
if(e.value!== null)
|
||||
'V.png'
|
||||
else if(e.instPropRef!==null)
|
||||
image(e.instPropRef)
|
||||
else if(e.enumRef!==null)
|
||||
'E.png'
|
||||
}
|
||||
|
||||
def image(InstancePropertyRef ref){
|
||||
if(ref.property!==null)
|
||||
'P.png'
|
||||
else if(ref.propertyEnum != PropertyEnum.UNSPECIFIED)
|
||||
'E.png'
|
||||
else
|
||||
'I.png'
|
||||
}
|
||||
|
||||
def image(EnumDefinition e){
|
||||
'E.png'
|
||||
}
|
||||
|
||||
def image(ExplicitPropertyAssignment e){
|
||||
'P.png'
|
||||
}
|
||||
|
||||
def image(PostPropertyAssignment e){
|
||||
'P.png'
|
||||
}
|
||||
|
||||
def image(NamedInstantiation e){
|
||||
'I.png'
|
||||
}
|
||||
|
||||
def image(EnumEntry v){
|
||||
'V.png'
|
||||
}
|
||||
|
||||
def image(EnumProperty e){
|
||||
'P.png'
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.minres.rdl.ui.outline
|
||||
|
||||
import com.minres.rdl.rdl.Root
|
||||
import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider
|
||||
import org.eclipse.xtext.ui.editor.outline.impl.DocumentRootNode
|
||||
import com.minres.rdl.rdl.ComponentDefinition
|
||||
import org.eclipse.xtext.ui.editor.outline.IOutlineNode
|
||||
import com.minres.rdl.rdl.PropertyAssignment
|
||||
import com.minres.rdl.rdl.NamedInstantiation
|
||||
import com.minres.rdl.rdl.ExplicitPropertyAssignment
|
||||
import com.minres.rdl.rdl.PostPropertyAssignment
|
||||
import com.minres.rdl.rdl.PropertyAssignmentRhs
|
||||
import com.minres.rdl.rdl.EnumDefinition
|
||||
import com.minres.rdl.rdl.EnumEntry
|
||||
|
||||
/**
|
||||
* Customization of the default outline structure.
|
||||
*
|
||||
* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#outline
|
||||
*/
|
||||
class RDLOutlineTreeProvider extends DefaultOutlineTreeProvider {
|
||||
|
||||
protected def _createChildren(DocumentRootNode parentNode, Root domainModel) {
|
||||
domainModel.enumDefinitions.forEach[createNode(parentNode, it)]
|
||||
domainModel.propertyDefinitions.forEach[createNode(parentNode, it)]
|
||||
domainModel.componentDefinitions.forEach[createNode(parentNode, it)]
|
||||
domainModel.propertyAssignments.forEach[createNode(parentNode, it)]
|
||||
domainModel.namedInstantiations.forEach[createNode(parentNode, it)]
|
||||
}
|
||||
|
||||
protected def _createChildren(IOutlineNode parentNode, ComponentDefinition compDef) {
|
||||
compDef.enumDefinitions.forEach[createNode(parentNode, it)]
|
||||
compDef.componentDefinitions.forEach[createNode(parentNode, it)]
|
||||
compDef.propertyAssignments.forEach[createNode(parentNode, it)]
|
||||
compDef.namedInstantiations.forEach[createNode(parentNode, it)]
|
||||
}
|
||||
|
||||
protected def _createChildren(IOutlineNode parentNode, EnumDefinition e) {
|
||||
e.body.entries.forEach[createNode(parentNode, it)]
|
||||
}
|
||||
|
||||
protected def _createChildren(IOutlineNode parentNode, PostPropertyAssignment p) {
|
||||
createNode(parentNode, p.rhs)
|
||||
}
|
||||
|
||||
protected def boolean _isLeaf(ExplicitPropertyAssignment feature) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected def boolean _isLeaf(NamedInstantiation feature) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected def boolean _isLeaf(PropertyAssignmentRhs feature) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected def boolean _isLeaf(EnumEntry feature) {
|
||||
return feature.properties.size==0;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* generated by Xtext 2.12.0
|
||||
*/
|
||||
package com.minres.rdl.ui.quickfix
|
||||
|
||||
import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider
|
||||
|
||||
/**
|
||||
* Custom quickfixes.
|
||||
*
|
||||
* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes
|
||||
*/
|
||||
class RDLQuickfixProvider extends DefaultQuickfixProvider {
|
||||
|
||||
// @Fix(RDLValidator.INVALID_NAME)
|
||||
// def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
|
||||
// acceptor.accept(issue, 'Capitalize name', 'Capitalize the name.', 'upcase.png') [
|
||||
// context |
|
||||
// val xtextDocument = context.xtextDocument
|
||||
// val firstLetter = xtextDocument.get(issue.offset, 1)
|
||||
// xtextDocument.replace(issue.offset, 1, firstLetter.toUpperCase)
|
||||
// ]
|
||||
// }
|
||||
}
|
Reference in New Issue
Block a user