Examples of ISourceRange


Examples of org.eclipse.jdt.core.ISourceRange

        public int compare(Object o1, Object o2) {
            IType m1 = (IType) o1;
            IType m2 = (IType) o2;
            int idx1, idx2;
            try {
                ISourceRange sr1 = m1.getSourceRange();
                ISourceRange sr2 = m2.getSourceRange();
                if (sr1 == null || sr2 == null) {
                    return 0;
                }
                idx1 = sr1.getOffset();
                idx2 = sr2.getOffset();
            } catch (JavaModelException e) {
                BytecodeOutlinePlugin.log(e, IStatus.ERROR);
                return 0;
            }
            return idx1 - idx2;
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

            removeUnusedImports(cu, existingImports, false);

            JavaModelUtil.reconcile(cu);

            ISourceRange range = createdType.getSourceRange();

            IBuffer buf = cu.getBuffer();
            String originalContent = buf.getText(range.getOffset(), range.getLength());

            String formattedContent = CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARATIONS, originalContent, indent, lineDelimiter, pack.getJavaProject());
            formattedContent = Strings.trimLeadingTabsAndSpaces(formattedContent);
            buf.replace(range.getOffset(), range.getLength(), formattedContent);
            if (!isInnerClass) {
                String fileComment = getFileComment(cu);
                if (fileComment != null && fileComment.length() > 0) {
                    buf.replace(0, 0, fileComment + lineDelimiter);
                }
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

            removeUnusedImports(cu, existingImports, false);

            JavaModelUtil.reconcile(cu);

            ISourceRange range = createdType.getSourceRange();

            IBuffer buf = cu.getBuffer();
            String originalContent = buf.getText(range.getOffset(), range.getLength());

            String formattedContent = CodeFormatterUtil.format(CodeFormatter.K_CLASS_BODY_DECLARATIONS, originalContent, indent, lineDelimiter, pack.getJavaProject());
            formattedContent = Strings.trimLeadingTabsAndSpaces(formattedContent);
            buf.replace(range.getOffset(), range.getLength(), formattedContent);
            if (!isInnerClass) {
                String fileComment = getFileComment(cu);
                if (fileComment != null && fileComment.length() > 0) {
                    buf.replace(0, 0, fileComment + lineDelimiter);
                }
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

   * @param methodName
   * @throws JavaModelException
   */
  private void focusOrCreateMethod(IEditorPart editorPart, IType type, String methodName) throws JavaModelException {
    // We can't just use IType.getMethod because we don't know the arguments
    ISourceRange sourceRange = null;
    IMethod[] methods;
    System.out.println("Looking for method: " + methodName);
      methods = type.getMethods();
      for (int i = 0; i < methods.length; i++) {
        if (methods[i].getElementName().equals(methodName)) {
          sourceRange = methods[i].getSourceRange();
        }
      }
    if (sourceRange != null) {
      FilesAccess.goToCharacter(editorPart, sourceRange.getOffset());
    } else if (PlayPlugin.showConfirm("The method " + methodName + " doesn't exist. Do you want to create it?")) {
        IMethod newMethod = type.createMethod("public static void "+methodName+"() {\n\n}\n", null, false, null);
        FilesAccess.goToCharacter(editorPart, newMethod.getSourceRange().getOffset());
    }
  }
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof ISourceRange)) {
      return false;
    }
    ISourceRange sourceRange = (ISourceRange) obj;
    return sourceRange.getOffset() == this.offset && sourceRange.getLength() == this.length;
  }
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

    if (isel instanceof TextSelection)
    {
      try
      {
        TextSelection   selection = (TextSelection)isel;
        ISourceRange   sourceRange = element.getSourceRange();
       
        if (sourceRange == null)
          return false;
       
        if ((sourceRange.getOffset() <= selection.getOffset()) &&
          (sourceRange.getOffset() + sourceRange.getLength() >= selection.getOffset() + selection.getLength()))
        {
          return true;
        }
      }
      catch (JavaModelException e)
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

        if (buf == null) {
          // no source attachment found. This method maybe the one. Stop.
          return InheritDocVisitor.STOP_BRANCH;
        }

        ISourceRange javadocRange= member.getJavadocRange();
        if (javadocRange == null)
          return InheritDocVisitor.CONTINUE;  // this method doesn't have javadoc, continue to look.
        String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength());
        if (rawJavadoc != null) {
          return overridden;
        }
        return InheritDocVisitor.CONTINUE;
      }
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

    Annotation[] astAnnotations = new Annotation[length];
    if (length > 0) {
      char[] cuSource = getSource();
      int recordedAnnotations = 0;
      for (int i = 0; i < length; i++) {
        ISourceRange positions = annotations[i].getSourceRange();
        int start = positions.getOffset();
        int end = start + positions.getLength();
        char[] annotationSource = CharOperation.subarray(cuSource, start, end);
        if (annotationSource != null) {
            Expression expression = parseMemberValue(annotationSource);
            /*
             * expression can be null or not an annotation if the source has changed between
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

    IAnnotation[] annotations = element.getAnnotations();
    int length = annotations.length;
    Annotation[] astAnnotations = new Annotation[length];
    int recordedAnnotations = 0;
    for (int i = 0; i < length; i++) {
      ISourceRange positions = annotations[i].getSourceRange();
      int start = positions.getOffset();
      int end = start + positions.getLength();
      char[] annotationSource = CharOperation.subarray(cuSource, start, end);
      if (annotationSource != null) {
          Expression expression = parseMemberValue(annotationSource);
          /*
           * expression can be null or not an annotation if the source has changed between
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceRange

  } while (token != TerminalTokens.TokenNameEOF);

}
protected void reportBinaryMemberDeclaration(IResource resource, IMember binaryMember, Binding binaryMemberBinding, IBinaryType info, int accuracy) throws CoreException {
  ClassFile classFile = (ClassFile) binaryMember.getClassFile();
  ISourceRange range = classFile.isOpen() ? binaryMember.getNameRange() : SourceMapper.UNKNOWN_RANGE;
  if (range.getOffset() == -1) {
    BinaryType type = (BinaryType) classFile.getType();
    String sourceFileName = type.sourceFileName(info);
    if (sourceFileName != null) {
      SourceMapper mapper = classFile.getSourceMapper();
      if (mapper != null) {
        char[] contents = mapper.findSource(type, sourceFileName);
        if (contents != null)
          range = mapper.mapSource(type, contents, info, binaryMember);
      }
    }
  }
  if (resource == null) resource =  this.currentPossibleMatch.resource;
  SearchMatch match = newDeclarationMatch(binaryMember, binaryMemberBinding, accuracy, range.getOffset(), range.getLength(), getParticipant(), resource);
  report(match);
}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.