Examples of IRegion


Examples of org.eclipse.jface.text.IRegion

    _viewer = viewer;
    setErrorMessage(null);

    IDocument document = viewer.getDocument();
    try {       
      IRegion region = determineRelatedRegion(offset, document);
      if (document.getContentType(region.getOffset()).equals(TMLPartitionScanner.TML_TAG_START)) {
        TMLRegion tmlRegion = TMLRegion.parse(region, document, offset);
        ICompletionProposal[] tmlProposals =  tmlRegion.createProposals(viewer, Plugin.getDefault().getActiveFile());
        if (tmlProposals != null) {
            proposals.addAll(Arrays.asList(tmlProposals));
        }
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

    return proposals.toArray(new ICompletionProposal[0]);   
  }

  public static IRegion determineRelatedRegion(int offset, IDocument document) throws BadLocationException {
    IRegion region = document.getPartition(offset);
    // partition length might be 0 - try previous region
    if (region.getLength() == 0) {         
      region = document.getPartition(offset - 1);
    }
    // fallback to current edit line if partition has length 0 - for e.g. end of document
    if (region.getLength() == 0) {         
      region = document.getLineInformationOfOffset(offset);
    }
    return region;
  }
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

        IDocument document = _viewer.getDocument();
        ISelection selection =_viewer.getSelectionProvider().getSelection();
        if (selection instanceof TextSelection) {
          TextSelection textSelection = (TextSelection) selection;
          int offset = textSelection.getOffset();
          IRegion region = document.getPartition(offset);
         
          boolean sameLine = document.getLineOfOffset(region.getOffset()) == document.getLineOfOffset(offset);
         
          if (document.getContentType(region.getOffset()).equals(TMLPartitionScanner.TML_TAG_START)) {
            TMLRegion tmlInfo = TMLRegion.parse(region, document, offset);
            if (tmlInfo.isCursorInTagName()) {
              return alphaNumericControlsNoEnter;
            } else if (tmlInfo.isCursorInAttributeValue()) {
               // check if attribute is tmlscript expression
                IFile activeFile = Plugin.getDefault().getActiveFile();
                String tagName = tmlInfo.getTagName();
                if (activeFile != null && tagName != null) {
                    VersionCompliance versionCompliance = WGADesignStructureHelper.getWGAVersionCompliance(activeFile);
                    if (versionCompliance != null) {
                        TMLTag tag = TMLTagDefinitions.getInstance(versionCompliance).getTagByName(tagName);
                        if (tag != null) {
                            String attributeAtCursor = tmlInfo.getAttributeAtCursor();
                            if (attributeAtCursor != null) {
                                TMLTagAttribute attribute = tag.getAttribute(attributeAtCursor);
                                if (attribute != null && attribute.isTmlscriptExpression()) {
                                    return _tmlScriptProcessor.getCompletionProposalAutoActivationCharacters();
                                }
                            }
                        }
                    }
                }
                return alphaNumericControls;
            } else {
                return alphaNumericControls;
            }
          } else if (document.getContentType(region.getOffset()).equals(IDocument.DEFAULT_CONTENT_TYPE) && sameLine) {
            return alphaNumericControlsNoEnter;
          }
        }
      } catch (BadLocationException e) {
      } catch (ParseException e) {
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    IDocument document = viewer.getDocument();
    try {       
      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);
      }
     
      ITypedRegion previousPartition = document.getPartition(offset - 1);
     
      // check if tml comment partition is open
      String content = document.get(region.getOffset(), region.getLength());
      if (!content.trim().endsWith("</tml:comment>") && (content.trim().startsWith("<tml:comment>") || previousPartition.getType().equals(TMLPartitionScanner.TML_COMMENT))) {       
        String replacement = "</tml:comment>";
        String alreadyTyped = document.get(region.getOffset(), offset-region.getOffset());
        if (alreadyTyped.contains("\n")) {
          alreadyTyped = alreadyTyped.substring(alreadyTyped.lastIndexOf("\n"));
        }
        int completionStartPos = -1;
        if (alreadyTyped.indexOf(">") == -1) {
View Full Code Here

Examples of org.eclipse.jface.text.IRegion

          // check if design db attribute is missing
          // we can only lookup references in local sources
          if (!tmlInfo.hasAttribute("designdb") && !tmlInfo.isDynamicAttributeValue("medium")) {
            int offset = tmlInfo.getDocumentRegion().getOffset() + "<tml:[".length();
            int length = tmlInfo.getTagName().length() - 2;
            IRegion referenceRegion = new Region(offset, length);
            link = new TMLModuleReferenceHyperlink(textViewer, referenceRegion, tmlInfo);
          }
        }

       
View Full Code Here

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

Examples of org.eclipse.jface.text.IRegion

  }



  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

Examples of org.eclipse.jface.text.IRegion

      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

Examples of org.eclipse.jface.text.IRegion

          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

Examples of org.eclipse.jface.text.IRegion

  }
 
  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
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.