RDL-Editor/com.minres.rdl.parent/com.minres.rdl.ui/xtend-gen/com/minres/rdl/ui/labeling/RDLLabelProvider.java

382 lines
12 KiB
Java

/**
* generated by Xtext 2.14.0
*/
package com.minres.rdl.ui.labeling;
import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.minres.rdl.IntegerWithRadix;
import com.minres.rdl.rdl.ComponentDefinition;
import com.minres.rdl.rdl.ComponentDefinitionType;
import com.minres.rdl.rdl.ComponentInstance;
import com.minres.rdl.rdl.EnumDefinition;
import com.minres.rdl.rdl.EnumEntry;
import com.minres.rdl.rdl.EnumProperty;
import com.minres.rdl.rdl.ExplicitPropertyAssignment;
import com.minres.rdl.rdl.InstancePropertyRef;
import com.minres.rdl.rdl.InstanceRef;
import com.minres.rdl.rdl.PostPropertyAssignment;
import com.minres.rdl.rdl.PropertyAssignment;
import com.minres.rdl.rdl.PropertyAssignmentRhs;
import com.minres.rdl.rdl.PropertyDefinition;
import com.minres.rdl.rdl.PropertyEnum;
import com.minres.rdl.rdl.PropertyModifier;
import com.minres.rdl.rdl.RValue;
import com.minres.rdl.rdl.RValueConstant;
import com.minres.rdl.rdl.Range;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ListExtensions;
/**
* Provides labels for EObjects.
*
* See https://www.eclipse.org/Xtext/documentation/304_ide_concepts.html#label-provider
*/
@SuppressWarnings("all")
public class RDLLabelProvider extends DefaultEObjectLabelProvider {
@Inject
public RDLLabelProvider(final AdapterFactoryLabelProvider delegate) {
super(delegate);
}
public String text(final ComponentDefinition e) {
String _xifexpression = null;
String _name = e.getName();
boolean _tripleNotEquals = (_name != null);
if (_tripleNotEquals) {
String _literal = e.getType().getLiteral();
String _plus = (_literal + " ");
String _name_1 = e.getName();
_xifexpression = (_plus + _name_1);
} else {
String _xblockexpression = null;
{
final Function1<PropertyAssignment, Boolean> _function = (PropertyAssignment pa) -> {
return Boolean.valueOf(((pa instanceof ExplicitPropertyAssignment) && Objects.equal(((ExplicitPropertyAssignment) pa).getName(), PropertyEnum.NAME)));
};
final PropertyAssignment pa = IterableExtensions.<PropertyAssignment>findFirst(e.getPropertyAssignments(), _function);
String _xifexpression_1 = null;
if ((pa != null)) {
String _literal_1 = e.getType().getLiteral();
String _plus_1 = (_literal_1 + " ");
Object _text = this.text(((ExplicitPropertyAssignment) pa).getRhs());
_xifexpression_1 = (_plus_1 + _text);
} else {
_xifexpression_1 = e.getType().getLiteral();
}
_xblockexpression = _xifexpression_1;
}
_xifexpression = _xblockexpression;
}
return _xifexpression;
}
public String text(final ExplicitPropertyAssignment e) {
String res = "";
PropertyModifier _modifier = e.getModifier();
boolean _notEquals = (!Objects.equal(_modifier, PropertyModifier.UNDEFINED));
if (_notEquals) {
String _res = res;
String _literal = e.getModifier().getLiteral();
String _plus = (_literal + " ");
res = (_res + _plus);
}
String _res_1 = res;
PropertyEnum _name = e.getName();
res = (_res_1 + _name);
PropertyAssignmentRhs _rhs = e.getRhs();
boolean _tripleNotEquals = (_rhs != null);
if (_tripleNotEquals) {
String _res_2 = res;
Object _text = this.text(e.getRhs());
String _plus_1 = (" = " + _text);
res = (_res_2 + _plus_1);
}
return res;
}
public String text(final PostPropertyAssignment e) {
String res = "";
String _res = res;
String _text = this.text(e.getInstance());
res = (_res + _text);
PropertyDefinition _property = e.getProperty();
boolean _tripleNotEquals = (_property != null);
if (_tripleNotEquals) {
String _res_1 = res;
String _name = e.getProperty().getName();
String _plus = ("->" + _name);
res = (_res_1 + _plus);
} else {
PropertyEnum _propertyEnum = e.getPropertyEnum();
boolean _notEquals = (!Objects.equal(_propertyEnum, PropertyEnum.UNSPECIFIED));
if (_notEquals) {
String _res_2 = res;
String _literal = e.getPropertyEnum().getLiteral();
String _plus_1 = ("->" + _literal);
res = (_res_2 + _plus_1);
}
}
return res;
}
public String text(final InstanceRef e) {
String _xifexpression = null;
InstanceRef _tail = e.getTail();
boolean _tripleNotEquals = (_tail != null);
if (_tripleNotEquals) {
String _name = e.getInstance().getName();
String _plus = (_name + ".");
String _text = this.text(e.getTail());
_xifexpression = (_plus + _text);
} else {
_xifexpression = e.getInstance().getName();
}
return _xifexpression;
}
public String text(final ComponentInstance e) {
String res = e.getName();
Range _range = e.getRange();
boolean _tripleNotEquals = (_range != null);
if (_tripleNotEquals) {
String _res = res;
String _xifexpression = null;
Object _size = e.getRange().getSize();
boolean _tripleNotEquals_1 = (_size != null);
if (_tripleNotEquals_1) {
_xifexpression = e.getRange().getSize().toString();
} else {
Object _left = e.getRange().getLeft();
String _plus = (_left + ":");
Object _right = e.getRange().getRight();
_xifexpression = (_plus + _right);
}
String _plus_1 = ("[" + _xifexpression);
String _plus_2 = (_plus_1 + "]");
res = (_res + _plus_2);
}
Object _address = e.getAddress();
boolean _tripleNotEquals_2 = (_address != null);
if (_tripleNotEquals_2) {
String _res_1 = res;
Object _address_1 = e.getAddress();
String _plus_3 = (" @" + _address_1);
res = (_res_1 + _plus_3);
}
return res;
}
public Object text(final PropertyAssignmentRhs e) {
Object _xifexpression = null;
RValue _value = e.getValue();
boolean _tripleNotEquals = (_value != null);
if (_tripleNotEquals) {
_xifexpression = this.text(e.getValue());
} else {
Object _xifexpression_1 = null;
InstancePropertyRef _instPropRef = e.getInstPropRef();
boolean _tripleNotEquals_1 = (_instPropRef != null);
if (_tripleNotEquals_1) {
_xifexpression_1 = this.text(e.getInstPropRef());
} else {
Object _xifexpression_2 = null;
EnumDefinition _enumRef = e.getEnumRef();
boolean _tripleNotEquals_2 = (_enumRef != null);
if (_tripleNotEquals_2) {
_xifexpression_2 = this.text(e.getEnumRef());
}
_xifexpression_1 = _xifexpression_2;
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
public String text(final InstancePropertyRef ref) {
String _text = this.text(ref.getInstance());
String _xifexpression = null;
PropertyDefinition _property = ref.getProperty();
boolean _tripleNotEquals = (_property != null);
if (_tripleNotEquals) {
String _name = ref.getProperty().getName();
_xifexpression = ("->" + _name);
} else {
String _xifexpression_1 = null;
PropertyEnum _propertyEnum = ref.getPropertyEnum();
boolean _notEquals = (!Objects.equal(_propertyEnum, PropertyEnum.UNSPECIFIED));
if (_notEquals) {
String _literal = ref.getPropertyEnum().getLiteral();
_xifexpression_1 = ("->" + _literal);
} else {
_xifexpression_1 = "";
}
_xifexpression = _xifexpression_1;
}
return (_text + _xifexpression);
}
public String text(final RValue e) {
String _xifexpression = null;
String _str = e.getStr();
boolean _tripleNotEquals = (_str != null);
if (_tripleNotEquals) {
_xifexpression = this.elipse(e.getStr());
} else {
RValueConstant _val = e.getVal();
boolean _notEquals = (!Objects.equal(_val, RValueConstant.UNDEFINED));
if (_notEquals) {
return e.getVal().getLiteral();
} else {
Object _num = e.getNum();
boolean _tripleNotEquals_1 = (_num != null);
if (_tripleNotEquals_1) {
Object _num_1 = e.getNum();
final IntegerWithRadix num = ((IntegerWithRadix) _num_1);
return num.toString();
}
}
}
return _xifexpression;
}
public String elipse(final String string) {
final int pos = string.indexOf("\n");
if ((pos > 0)) {
String _substring = string.substring(0, (pos - 1));
return (_substring + "...");
} else {
int _length = string.length();
boolean _greaterThan = (_length > 30);
if (_greaterThan) {
String _substring_1 = string.substring(0, 30);
return (_substring_1 + "...");
} else {
return string;
}
}
}
public String text(final EnumEntry e) {
String _xifexpression = null;
Object _index = e.getIndex();
boolean _tripleNotEquals = (_index != null);
if (_tripleNotEquals) {
String _name = e.getName();
String _plus = (_name + "=");
String _string = e.getIndex().toString();
_xifexpression = (_plus + _string);
} else {
String _name_1 = e.getName();
String _plus_1 = (_name_1 + "=");
final Function1<EnumProperty, String> _function = (EnumProperty it) -> {
return this.text(it);
};
String _join = IterableExtensions.join(ListExtensions.<EnumProperty, String>map(e.getProperties(), _function), ",");
_xifexpression = (_plus_1 + _join);
}
return _xifexpression;
}
public String text(final EnumProperty e) {
String _name = e.getName();
String _plus = (_name + "=");
String _elipse = this.elipse(e.getValue());
return (_plus + _elipse);
}
public String image(final ComponentDefinition e) {
ComponentDefinitionType _type = e.getType();
if (_type != null) {
switch (_type) {
case ADDRMAP:
return "A.png";
case FIELD:
return "F.png";
case REG:
return "R.png";
case REGFILE:
return "R.png";
case SIGNAL:
return "S.png";
default:
break;
}
}
return null;
}
public String image(final PropertyAssignmentRhs e) {
String _xifexpression = null;
RValue _value = e.getValue();
boolean _tripleNotEquals = (_value != null);
if (_tripleNotEquals) {
_xifexpression = "V.png";
} else {
String _xifexpression_1 = null;
InstancePropertyRef _instPropRef = e.getInstPropRef();
boolean _tripleNotEquals_1 = (_instPropRef != null);
if (_tripleNotEquals_1) {
_xifexpression_1 = this.image(e.getInstPropRef());
} else {
String _xifexpression_2 = null;
EnumDefinition _enumRef = e.getEnumRef();
boolean _tripleNotEquals_2 = (_enumRef != null);
if (_tripleNotEquals_2) {
_xifexpression_2 = "E.png";
}
_xifexpression_1 = _xifexpression_2;
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
public String image(final InstancePropertyRef ref) {
String _xifexpression = null;
PropertyDefinition _property = ref.getProperty();
boolean _tripleNotEquals = (_property != null);
if (_tripleNotEquals) {
_xifexpression = "P.png";
} else {
String _xifexpression_1 = null;
PropertyEnum _propertyEnum = ref.getPropertyEnum();
boolean _notEquals = (!Objects.equal(_propertyEnum, PropertyEnum.UNSPECIFIED));
if (_notEquals) {
_xifexpression_1 = "E.png";
} else {
_xifexpression_1 = "I.png";
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
public String image(final EnumDefinition e) {
return "E.png";
}
public String image(final ExplicitPropertyAssignment e) {
return "P.png";
}
public String image(final PostPropertyAssignment e) {
return "P.png";
}
public String image(final ComponentInstance e) {
return "I.png";
}
public String image(final EnumEntry v) {
return "V.png";
}
public String image(final EnumProperty e) {
return "P.png";
}
}