Package org.eclipse.xtext.util

Examples of org.eclipse.xtext.util.ITextRegion


             
              for (ruleset r : root.getRuleset()) {
                for (selector s : r.getSelectors()) {
                  for (simple_selector ss : s.getSimpleselectors()) {
                    if (ss.getElement() != null) {
                      ITextRegion declarationRegion = locationInFileProvider.getFullTextRegion(ss.getElement());
                      addOccurrenceAnnotation(DECLARATION_ANNOTATION_TYPE, document, declarationRegion, m);
                    }
                  }
                }
              }
View Full Code Here


                  while (cur != null) {
                    for (simple_selector ss : cur.getSimpleselectors()) {
                      if (ss.getElement() != null) {
                        ElementSelector check = ss.getElement();
                        if (check.getName().equals(((ElementSelector) target).getName())) {
                          ITextRegion declarationRegion = locationInFileProvider.getFullTextRegion(ss.getElement());
                          addOccurrenceAnnotation(DECLARATION_ANNOTATION_TYPE, document, declarationRegion, m);
                        }
                      }
                    }
                    cur = cur.getSelector();
                  }
                }
              }
            }
           
            // ClassSelector:
            if (target instanceof ClassSelector) {
              stylesheet root = (stylesheet) resource.getContents().get(0);
              for (ruleset r : root.getRuleset()) {
                for (selector s : r.getSelectors()) {
                  selector cur = s;
                  while (cur != null) {
                    for (simple_selector ss : cur.getSimpleselectors()) {
                      for (CssSelector subSel : ss.getSubSelectors()) {
                        if (subSel instanceof ClassSelector) {
                          ClassSelector check = (ClassSelector) subSel;
                          if (check.getName() != null) {
                            // TODO i don't get get a ClassSelectors name can be null
                            if (check.getName().equals(((ClassSelector) target).getName())) {
                              ITextRegion declarationRegion = locationInFileProvider.getFullTextRegion(subSel);
                              addOccurrenceAnnotation(DECLARATION_ANNOTATION_TYPE, document, declarationRegion, m);
                            }
                          }
                        }
                      }
                      if (ss.getElement() != null) {
                       
                      }
                    }
                    cur = cur.getSelector();
                  }
                }
              }
            }
            // ClassSelector:
            if (target instanceof IdSelector) {
              stylesheet root = (stylesheet) resource.getContents().get(0);
              for (ruleset r : root.getRuleset()) {
                for (selector s : r.getSelectors()) {
                  selector cur = s;
                  while (cur != null) {
                    for (simple_selector ss : cur.getSimpleselectors()) {
                      for (CssSelector subSel : ss.getSubSelectors()) {
                        if (subSel instanceof IdSelector) {
                          IdSelector check = (IdSelector) subSel;
                          if (check.getName().equals(((IdSelector) target).getName())) {
                            ITextRegion declarationRegion = locationInFileProvider.getFullTextRegion(subSel);
                            addOccurrenceAnnotation(DECLARATION_ANNOTATION_TYPE, document, declarationRegion, m);
                          }
                        }
                      }
                      if (ss.getElement() != null) {
                       
                      }
                    }
                    cur = cur.getSelector();
                  }
                }
              }
            }
           
            // Properties
            if (target instanceof css_property) {
              stylesheet root = (stylesheet) resource.getContents().get(0);
              for (ruleset r : root.getRuleset()) {
                for (css_declaration d : r.getDeclarations()) {
                  if (d.getProperty().getName().equals(((css_property) target).getName())) {
                    ITextRegion declarationRegion = locationInFileProvider.getFullTextRegion(d.getProperty());
                    addOccurrenceAnnotation(DECLARATION_ANNOTATION_TYPE, document, declarationRegion, m);
                  }
                }
              }
            }
View Full Code Here

     
      // This allows us to select only the urls content on doubleclick
      if (o instanceof URLType) {
        final URLType urlType = (URLType) o;
        if (urlType.getUrl() != null) {
          ITextRegion r1 = locationInFileProvider.getFullTextRegion(o, CssDslPackage.Literals.URL_TYPE__URL, 0);
          int mod = 0;
          if (urlType.getUrl().startsWith("\"") || urlType.getUrl().startsWith("'")) {
            mod = 1;
          }
          IRegion r = new Region(r1.getOffset() + mod, r1.getLength() - 2 * mod);
          return Tuples.create(o, r);
        }
      }
      if (o != null) {
        ITextRegion region = locationInFileProvider.getSignificantTextRegion(o);
        final IRegion region2 = new Region(region.getOffset(), region.getLength());
        if (TextUtilities.overlaps(region2, new Region(offset, 0)))
          return Tuples.create(o, region2);
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.util.ITextRegion

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.