Package org.eclipse.jdt.core

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


  } 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

      parser.parseCompilationUnit(
        new BasicCompilationUnit(contents, null, this.binaryType.sourceFileName(info), javaElement),
        doFullParse,
        null/*no progress*/);
      if (elementToFind != null) {
        ISourceRange range = getNameRange(elementToFind);
        return range;
      } else {
        return null;
      }
    } finally {
View Full Code Here

        System.out.print("SELECTION - accept method("); //$NON-NLS-1$
        System.out.print(method.toString());
        System.out.println(")"); //$NON-NLS-1$
      }
    } else {
      ISourceRange range = method.getSourceRange();
      if (range.getOffset() != -1 && range.getLength() != 0 ) {
        if (uniqueKey != null) {
          ResolvedBinaryMethod resolvedMethod = new ResolvedBinaryMethod(
              (JavaElement)method.getParent(),
              method.getElementName(),
              method.getParameterTypes(),
View Full Code Here

    if(type != null) {
      try {
        IField[] fields = type.getFields();
        for (int i = 0; i < fields.length; i++) {
          IField field = fields[i];
          ISourceRange range = field.getNameRange();
          if(range.getOffset() <= start
              && range.getOffset() + range.getLength() >= end
              && field.getElementName().equals(new String(name))) {
            addElement(fields[i]);
            if(SelectionEngine.DEBUG){
              System.out.print("SELECTION - accept field("); //$NON-NLS-1$
              System.out.print(field.toString());
View Full Code Here

  String name = new String(selector);
  IMethod[] methods = null;
  try {
    methods = type.getMethods();
    for (int i = 0; i < methods.length; i++) {
      ISourceRange range = methods[i].getNameRange();
      if(range.getOffset() <= start
          && range.getOffset() + range.getLength() >= end
          && methods[i].getElementName().equals(name)) {
        addElement(methods[i]);
        if(SelectionEngine.DEBUG){
          System.out.print("SELECTION - accept method("); //$NON-NLS-1$
          System.out.print(this.elements[0].toString());
View Full Code Here

    IMethod[] methods = null;

    try {
      methods = type.getMethods();
      done : for (int i = 0; i < methods.length; i++) {
        ISourceRange range = methods[i].getNameRange();
        if(range.getOffset() >= selectorStart
            && range.getOffset() + range.getLength() <= selectorEnd
            && methods[i].getElementName().equals(name)) {
          method = methods[i];
          break done;
        }
      }
View Full Code Here

          IType[] tTypes = wc.getTypes();
          int i = 0;
          int depth = 0;
          done : while(i < tTypes.length) {
            ISourceRange range = tTypes[i].getSourceRange();
            if(range.getOffset() <= start
                && range.getOffset() + range.getLength() >= end
                && tTypes[i].getElementName().equals(new String(compoundName[depth]))) {
              if(depth == compoundName.length - 1) {
                type = tTypes[i];
                break done;
              }
View Full Code Here

        public int compare(IType o1, IType o2) {
            IType m1 = o1;
            IType m2 = 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) {
                FindbugsPlugin.getDefault().logException(e, "SourceOffsetComparator failed");
                return 0;
            }
            return idx1 - idx2;
View Full Code Here

        }

        // get Java range, translate coordinate to JSP

        try {
          ISourceRange range = null;
          IJSPTranslation jspTranslation = getJSPTranslation(document);
          if (jspTranslation != null) {
            // link to local variable definitions
            if (element instanceof ILocalVariable) {
              range = ((ILocalVariable) element).getNameRange();
            }
            // linking to fields of the same compilation unit
            else if (element.getElementType() == IJavaElement.FIELD) {
              Object cu = ((IField) element).getCompilationUnit();
              if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
                range = ((ISourceReference) element).getSourceRange();
            }
            // linking to methods of the same compilation unit
            else if (element.getElementType() == IJavaElement.METHOD) {
              Object cu = ((IMethod) element).getCompilationUnit();
              if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
                range = ((ISourceReference) element).getSourceRange();
            }
          }

          if (range != null && file != null) {
            jspOffset = jspTranslation.getJspOffset(range.getOffset());
            if (jspOffset >= 0) {
              link = new WorkspaceFileHyperlink(region, file, new Region(jspOffset, range.getLength()));
            }
          }
        }
        catch (JavaModelException jme) {
          Logger.log(Logger.WARNING_DEBUG, jme.getMessage(), jme);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.ISourceRange

Copyright © 2018 www.massapicom. 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.