@Override
 public Object getParent(Object element) {
   if (element instanceof CommonOutlineItem) {
     IParseNode node = ((CommonOutlineItem) element).getReferenceNode();
     IParseNode parent = node.getParent();
     if (parent instanceof ParseRootNode) {
       // we're at the root of the nested language, which is not displayed; go one level up
       parent = parent.getParent();
     }
     return getOutlineItem(parent);
   }
   return super.getParent(element);
 }
예제 #2
0
 /**
  * @param document
  * @param hasBlockedChild
  * @param node
  */
 public FormatterJSIfNode(
     IFormatterDocument document,
     boolean hasBlockedChild,
     IParseNode node,
     boolean hasCommentBefore) {
   super(document, hasBlockedChild, node, hasCommentBefore);
   // Check if this node is located in the 'false' block of a parent 'if'. In that case, we can say
   // for sure that
   // this 'if' arrives right after an 'else'.
   if (node.getParent().getNodeType() == JSNodeTypes.IF) {
     JSIfNode parentIfNode = (JSIfNode) node.getParent();
     inElseIf = parentIfNode.getFalseBlock() == node;
   }
 }
예제 #3
0
  /**
   * addParameterTypes
   *
   * @param identifierNode
   */
  private void addParameterTypes(JSIdentifierNode identifierNode) {
    IParseNode parent = identifierNode.getParent();
    IParseNode grandparent = (parent != null) ? parent.getParent() : null;
    boolean foundType = false;

    if (grandparent != null && grandparent.getNodeType() == IJSNodeTypes.FUNCTION) {
      DocumentationBlock docs = ((JSNode) grandparent).getDocumentation();

      if (docs != null) {
        String name = identifierNode.getText();
        int index = identifierNode.getIndex();
        List<Tag> params = docs.getTags(TagType.PARAM);

        if (params != null && index < params.size()) {
          ParamTag param = (ParamTag) params.get(index);

          if (name.equals(param.getName())) {
            for (Type parameterType : param.getTypes()) {
              String type = parameterType.getName();

              // Fix up type names as might be necessary
              type = JSTypeMapper.getInstance().getMappedType(type);

              this.addType(type);
              foundType = true;
            }
          }
        }
      }
    }

    // Use "Object" as parameter type if we didn't find types by other
    // means
    if (!foundType) {
      this.addType(JSTypeConstants.DEFAULT_PARAMETER_TYPE);
    }
  }