Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion





  private IHyperlink createTMLLabelLink(ITextViewer viewer, IRegion region, ITypedRegion partition, String attributeName, TMLRegion tmlInfo) throws BadLocationException {
    IRegion attributeValueRegion = tmlInfo.getAttributeValueRegion(attributeName);
    if (attributeValueRegion != null) {
      return new TMLLabelHyperlink(viewer, attributeValueRegion, tmlInfo);
    } else {
      return null;
    }
View Full Code Here


  }



  private IHyperlink createTMLReferenceLink(ITextViewer viewer, IRegion region, ITypedRegion partition, String attributeName, TMLRegion tmlInfo) throws BadLocationException {
    IRegion attributeValueRegion = tmlInfo.getAttributeValueRegion(attributeName);
    if (attributeValueRegion != null) {
      return new TMLModuleReferenceHyperlink(viewer, attributeValueRegion, tmlInfo);
    } else {
      return null;
    }
View Full Code Here

      return null;
    }
  }
 
  private IHyperlink createScriptReferenceLink(ITextViewer viewer, IRegion region, ITypedRegion partition, String attributeName, TMLRegion tmlInfo, String type) throws BadLocationException {
    IRegion attributeValueRegion = tmlInfo.getAttributeValueRegion(attributeName);
    if (attributeValueRegion != null) {
      return new ScriptReferenceHyperlink(viewer, attributeValueRegion, tmlInfo, type);
    } else {
      return null;
    }
View Full Code Here

          TMLTagAttribute tagAttribute = tag.getAttribute(attribute);
          if (tagAttribute != null) {
              if (tagAttribute.isTmlscriptExpression()) {
                  // perform tmlscript code completion
                  try {
                            IRegion region = getAttributeValueRegion(attribute);
                            TMLScriptRegion tmlScriptRegion = TMLScriptRegion.parse(region, _document, _cursorAbsolute, WGADesignStructureHelper.getWGAVersionCompliance(activeFile));
                            proposals.addAll(tmlScriptRegion.createProposals());
                        }
                        catch (BadLocationException e) {
                        }
View Full Code Here

  }
 
  public static List<ICompletionProposal> computeCloseTagProposals(IDocument document, int offset) throws BadLocationException {
    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
   
    IRegion region = document.getPartition(offset);
    // fallback to current edit line if partition has length 0 - for e.g. end of document
    if (region.getLength() == 0) {         
      region = document.getLineInformationOfOffset(offset);
    }
    // search backwards for a tmltag with body which might need to be closed
    int pos = offset - 1;
    while (pos >= 0) {           
      ITypedRegion previousRegion = document.getPartition(pos);
      if (previousRegion.getType().equals(TMLPartitionScanner.TML_TAG_START) && !isTMLPartitionClosed(previousRegion, document)) {
          String alreadyTyped = document.get(region.getOffset(), offset-region.getOffset());       
          if (alreadyTyped.contains("\n")) {
            alreadyTyped = alreadyTyped.substring(alreadyTyped.lastIndexOf("\n"));
          }
          int posEnd = alreadyTyped.lastIndexOf(">");
          if (posEnd != -1) {
            alreadyTyped = alreadyTyped.substring(posEnd + 1);
          }
          posEnd = alreadyTyped.lastIndexOf("<");
          if (posEnd != -1) {
            alreadyTyped = alreadyTyped.substring(posEnd);
          } else {
            alreadyTyped = "";
          }
          String tagName = TMLPartitionScanner.determineTMLTagName(previousRegion, document);
          if (document.getLineOfOffset(offset) == document.getLineOfOffset(region.getOffset())) {
            // completion in same line
            int start = previousRegion.getOffset() + previousRegion.getLength();
            int end = offset;
            String typedBody = document.get(start, end - start);
            if (typedBody.trim().equals("")) {
View Full Code Here

        return text;

      try {
        // find start of line
        int p= (offset == document.getLength() ? offset  - 1 : offset);
        IRegion info= document.getLineInformationOfOffset(p);
        int start= info.getOffset();

        // find white spaces
        int end= findEndOfWhiteSpace(document, start, offset);

        StringBuffer buf= new StringBuffer(text);
View Full Code Here

  }
 
  public IRegion getAttributeValueRegion(String attributeName) throws BadLocationException {
    FindReplaceDocumentAdapter findReplaceAdapter = new FindReplaceDocumentAdapter(_document);
   
    IRegion region = findReplaceAdapter.find(_documentRegion.getOffset(), attributeName + "=\"" + getAttributeValue(attributeName) + "\"", true, true, false, false);
    if (region != null) {
      String tmp = attributeName + "=\"";
      return new Region(region.getOffset() + tmp.length(), region.getLength() - tmp.length() - 1);
    } else {
      return null;
    }
    /*
    IRegion end = findReplaceAdapter.find(start.getOffset() + start.getLength(), "\"", true, true, false, false);
View Full Code Here

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    IDocument document = viewer.getDocument();
           
        try {
            IRegion region = document.getPartition(offset);
           
            // search backwards to document start or partition of type TML - this is neccessary bc. our current script may contain TMLscript comments
            ITypedRegion prevPartition = null;
            int previousOffset = region.getOffset() - 1;
            while (previousOffset > 0) {
                prevPartition = document.getPartition(previousOffset);
                if (prevPartition.getType().equals(TMLPartitionScanner.TML_TAG_START)) {
                    break;
                }
                previousOffset = prevPartition.getOffset() - 1;
            }
           
            if (prevPartition != null) {
                region = new Region(previousOffset+1, region.getOffset() - previousOffset + region.getLength() - 1);
            }
           
            VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(Plugin.getDefault().getActiveFile());
            TMLScriptRegion tmlScriptRegion = TMLScriptRegion.parse(region, document, offset, versionCompliance);
            System.out.println(tmlScriptRegion.toString());
View Full Code Here

   * @return the line end offset for the given offset
   * @exception BadLocationException if offset is invalid in the current document
   */
  protected int endOfLineOf(int offset) throws BadLocationException {

    IRegion info = fDocument.getLineInformationOfOffset(offset);
    if (offset <= info.getOffset() + info.getLength())
      return info.getOffset() + info.getLength();

    int line = fDocument.getLineOfOffset(offset);
    try {
      info = fDocument.getLineInformation(line + 1);
      return info.getOffset() + info.getLength();
    } catch (BadLocationException x) {
      return fDocument.getLength();
    }
  }
View Full Code Here

    DocumentEvent event,
    boolean documentPartitioningChanged) {
    if (!documentPartitioningChanged) {
      try {

        IRegion info =
          fDocument.getLineInformationOfOffset(event.getOffset());
        int start = Math.max(partition.getOffset(), info.getOffset());

        int end =
          event.getOffset()
            + (event.getText() == null
              ? event.getLength()
              : event.getText().length());

        if (info.getOffset() <= end
          && end <= info.getOffset() + info.getLength()) {
          // optimize the case of the same line
          end = info.getOffset() + info.getLength();
        } else
          end = endOfLineOf(end);

        end =
          Math.min(
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.IRegion

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.