Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion


              }
            }
          }
        }
        if (!designDBReferenceFound) {
          IRegion designDBValueRegion;
          try {
            designDBValueRegion = tmlInfo.getAttributeValueRegion("designdb");
            charStart = designDBValueRegion.getOffset();
            charEnd = charStart + designDBValueRegion.getLength();
          } catch (BadLocationException e) {
            // ignore just mark the whole line
          }
          MarkerFactory.createErrorMarker(getMarkerID(), file, charStart, charEnd, "Unsatisfied design db reference '" + designDBValue + "'.");
        }
View Full Code Here


          // check if labelfile exists
          try {
            IFile labelFile = designHelper.getLabelFile(labelFilename);
            if (labelFile == null || !labelFile.exists()) {
              try {             
                IRegion attributeRegion = tmlInfo.getAttributeValueRegion("file");
                if (attributeRegion != null) {
                  charStart = attributeRegion.getOffset();
                  charEnd = charStart + attributeRegion.getLength();
                }
              } catch (BadLocationException e) {
              }
             
              MarkerFactory.createErrorMarker(getMarkerID(), file, charStart, charEnd, "Labelfile '" + labelFilename + "' does not exist.", markerAttributes);
            }
          } catch (CoreException e1) {
          }
        }
       
        Set<String> labelKeys = designHelper.getLabelKeys(labelFilename);
   
        if (!labelKeys.contains(labelKey)) {
          try {
            IRegion attributeRegion = tmlInfo.getAttributeValueRegion("key");
            if (attributeRegion != null) {
              charStart = attributeRegion.getOffset();
              charEnd = charStart + attributeRegion.getLength();
            }
          } catch (BadLocationException e) {
          }
          if (labelFilename.equalsIgnoreCase("general")) {
            MarkerFactory.createWarningMarker(getMarkerID(), file, charStart, charEnd, "Cannot resolve label for key '" + labelKey + "'.", markerAttributes);
View Full Code Here

  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {   
    setErrorMessage(null);
    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();   
    try {
      IDocument document = viewer.getDocument();
      IRegion region = TMLContentAssistProcessor.determineRelatedRegion(offset, document);
      if (isOpenPartition(region, document, "<tml:comment>", "</tml:comment>", TMLPartitionScanner.TML_COMMENT)) {
        proposals.addAll(computeCompletionPropsals(document, region, offset, "<tml:comment>", "</tml:comment>"));
      } else if (isOpenPartition(region, document, "<tml:disable>", "</tml:disable>", TMLPartitionScanner.TML_DISABLE)) {
        proposals.addAll(computeCompletionPropsals(document, region, offset, "<tml:disable>", "</tml:disable>"));
      } else {       
View Full Code Here

      referencedFile = WGADesignStructureHelper.findReferencedScript(file, ref, WGADesignStructureHelper.SCRIPT_TYPE_TMLSCRIPT);
      referenceType = REFERENCE_TYPE_SCRIPT;
      referencePath = WGADesignStructureHelper.computeScriptReferencePath(file, ref, WGADesignStructureHelper.SCRIPT_TYPE_TMLSCRIPT);
     
      if (referencedFile == null && referenceType != null) {
        IRegion region;
        try {             
          region = tmlInfo.getAttributeValueRegion(attributeName);
          if (region != null) {
            charStart = region.getOffset();
            charEnd = charStart + region.getLength();
          }
        } catch (BadLocationException e) {
        }         
       
        Map<String, Object> attributes = new HashMap<String, Object>();
View Full Code Here

        referencedFile = WGADesignStructureHelper.findReferencedTMLModule(file, ref, medium);
        referenceType = REFERENCE_TYPE_TML;           
        referencePath = new WGADesignStructureHelper(file).computeTMLModuleReferencePath(file, ref, medium);
      }
      if (referencedFile == null && referenceType != null) {
        IRegion region;
        try {             
          region = tmlInfo.getAttributeValueRegion("name");
          if (region != null) {
            charStart = region.getOffset();
            charEnd = charStart + region.getLength();
          }
        } catch (BadLocationException e) {
        }         
       
        Map<String, Object> attributes = new HashMap<String, Object>();
View Full Code Here

    _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

    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

        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

  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

          // 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

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.