Package org.eclipse.dltk.core

Examples of org.eclipse.dltk.core.ISourceRange


  protected String getHeaderComment(IMember member) {
    if (member instanceof IField) {
      return null;
    }
    try {
      ISourceRange range = member.getSourceRange();
      if (range == null)
        return null;

      IBuffer buf = null;

      ISourceModule compilationUnit = member.getSourceModule();
      if (!compilationUnit.isConsistent()) {
        return null;
      }

      buf = compilationUnit.getBuffer();

      final int start = range.getOffset();

      String contents = buf.getContents();

      String result = "";
View Full Code Here


  public void update() {
    setEnabled(!fHistory.isEmpty());
  }

  public void run() {
    ISourceRange old = fHistory.getLast();
    if (old != null) {
      try {
        fHistory.ignoreSelectionChanges();
        fEditor.selectAndReveal(old.getOffset(), old.getLength());
      } finally {
        fHistory.listenToSelectionChanges();
      }
    }
  }
View Full Code Here

        fEditor, false);
    if (!(inputElement instanceof ISourceModule && inputElement.exists()))
      return;

    // ITypeRoot typeRoot= (ITypeRoot) inputElement;
    ISourceRange sourceRange;
    try {
      sourceRange = inputElement.getSourceRange();
      if (sourceRange == null || sourceRange.getLength() == 0) {
        MessageDialog
            .openInformation(
                fEditor.getEditorSite().getShell(),
                Messages.StructureSelectionAction_0,
                Messages.StructureSelectionAction_1);
        return;
      }
    } catch (ModelException e) {
    }
    ITextSelection selection = getTextSelection();
    ISourceRange newRange = getNewSelectionRange(
        createSourceRange(selection), inputElement);
    // Check if new selection differs from current selection
    if (selection.getOffset() == newRange.getOffset()
        && selection.getLength() == newRange.getLength())
      return;
    fSelectionHistory.remember(new SourceRange(selection.getOffset(),
        selection.getLength()));
    try {
      fSelectionHistory.ignoreSelectionChanges();
      fEditor.selectAndReveal(newRange.getOffset(), newRange.getLength());
    } finally {
      fSelectionHistory.listenToSelectionChanges();
    }
  }
View Full Code Here

  public ISourceRange getLast() {
    if (isEmpty())
      return null;
    int size = fHistory.size();
    ISourceRange result = fHistory.remove(size - 1);
    fHistoryAction.update();
    return result;
  }
View Full Code Here

   * @param member
   * @return array of 3 ints or <code>null</code>
   */
  protected int[] getNewLineNumberAndRange(IMember member)
      throws CoreException {
    ISourceRange nameRange = member.getNameRange();
    int offset = nameRange.getOffset();
    int lineNumber = getNewLineNumber(member, offset);
    return new int[] { lineNumber, offset, offset + nameRange.getLength() };
  }
View Full Code Here

  private DeclarationType declarationType;

  public DeclarationSearcher(ModuleDeclaration moduleDeclaration,
      IMember modelElement, DeclarationType declarationType)
      throws ModelException {
    ISourceRange sourceRange = modelElement.getSourceRange();
    modelStart = sourceRange.getOffset();
    modelEnd = modelStart + sourceRange.getLength();
    modelCutoffStart = modelStart - 100;
    modelCutoffEnd = modelEnd + 100;
    elementName = modelElement.getElementName();

    this.declarationType = declarationType;
View Full Code Here

    protected final IRegion[] computeProjectionRanges(
            ISourceReference reference, FoldingStructureComputationContext ctx)
    {
        try {
            ISourceRange range = reference.getSourceRange();
            if (!SourceRange.isAvailable(range))
                return new IRegion[0];
            List<IRegion> regions = new ArrayList<IRegion>();
            if (!ctx.isHeaderChecked() && reference instanceof IModelElement) {
                ctx.setFirstElement((IModelElement) reference);
                ctx.setHeaderChecked();

                IRegion headerComment = computeHeaderComment(ctx);
                if (headerComment != null) {
                    regions.add(headerComment);
                    ctx.setHasHeaderComment();
                }
            }

            final int shift = range.getOffset();
            ICommentScanner scanner = ctx.getScanner();
            scanner.resetTo(shift);

            int start = shift;

            start = scanner.computePreviousComment();

            if (start != shift) {
                start = scanner.getCurrentCommentStartPosition();
                int end = scanner.getCurrentCommentEndPosition();
                regions.add(new Region(start, end - start));
            }

            // shift -> start
            regions.add(new Region(shift, range.getLength()));

            IRegion[] result = new IRegion[regions.size()];
            regions.toArray(result);
            return result;
        } catch (ModelException e) {
View Full Code Here

                 * reconciling would trigger another element delta which would
                 * lead to reentrant situations. Therefore, we optimistically
                 * assume that the name range is correct, but double check the
                 * received lines below.
                 */
                ISourceRange nameRange = fMember.getNameRange();
                if (nameRange != null)
                    nameStart = nameRange.getOffset();

            } catch (ModelException e) {
                // ignore and use default
            }

View Full Code Here

                throws BadLocationException
        {
            int nameStart = offset;
            try {
                // need a reconcile here?
                ISourceRange nameRange = fMember.getNameRange();
                if (nameRange != null)
                    nameStart = nameRange.getOffset();
            } catch (ModelException e) {
                // ignore and use default
            }

            return nameStart - offset;
View Full Code Here

            if (sourceViewer != null)
                textWidget = sourceViewer.getTextWidget();
            if (textWidget == null)
                return;
            try {
                ISourceRange range = null;
                range = reference.getSourceRange();
                if (range == null)
                    return;
                int offset = range.getOffset();
                int length = range.getLength();
                if (offset < 0 || length < 0)
                    return;
                setHighlightRange(offset, length, moveCursor);
                if (!moveCursor)
                    return;
                offset = -1;
                length = -1;
                if (reference instanceof IMember) {
                    range = ((IMember) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }
                }
                if (offset > -1 && length > 0) {
                    try {
                        textWidget.setRedraw(false);
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.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.