org.eclipse.jdt.core.dom.Annotation.getLength()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.eclipse.jdt.core.dom.Annotation.getLength()方法的一些代码示例,展示了Annotation.getLength()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getLength()方法的具体详情如下:
包路径:org.eclipse.jdt.core.dom.Annotation
类名称:Annotation
方法名:getLength

Annotation.getLength介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e

/**
 * Gets the sibling where the given {@link Annotation} should be added to the given {@link BodyDeclaration}. The
 * {@link Annotation} must be added before the returned node.
 *
 * @param owner
 *          The owner of the {@link Annotation}.
 * @param newAnnotation
 *          The new {@link Annotation} that should be added.
 * @return The
 */
public static ASTNode getAnnotationSibling(BodyDeclaration owner, Annotation newAnnotation) {
 Deque<Annotation> annotations = getAnnotations(owner);
 if (!annotations.isEmpty()) {
  int newAnnotLen = newAnnotation.toString().length();
  Iterator<Annotation> iterator = annotations.descendingIterator();
  while (iterator.hasNext()) {
   Annotation existingAnnotation = iterator.next();
   int len = existingAnnotation.getLength();
   if (len > 0 && len >= newAnnotLen) {
    return existingAnnotation;
   }
  }
 }
 for (Object o : owner.modifiers()) {
  if (o instanceof Modifier) {
   return (Modifier) o;
  }
 }
 return null;
}

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

private void rewriteAnnotationsOnDimension(ArrayType oldArrayType, ArrayType replacingType, int index, int pos, boolean typeReplaced, TextEditGroup editGroup) throws CoreException {
  if (typeReplaced) {
    List dimensions = oldArrayType.dimensions();
    Dimension oldDim = index < dimensions.size() ? (Dimension) dimensions.get(index) : null;
    if (oldDim != null) {
      List oldAnnotations = oldDim.annotations();
      int size = oldAnnotations.size();
      if (size > 0) {
        ASTNode prev = getPreviousNode(oldDim);
        Annotation annotation = (Annotation) oldAnnotations.get(0);
        int start = prev != null ? prev.getStartPosition() + prev.getLength() : annotation.getStartPosition();
        annotation = (Annotation) oldAnnotations.get(size - 1);
        int end = annotation.getStartPosition() + annotation.getLength();
        end = getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, end) - 1;
        doTextRemove(start, end - start, editGroup);
      }
    }
    insertAnnotationsOnDimension(replacingType, index, pos, editGroup, true);
  } else {
    Dimension dim = (Dimension) replacingType.dimensions().get(index);
    rewriteNodeList(dim, Dimension.ANNOTATIONS_PROPERTY, pos, String.valueOf(' '), String.valueOf(' '), String.valueOf(' '));
  }
}

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

private void rewriteAnnotationsOnDimension(ArrayType oldArrayType, ArrayType replacingType, int index, int pos, boolean typeReplaced, TextEditGroup editGroup) throws CoreException {
  if (typeReplaced) {
    List dimensions = oldArrayType.dimensions();
    Dimension oldDim = index < dimensions.size() ? (Dimension) dimensions.get(index) : null;
    if (oldDim != null) {
      List oldAnnotations = oldDim.annotations();
      int size = oldAnnotations.size();
      if (size > 0) {
        ASTNode prev = getPreviousNode(oldDim);
        Annotation annotation = (Annotation) oldAnnotations.get(0);
        int start = prev != null ? prev.getStartPosition() + prev.getLength() : annotation.getStartPosition();
        annotation = (Annotation) oldAnnotations.get(size - 1);
        int end = annotation.getStartPosition() + annotation.getLength();
        end = getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, end) - 1;
        doTextRemove(start, end - start, editGroup);
      }
    }
    insertAnnotationsOnDimension(replacingType, index, pos, editGroup, true);
  } else {
    Dimension dim = (Dimension) replacingType.dimensions().get(index);
    rewriteNodeList(dim, Dimension.ANNOTATIONS_PROPERTY, pos, String.valueOf(' '), String.valueOf(' '), String.valueOf(' '));
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

private void rewriteAnnotationsOnDimension(ArrayType oldArrayType, ArrayType replacingType, int index, int pos, boolean typeReplaced, TextEditGroup editGroup) throws CoreException {
  if (typeReplaced) {
    List dimensions = oldArrayType.dimensions();
    Dimension oldDim = index < dimensions.size() ? (Dimension) dimensions.get(index) : null;
    if (oldDim != null) {
      List oldAnnotations = oldDim.annotations();
      int size = oldAnnotations.size();
      if (size > 0) {
        ASTNode prev = getPreviousNode(oldDim);
        Annotation annotation = (Annotation) oldAnnotations.get(0);
        int start = prev != null ? prev.getStartPosition() + prev.getLength() : annotation.getStartPosition();
        annotation = (Annotation) oldAnnotations.get(size - 1);
        int end = annotation.getStartPosition() + annotation.getLength();
        end = getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, end) - 1;
        doTextRemove(start, end - start, editGroup);
      }
    }
    insertAnnotationsOnDimension(replacingType, index, pos, editGroup, true);
  } else {
    Dimension dim = (Dimension) replacingType.dimensions().get(index);
    rewriteNodeList(dim, Dimension.ANNOTATIONS_PROPERTY, pos, String.valueOf(' '), String.valueOf(' '), String.valueOf(' '));
  }
}

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

private void rewriteAnnotationsOnDimension(ArrayType oldArrayType, ArrayType replacingType, int index, int pos, boolean typeReplaced, TextEditGroup editGroup) throws CoreException {
  if (typeReplaced) {
    List dimensions = oldArrayType.dimensions();
    Dimension oldDim = index < dimensions.size() ? (Dimension) dimensions.get(index) : null;
    if (oldDim != null) {
      List oldAnnotations = oldDim.annotations();
      int size = oldAnnotations.size();
      if (size > 0) {
        ASTNode prev = getPreviousNode(oldDim);
        Annotation annotation = (Annotation) oldAnnotations.get(0);
        int start = prev != null ? prev.getStartPosition() + prev.getLength() : annotation.getStartPosition();
        annotation = (Annotation) oldAnnotations.get(size - 1);
        int end = annotation.getStartPosition() + annotation.getLength();
        end = getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, end) - 1;
        doTextRemove(start, end - start, editGroup);
      }
    }
    insertAnnotationsOnDimension(replacingType, index, pos, editGroup, true);
  } else {
    Dimension dim = (Dimension) replacingType.dimensions().get(index);
    rewriteNodeList(dim, Dimension.ANNOTATIONS_PROPERTY, pos, String.valueOf(' '), String.valueOf(' '), String.valueOf(' '));
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

private void rewriteAnnotationsOnDimension(ArrayType oldArrayType, ArrayType replacingType, int index, int pos, boolean typeReplaced, TextEditGroup editGroup) throws CoreException {
  if (typeReplaced) {
    List dimensions = oldArrayType.dimensions();
    Dimension oldDim = index < dimensions.size() ? (Dimension) dimensions.get(index) : null;
    if (oldDim != null) {
      List oldAnnotations = oldDim.annotations();
      int size = oldAnnotations.size();
      if (size > 0) {
        ASTNode prev = getPreviousNode(oldDim);
        Annotation annotation = (Annotation) oldAnnotations.get(0);
        int start = prev != null ? prev.getStartPosition() + prev.getLength() : annotation.getStartPosition();
        annotation = (Annotation) oldAnnotations.get(size - 1);
        int end = annotation.getStartPosition() + annotation.getLength();
        end = getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, end) - 1;
        doTextRemove(start, end - start, editGroup);
      }
    }
    insertAnnotationsOnDimension(replacingType, index, pos, editGroup, true);
  } else {
    Dimension dim = (Dimension) replacingType.dimensions().get(index);
    rewriteNodeList(dim, Dimension.ANNOTATIONS_PROPERTY, pos, String.valueOf(' '), String.valueOf(' '), String.valueOf(' '));
  }
}

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

Annotation annotation = convert(typeAnnotation);
type.annotations().add(annotation);
annotationsEnd = annotation.getStartPosition() + annotation.getLength();

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

Annotation annotation = convert(typeAnnotation);
type.annotations().add(annotation);
annotationsEnd = annotation.getStartPosition() + annotation.getLength();

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

Annotation annotation = convert(typeAnnotation);
type.annotations().add(annotation);
annotationsEnd = annotation.getStartPosition() + annotation.getLength();

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

Annotation annotation = convert(typeAnnotation);
type.annotations().add(annotation);
annotationsEnd = annotation.getStartPosition() + annotation.getLength();

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

Annotation annotation = convert(typeAnnotation);
type.annotations().add(annotation);
annotationsEnd = annotation.getStartPosition() + annotation.getLength();

代码示例来源:origin: windup/windup

compilationUnit.getLineNumber(node.getStartPosition()),
compilationUnit.getColumnNumber(node.getStartPosition()),
node.getLength(),
node.toString());

代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.core

if (noOfAnnotations > 0) {
  Annotation annotation= (Annotation) node.varargsAnnotations().get(noOfAnnotations - 1);
  int annotationEndPosition= annotation.getStartPosition() + annotation.getLength();
  ellipsisEnd= getScanner().getNextEndOffset(annotationEndPosition, true);
} else {

代码示例来源:origin: trylimits/Eclipse-Postfix-Code-Completion

if (noOfAnnotations > 0) {
  Annotation annotation= (Annotation) node.varargsAnnotations().get(noOfAnnotations - 1);
  int annotationEndPosition= annotation.getStartPosition() + annotation.getLength();
  ellipsisEnd= getScanner().getNextEndOffset(annotationEndPosition, true);
} else {

代码示例来源:origin: org.eclipse.tycho/org.eclipse.jdt.core

if (noOfAnnotations > 0) {
  Annotation annotation= (Annotation) node.varargsAnnotations().get(noOfAnnotations - 1);
  int annotationEndPosition= annotation.getStartPosition() + annotation.getLength();
  ellipsisEnd= getScanner().getNextEndOffset(annotationEndPosition, true);
} else {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.core

if (noOfAnnotations > 0) {
  Annotation annotation= (Annotation) node.varargsAnnotations().get(noOfAnnotations - 1);
  int annotationEndPosition= annotation.getStartPosition() + annotation.getLength();
  ellipsisEnd= getScanner().getNextEndOffset(annotationEndPosition, true);
} else {

代码示例来源:origin: com.google.code.maven-play-plugin.org.eclipse.jdt/org.eclipse.jdt.core

if (noOfAnnotations > 0) {
  Annotation annotation= (Annotation) node.varargsAnnotations().get(noOfAnnotations - 1);
  int annotationEndPosition= annotation.getStartPosition() + annotation.getLength();
  ellipsisEnd= getScanner().getNextEndOffset(annotationEndPosition, true);
} else {

相关文章