Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.ISourceReference


 
 
  private String computeSource() {
    StringBuffer result = new StringBuffer();
    try {
      ISourceReference ref = (ISourceReference) owner;
      ISourceRange range = ref.getSourceRange();
      int sourceOffset = range.getOffset();
      int sourceLen = range.getLength();
      int offset = position.getOffset();
      int len = position.getLength();

      offset -= sourceOffset;
      if (offset < 0) {
        offset = 0;
        result.append("Position precedes element!\n");
      }
      if (len > sourceLen) {
        len = sourceLen;
        result.append("Position extends past element!\n");
      }
      if (len < 0) {
        len = 0;
        result.append("Length was less than 0!\n");
      }
      result.append(ref.getSource().substring(offset, offset + len));

    }
    catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here


   * @param elem
   * @return @throws
   *         JavaModelException
   */
  protected ISourceRange getNaturalRange(IJavaElement elem) throws JavaModelException {
    ISourceReference ref = (ISourceReference) elem;
    return ref.getSourceRange();
  }
View Full Code Here

   * @param result
   * @param positions
   * @throws BadLocationException
   */
  private void constructAnnotations(IJavaElement elem, Map result, Set positions) throws BadLocationException, JavaModelException {
    ISourceReference reference = (ISourceReference) elem;

    if (positions != null) {

      for (Iterator iter = positions.iterator(); iter.hasNext();) {
        EnhancedPosition aPosition = (EnhancedPosition) iter.next();
View Full Code Here

    Set regionSet;
    if (!strategy.shouldScan(elem)) {
      regionSet = strategy.result(); // call immediately...
    }
    else {
      ISourceReference reference = (ISourceReference) elem;
      ISourceRange range = reference.getSourceRange();

      // All other element types require some parsing...
      String contents = reference.getSource();

      if (contents == null) return null;

      IScanner scanner = ToolFactory.createScanner(true, false, false, false);
      scanner.setSource(contents.toCharArray());
View Full Code Here

   * @param result
   * @param positions
   * @throws BadLocationException
   */
  private void constructAnnotations(IJavaElement elem, Map result, Set positions) throws BadLocationException, JavaModelException {
    ISourceReference reference = (ISourceReference) elem;

    if (positions != null) {

      for (Iterator iter = positions.iterator(); iter.hasNext();) {
        EnhancedPosition aPosition = (EnhancedPosition) iter.next();
View Full Code Here

    Set regionSet;
    if (!strategy.shouldScan(elem)) {
      regionSet = strategy.result(); // call immediately...
    }
    else {
      ISourceReference reference = (ISourceReference) elem;
      ISourceRange range = reference.getSourceRange();

      // All other element types require some parsing...
      String contents = reference.getSource();

      if (contents == null) return null;

      IScanner scanner = ToolFactory.createScanner(true, false, false, false);
      scanner.setSource(contents.toCharArray());
View Full Code Here

 
 
  private String computeSource() {
    StringBuffer result = new StringBuffer();
    try {
      ISourceReference ref = (ISourceReference) owner;
      ISourceRange range = ref.getSourceRange();
      int sourceOffset = range.getOffset();
      int sourceLen = range.getLength();
      int offset = position.getOffset();
      int len = position.getLength();

      offset -= sourceOffset;
      if (offset < 0) {
        offset = 0;
        result.append("Position precedes element!\n");
      }
      if (len > sourceLen) {
        len = sourceLen;
        result.append("Position extends past element!\n");
      }
      if (len < 0) {
        len = 0;
        result.append("Length was less than 0!\n");
      }
      result.append(ref.getSource().substring(offset, offset + len));

    }
    catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

   * @param elem
   * @return @throws
   *         JavaModelException
   */
  protected ISourceRange getNaturalRange(IJavaElement elem) throws JavaModelException {
    ISourceReference ref = (ISourceReference) elem;
    return ref.getSourceRange();
  }
View Full Code Here

    String endSentinel = FoldingPlugin.getPrefs().getString(PreferenceKeys.USER_DEFINED_END);
    return isSentinel(endSentinel, start, end, owner);
  }
 
  public boolean isSentinel(String sentinel, int start, int end, IJavaElement owner) throws JavaModelException {
    ISourceReference reference = (ISourceReference) owner;
   
    String contents = reference.getSource();
    ISourceRange range = (ISourceRange)reference.getSourceRange();
   
   
    int correctedStart = start - range.getOffset();
    // Math.min should be redundant (no JavaElement should contain half of a comment)
    int correctedEnd = Math.min( (end - range.getOffset()) , range.getLength());
View Full Code Here

      }
    }

    IType resultType = result.getTypes()[0];
    String name = resultType.getElementName();
    ISourceReference ref = resultType;
    ISourceRange docRange = resultType.getJavadocRange();

    IJavaElement element = src.getElementAt(offset);
    if(element != null && element.getElementType() == IJavaElement.METHOD){
      IMethod method = null;
      if (finder.isTest(src.getTypes()[0])){
        method = JUnitUtils.findClassMethod(result, (IMethod)element);
      }else{
        method = JUnitUtils.findTestMethod(result, (IMethod)element);
      }
      if (method != null){
        name = method.getElementName();
        ref = method;
        docRange = method.getJavadocRange();
      }
    }

    String lineDelim = result.findRecommendedLineSeparator();
    int docLength = docRange != null ?
      docRange.getLength() + lineDelim.length() : 0;
    return Position.fromOffset(
        result.getResource().getLocation().toOSString(), name,
        ref.getSourceRange().getOffset() + docLength, 0);
  }
View Full Code Here

TOP

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

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.