Package org.erlide.engine.model.erlang

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


                .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


            final IErlModule m = (IErlModule) element;
            length = doc.getLength();
            name = m.getModuleName();
        } else if (element instanceof ISourceReference) {
            final ISourceReference sourceReference = (ISourceReference) element;
            final ISourceRange sr = sourceReference.getSourceRange();
            start = sr.getOffset();
            length = sr.getLength();
        }
        return new ErlNode(parent, element.getKind(), name,
                ErlangCompareUtilities.getErlElementID(element), doc, start, length);
    }
View Full Code Here

     * @return the regions to be folded, or <code>null</code> if there are none
     */
    private IRegion computeProjectionRanges(final IErlElement element) {
        if (element instanceof ISourceReference) {
            final ISourceReference reference = (ISourceReference) element;
            final ISourceRange range = reference.getSourceRange();
            return new Region(range.getOffset(), range.getLength());
        }
        return null;
    }
View Full Code Here

            throws CoreException {
        // if (fCachedRange == null) {
        // fCachedRange= sourceElement.getSourceRange();
        // }
        // ISourceRange range= fCachedRange;
        final ISourceRange range = sourceElement.getSourceRange();
        if (range != null) {
            final int rangeOffset = range.getOffset();
            return rangeOffset <= pos && rangeOffset + range.getLength() > pos;
        }
        return false;
    }
View Full Code Here

             * The member's name range may not be correct. However, 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.
             */
            final ISourceRange nameRange = fMember.getNameRange();
            if (nameRange != null) {
                nameStart = nameRange.getOffset();
            }

            final int firstLine = document.getLineOfOffset(offset);
            int captionLine = document.getLineOfOffset(nameStart);
            final int lastLine = document.getLineOfOffset(offset + length);
View Full Code Here

         */
        @Override
        public int computeCaptionOffset(final IDocument document)
                throws BadLocationException {
            int nameStart = offset;
            final ISourceRange nameRange = fMember.getNameRange();
            if (nameRange != null) {
                nameStart = nameRange.getOffset();
            }

            return nameStart - offset;
        }
View Full Code Here

            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 IErlMember) {
                    range = ((IErlMember) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }
                } else if (reference instanceof IErlAttribute) {
                    range = ((IErlAttribute) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }

                } else if (reference instanceof IErlFunctionClause) {
                    range = ((IErlFunctionClause) reference).getNameRange();
                    if (range != null) {
                        offset = range.getOffset();
                        length = range.getLength();
                    }
                }
                if (offset > -1 && length > 0) {

                    try {
View Full Code Here

                try {
                    final IErlElement e1 = module.getElementAt(offset1);
                    final IErlElement e2 = module.getElementAt(offset2);
                    if (e1 instanceof ISourceReference) {
                        final ISourceReference ref1 = (ISourceReference) e1;
                        final ISourceRange r1 = ref1.getSourceRange();
                        final int offset = r1.getOffset();
                        int length = r1.getLength();
                        if (e1 == e2) {
                            final int docLength = document.getLength();
                            if (offset + length > docLength) {
                                length = docLength - offset;
                            }
                            return extendSelectionToWholeLines(document,
                                    new TextSelection(document, offset, length));
                        } else if (e2 == null) {
                            return extendSelectionToWholeLines(
                                    document,
                                    new TextSelection(document, offset, selection
                                            .getLength() + selection.getOffset() - offset));
                        } else if (e2 instanceof ISourceReference) {
                            final ISourceReference ref2 = (ISourceReference) e2;
                            final ISourceRange r2 = ref2.getSourceRange();
                            return extendSelectionToWholeLines(document,
                                    new TextSelection(document, offset, r2.getOffset()
                                            - offset + r2.getLength()));
                        }
                    }
                } catch (final ErlModelException e) {
                }
            }
View Full Code Here

  protected Object _findOpenResult(final VariableOpenResult openResult, final IErlModule module, final IErlProject project, final IErlElement element, final IErlElementLocator model, final IErlElementLocator.Scope scope, final ITextEditor editor) {
    try {
      Object _xblockexpression = null;
      {
        if ((element instanceof ISourceReference)) {
          final ISourceRange range = ((ISourceReference)element).getSourceRange();
          IDocumentProvider _documentProvider = editor.getDocumentProvider();
          IEditorInput _editorInput = editor.getEditorInput();
          IDocument _document = _documentProvider.getDocument(_editorInput);
          int _offset = range.getOffset();
          int _length = range.getLength();
          final String elementText = _document.get(_offset, _length);
          String _name = openResult.getName();
          return this.modelFindService.findVariable(range, _name, elementText);
        }
        _xblockexpression = null;
View Full Code Here

            final String prefix) throws BadLocationException {
        final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
        // get variables
        final IErlElement el = getElementAt(offset);
        if (el instanceof ISourceReference) {
            final ISourceRange r = ((ISourceReference) el).getSourceRange();
            final int o = r.getOffset();
            final IDocument doc = sourceViewer.getDocument();
            final int prefixLength = prefix.length();
            final String src = doc.get(o, offset - o - prefixLength);
            final Collection<String> vars = ErlangEngine.getInstance()
                    .getContextAssistService().getVariables(src, prefix);
View Full Code Here

TOP

Related Classes of org.erlide.engine.model.erlang.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.