Examples of ISourceRange


Examples of org.eclipse.jdt.core.ISourceRange

      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

Examples of org.eclipse.jdt.core.ISourceRange

        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

Examples of org.eclipse.jdt.core.ISourceRange

    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

Examples of org.eclipse.jdt.core.ISourceRange

  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

Examples of org.eclipse.jdt.core.ISourceRange

    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

Examples of org.eclipse.jdt.core.ISourceRange

          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

Examples of org.eclipse.jdt.core.ISourceRange

        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

Examples of org.eclipse.jdt.core.ISourceRange

        }

        // 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

Examples of org.eclipse.jdt.core.ISourceRange

        }

        // 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();
              Object cu = ((ILocalVariable) element).getDeclaringMember().getCompilationUnit();
              if (cu != null && cu.equals(jspTranslation.getCompilationUnit()))
                isInTranslationCU = true;
            }
            // 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();
                isInTranslationCU = true;
              }
            }
            // 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();
                isInTranslationCU = true;
              }
            }
          }

          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

Examples of org.eclipse.jdt.core.ISourceRange

    IJavaProject javaProject = JavaCore.create(getProject());
    SingletonDependencyFinder finder = new SingletonDependencyFinder(projectModel);
    Dependency[] dependencies = finder.findSingletonDependencies(singleton, interfacesToSearchFor);
   
    IType type = javaProject.findType(singleton);
    ISourceRange sourceRange = type.getSourceRange();

    CompilationUnit compilationUnit = cache.getCompilationUnit(type.getCompilationUnit());
    TypeDeclaration typeDeclaration = cache.getTypeDeclaration(type);
    IAnnotationBinding[] annotations = typeDeclaration.resolveBinding().getAnnotations();

    List<String> declaredDependencies = new ArrayList<String>();

    for (IAnnotationBinding annotation : annotations) {
      if ("javax.ejb.DependsOn".equals(annotation.getAnnotationType().getQualifiedName())) {
        IMemberValuePairBinding[] pairs = annotation.getDeclaredMemberValuePairs();
        for (int i = 0; i < pairs.length; i++) {
          if ("value".equals(pairs[i].getName())) {
            if (pairs[i].getValue() instanceof Object[]) {
              Object[] values = (Object[]) pairs[i].getValue();
              for (int j = 0; j < values.length; j++) {
                declaredDependencies.add(values[j].toString());
              }
            }
          }
        }
      }
    }

    List<String> expectedDependencies = new ArrayList<String>();

    if (dependencies != null) {
      for (Dependency dependency : dependencies) {
        expectedDependencies.add(dependency.getDependsOn());
      }
    }

    boolean matches = expectedDependencies.size() == declaredDependencies.size();

    if (matches) {
      for (String dependency : declaredDependencies) {
        if (!expectedDependencies.contains(dependency)) {
          matches = false;
          break;
        }
      }
    }

    if (!matches) {
      IMarker marker = type.getUnderlyingResource().createMarker(MARKER_TYPE_DEPENDS_ON);
      Map attributes = new HashMap();

      attributes.put(IMarker.LINE_NUMBER, compilationUnit.getLineNumber(sourceRange.getOffset()));
      attributes.put(IMarker.CHAR_START, sourceRange.getOffset());
      attributes.put(IMarker.CHAR_END, sourceRange.getOffset() + sourceRange.getLength());
      attributes.put(IMarker.LINE_NUMBER, compilationUnit.getLineNumber(sourceRange.getOffset()));
      attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
      attributes.put(IMarker.MESSAGE, expectedDependencies.size() == 0 ? "This bean should not have the @DependsOn annotation" : "This bean requires the @DependsOn annotation, and depends on: " + getDependencyList(expectedDependencies));
      attributes.put(ISingletonDependencyMarker.DEPENDENCIES, expectedDependencies.toArray(new String[expectedDependencies.size()]));
      attributes.put(ISingletonDependencyMarker.BEAN, singleton);
      marker.setAttributes(attributes);
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.