Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: aa48c6bf38c41562b49c5bed9c96fbd91e8f402c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.eclipse.papyrus.qompass.designer.cpp.xtend;

import com.google.common.base.Objects;
import org.eclipse.papyrus.C_Cpp.Ptr;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
import org.eclipse.uml2.uml.AggregationKind;
import org.eclipse.uml2.uml.Property;

@SuppressWarnings("all")
public class CppUtils {
  public static String nameRef(final Property part) {
    String _name = part.getName();
    String _refOp = CppUtils.refOp(part);
    return (_name + _refOp);
  }
  
  /**
   * return the operator for (de-) referencing a part. If the part is
   * instantiate via the bootloader, it becomes a pointer. If it is
   * instantiated by the composite itself, it is not a pointer, it will be
   * instantiated along with the composite
   * 
   * @param part
   * @return
   */
  public static String refOp(final Property part) {
    String _xifexpression = null;
    boolean _or = false;
    AggregationKind _aggregation = part.getAggregation();
    boolean _equals = Objects.equal(_aggregation, AggregationKind.SHARED_LITERAL);
    if (_equals) {
      _or = true;
    } else {
      boolean _isApplied = StereotypeUtil.isApplied(part, Ptr.class);
      _or = _isApplied;
    }
    if (_or) {
      _xifexpression = "->";
    } else {
      _xifexpression = ".";
    }
    return _xifexpression;
  }
}

Back to the top