Package org.eclipse.jface.text.presentation

Examples of org.eclipse.jface.text.presentation.IPresentationRepairer


   */
  protected void setDocumentToRepairers(IDocument document) {
    if (fRepairers != null) {
      Iterator e= fRepairers.values().iterator();
      while (e.hasNext()) {
        IPresentationRepairer repairer= (IPresentationRepairer) e.next();
        repairer.setDocument(document);
      }
    }
  }
View Full Code Here


      TextPresentation presentation= new TextPresentation(damage, 1000);

      ITypedRegion[] partitions= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), validLength, false);
      for (int i= 0; i < partitions.length; i++) {
        ITypedRegion r= partitions[i];
        IPresentationRepairer repairer= getRepairer(r.getType());
        if (repairer != null)
          repairer.createPresentation(presentation, r);
      }

      return presentation;

    } catch (BadLocationException x) {
View Full Code Here

      PresentationReconciler reconciler, String contentType) {
   
    IPresentationDamager d = new ClojureTopLevelFormsDamager(editor);
    reconciler.setDamager(d, contentType);
   
    IPresentationRepairer r = new DefaultDamagerRepairer(tokenScanner);
    reconciler.setRepairer(r, contentType);

  }
View Full Code Here

              jumpto = getFollowingCSS(partitions, i, r.getType());
              r = new SimpleStructuredTypedRegion(r.getOffset(),
                  partitions[jumpto].getOffset()
                      + partitions[jumpto].getLength()
                      - r.getOffset(), r.getType());
              IPresentationRepairer repairer = getRepairer(r
                  .getType());
              if (repairer != null) {
                TextPresentation presentation = new TextPresentation(
                    damage, 1000);
                repairer.createPresentation(presentation, r);
                for (Iterator iterator = presentation
                    .getAllStyleRangeIterator(); iterator
                    .hasNext();) {
                  StyleRange styleRange = (StyleRange) iterator
                      .next();
                  // the styleRange's scope may be out of
                  // the
                  // region see
                  // https://bugs.eclipse.org/bugs/attachment.cgi?id=179715
                  if (styleRange.start < r.getOffset()
                      || (styleRange.start
                          + styleRange.length > r
                          .getOffset()
                          + r.getLength())) {
                    continue;
                  }

                  for (int j = i + 1; j < jumpto; j = j + 2) {
                    ITypedRegion typedRegion = partitions[j];
                    if (styleRange.start < typedRegion
                        .getOffset()
                        && styleRange.start
                            + styleRange.length > typedRegion
                            .getOffset()
                            + typedRegion
                                .getLength()) {
                      int end = styleRange.start
                          + styleRange.length;
                      styleRange.length = typedRegion
                          .getOffset()
                          - styleRange.start;
                      fRangeSet.add(styleRange);
                      styleRange = new StyleRange(
                          typedRegion.getOffset()
                              + typedRegion
                                  .getLength(),
                          end
                              - (typedRegion
                                  .getOffset() + typedRegion
                                  .getLength()),
                          styleRange.foreground,
                          styleRange.background,
                          styleRange.fontStyle);
                    } else if (styleRange.start < typedRegion
                        .getOffset()
                        && styleRange.start
                            + styleRange.length > typedRegion
                              .getOffset()) {
                      styleRange.length = typedRegion
                          .getOffset()
                          - styleRange.start;
                      break;
                    } else if (styleRange.start >= typedRegion
                        .getOffset()
                        && styleRange.start
                            + styleRange.length <= typedRegion
                            .getOffset()
                            + typedRegion
                                .getLength()) {
                      styleRange = null;
                      break;
                    } else if (styleRange.start > typedRegion
                        .getOffset()
                        && styleRange.start < typedRegion
                            .getOffset()
                            + typedRegion
                                .getLength()
                        && styleRange.start
                            + styleRange.length > typedRegion
                            .getOffset()
                            + typedRegion
                                .getLength()) {
                      styleRange.length = styleRange.start
                          + styleRange.length
                          - (typedRegion.getOffset() + typedRegion
                              .getLength());
                      styleRange.start = typedRegion
                          .getOffset()
                          + typedRegion.getLength();

                    } else if (styleRange.start
                        + styleRange.length < typedRegion
                          .getOffset()) {
                      break;
                    }
                  }
                  if (styleRange != null) {
                    fRangeSet.add(styleRange);
                  }
                }
              }
            }

          } else {
            if (i > jumpto
                || i < jumpto
                && !r.getType().equals(
                    partitions[jumpto].getType())) {// jumpto
                                    // partition
                                    // has
                                    // been
                                    // added
              IPresentationRepairer repairer = getRepairer(r
                  .getType());
              if (repairer != null) {
                TextPresentation presentation = new TextPresentation(
                    damage, 1000);
                repairer.createPresentation(presentation, r);
                for (Iterator iterator = presentation
                    .getAllStyleRangeIterator(); iterator
                    .hasNext();) {
                  StyleRange styleRange = (StyleRange) iterator
                      .next();
                  fRangeSet.add(styleRange);
                }
              }
            }

          }
        }
        if (fRangeSet.isEmpty()) {
          return null;
        }
        Collections.sort(fRangeSet, new Comparator<StyleRange>() {

          public int compare(StyleRange o1, StyleRange o2) {
            return o1.start - o2.start;
          }

        });
        List<StyleRange> fRanges = new ArrayList<StyleRange>();
        StyleRange[] rangeArray = fRangeSet
            .toArray(new StyleRange[fRangeSet.size()]);
        StyleRange lastRange = rangeArray[0];
        fRanges.add(lastRange);
        for (int i = 1; i < rangeArray.length; i++) {
          StyleRange styleRange = rangeArray[i];
          // do not add duplicate ranges
          if (styleRange.start == lastRange.start
              && styleRange.length == lastRange.length) {
            continue;
          } else {
            fRanges.add(styleRange);
            lastRange = styleRange;
          }
        }
        TextPresentation presentation = new TextPresentation(damage,
            1000);
        presentation = new TextPresentation(damage, fRanges.size());
        for (Iterator iterator = fRanges.iterator(); iterator.hasNext();) {
          StyleRange styleRange = (StyleRange) iterator.next();
          if (styleRange.start + styleRange.length <= damage
              .getOffset()) {
            continue;
          } else if (styleRange.start <= damage.getOffset()
              && styleRange.start + styleRange.length > damage
                  .getOffset()
              && styleRange.start + styleRange.length <= damage
                  .getOffset() + validLength) {
            int rangeEnd = styleRange.start + styleRange.length;
            styleRange.start = damage.getOffset();
            styleRange.length = rangeEnd - damage.getOffset();
            addStyleRange(presentation, styleRange);
          } else if (styleRange.start >= damage.getOffset()
              && styleRange.start < damage.getOffset()
                  + validLength
              && styleRange.start + styleRange.length > damage
                  .getOffset() + validLength) {
            styleRange.length = damage.getOffset() + validLength
                - styleRange.start;
            addStyleRange(presentation, styleRange);
          } else if (styleRange.start >= damage.getOffset()
              && styleRange.start + styleRange.length <= damage
                  .getOffset() + validLength) {
            addStyleRange(presentation, styleRange);
          }

        }
        return presentation;
      } else {
        TextPresentation presentation = new TextPresentation(damage,
            1000);

        List<ITypedRegion> damagedPartitions = findDamagedPartitions(
            partitions, damage);

        // performance optimisation: if only PHPScriptRegion has been
        // damaged and not fully reparsed we can try to create
        // presentation for updated tokens only.
        if (damagedPartitions.size() == 1) {
          ITypedRegion r = damagedPartitions.get(0);
          IPresentationRepairer repairer = getRepairer(damagedPartitions
              .get(0).getType());
          if (repairer != null) {
            if (r.getType().equals(PHPPartitionTypes.PHP_DEFAULT)) {
              if (repairer instanceof StructuredDocumentDamagerRepairer) {
                TextPresentation newPresentation = ((StructuredDocumentDamagerRepairer) repairer)
                    .getPresentation(r, damage);
                if (newPresentation != null) {
                  presentation = newPresentation;
                }
              }
            }
            repairer.createPresentation(presentation, r);
          }
        } else {
          for (int i = 0; i < damagedPartitions.size(); i++) {
            ITypedRegion r = damagedPartitions.get(i);
            IPresentationRepairer repairer = getRepairer(r
                .getType());
            if (repairer != null)
              repairer.createPresentation(presentation, r);
          }
        }

        // OLD CODE
        // for (int i = 0; i < partitions.length; i++) {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.presentation.IPresentationRepairer

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.