Examples of ISourceReference

Source reference elements may be working copies if they were created from a compilation unit that is a working copy.

@noimplement This interface is not intended to be implemented by clients.


Examples of org.eclipse.jdt.core.ISourceReference

    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

Examples of org.eclipse.jdt.core.ISourceReference

   * @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

Examples of org.eclipse.jdt.core.ISourceReference

    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

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

Examples of org.eclipse.jdt.core.ISourceReference

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

Examples of org.eclipse.jdt.core.ISourceReference

    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

Examples of org.eclipse.jdt.core.ISourceReference

      }
    }

    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

Examples of org.eclipse.jdt.core.ISourceReference

    }
    else if (part instanceof IEditorPart
        && selection instanceof ITextSelection) {
      if (part instanceof JavaEditor) {
        JavaEditor je = (JavaEditor) part;
        ISourceReference sourceRef = computeHighlightRangeSourceReference(je);
        IJavaElement javaElement = (IJavaElement) sourceRef;
        return javaElement;
      }
    }
    return null;
View Full Code Here

Examples of org.eclipse.jdt.core.ISourceReference

      }
    }
    else if (part instanceof IEditorPart && selection instanceof ITextSelection) {
      if (part instanceof JavaEditor) {
        JavaEditor je = (JavaEditor) part;
        ISourceReference sourceRef = computeHighlightRangeSourceReference(je);
        IJavaElement javaElement = (IJavaElement) sourceRef;
        return javaElement;
      }
    }
    return null;
View Full Code Here

Examples of org.erlide.engine.model.erlang.ISourceReference

        return ErlangEngine.getInstance().getModel()
                .innermostThat(this, new Predicate<IErlElement>() {
                    @Override
                    public boolean apply(final IErlElement e) {
                        if (e instanceof ISourceReference) {
                            final ISourceReference ch = (ISourceReference) e;
                            ISourceRange r;
                            r = ch.getSourceRange();
                            if (r != null && r.hasPosition(position)) {
                                return true;
                            }
                        }
                        return false;
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.