public IFunctionBinding getDeclaringMethod() {
   ASTNode parent = this.variableDeclaration.getParent();
   while (parent != null && parent.getNodeType() != ASTNode.FUNCTION_DECLARATION) {
     parent = parent.getParent();
   }
   if (parent != null) {
     return ((FunctionDeclaration) parent).resolveBinding();
   }
   return null;
 }
 public ITypeBinding getDeclaringClass() {
   ASTNode parent = this.variableDeclaration.getParent();
   while (parent != null && parent.getNodeType() != ASTNode.TYPE_DECLARATION) {
     parent = parent.getParent();
   }
   if (parent != null) {
     return ((TypeDeclaration) parent).resolveBinding();
   }
   return null;
 }
示例#3
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#refreshInlineTagPosition(int)
  */
 protected void refreshInlineTagPosition(int previousPosition) {
   if (this.astPtr != -1) {
     TagElement previousTag = (TagElement) this.astStack[this.astPtr];
     if (this.inlineTagStarted) {
       int previousStart = previousTag.getStartPosition();
       previousTag.setSourceRange(previousStart, previousPosition - previousStart + 1);
       if (previousTag.fragments().size() > 0) {
         ASTNode inlineTag =
             (ASTNode) previousTag.fragments().get(previousTag.fragments().size() - 1);
         if (inlineTag.getNodeType() == ASTNode.TAG_ELEMENT) {
           int inlineStart = inlineTag.getStartPosition();
           inlineTag.setSourceRange(inlineStart, previousPosition - inlineStart + 1);
         }
       }
     }
   }
 }
示例#4
0
  /* (non-Javadoc)
   * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#pushText(int, int)
   */
  protected void pushText(int start, int end) {

    // Create text element
    TextElement text = this.ast.newTextElement();
    text.setText(new String(this.source, start, end - start));
    text.setSourceRange(start, end - start);

    // Search previous tag on which to add the text element
    TagElement previousTag = null;
    int previousStart = start;
    if (this.astPtr == -1) {
      previousTag = this.ast.newTagElement();
      previousTag.setSourceRange(start, end - start);
      pushOnAstStack(previousTag, true);
    } else {
      previousTag = (TagElement) this.astStack[this.astPtr];
      previousStart = previousTag.getStartPosition();
    }

    // If we're in a inline tag, then retrieve previous tag in its fragments
    List fragments = previousTag.fragments();
    if (this.inlineTagStarted) {
      int size = fragments.size();
      if (size == 0) {
        // no existing fragment => just add the element
        TagElement inlineTag = this.ast.newTagElement();
        fragments.add(inlineTag);
        previousTag = inlineTag;
      } else {
        // If last fragment is a tag, then use it as previous tag
        ASTNode lastFragment = (ASTNode) fragments.get(size - 1);
        if (lastFragment.getNodeType() == ASTNode.TAG_ELEMENT) {
          previousTag = (TagElement) lastFragment;
          previousStart = previousTag.getStartPosition();
        }
      }
    }

    // Add the text
    previousTag.fragments().add(text);
    previousTag.setSourceRange(previousStart, end - previousStart);
    this.textStart = -1;
  }
示例#5
0
 /* (non-Javadoc)
  * @see org.eclipse.jdt.internal.compiler.parser.AbstractCommentParser#createArgumentReference(char[], java.lang.Object, int)
  */
 protected Object createArgumentReference(
     char[] name, int dim, boolean isVarargs, Object typeRef, long[] dimPositions, long argNamePos)
     throws InvalidInputException {
   try {
     MethodRefParameter argument = this.ast.newMethodRefParameter();
     ASTNode node = (ASTNode) typeRef;
     int argStart = node.getStartPosition();
     int argEnd = node.getStartPosition() + node.getLength() - 1;
     if (dim > 0) argEnd = (int) dimPositions[dim - 1];
     if (argNamePos >= 0) argEnd = (int) argNamePos;
     if (name.length != 0) {
       final SimpleName argName = new SimpleName(this.ast);
       argName.internalSetIdentifier(new String(name));
       argument.setName(argName);
       int argNameStart = (int) (argNamePos >>> 32);
       argName.setSourceRange(argNameStart, argEnd - argNameStart + 1);
     }
     Type argType = null;
     if (node.getNodeType() == ASTNode.PRIMITIVE_TYPE) {
       argType = (PrimitiveType) node;
       //				if (dim > 0) {
       //					argType = this.ast.newArrayType(argType, dim);
       //					argType.setSourceRange(argStart, ((int) dimPositions[dim-1])-argStart+1);
       //				}
     } else {
       Name argTypeName = (Name) node;
       argType = this.ast.newSimpleType(argTypeName);
       argType.setSourceRange(argStart, node.getLength());
     }
     if (dim > 0 && !isVarargs) {
       for (int i = 0; i < dim; i++) {
         argType = this.ast.newArrayType(argType);
         argType.setSourceRange(argStart, ((int) dimPositions[i]) - argStart + 1);
       }
     }
     argument.setType(argType);
     argument.setSourceRange(argStart, argEnd - argStart + 1);
     return argument;
   } catch (ClassCastException ex) {
     throw new InvalidInputException();
   }
 }