Package com.intellij.util.text

Examples of com.intellij.util.text.UniqueNameGenerator


  private static BnfListEntry addTokenDefinition(Project project,
                                                 BnfFile bnfFile,
                                                 String tokenName,
                                                 String tokenText,
                                                 Map<String, String> tokenMap) {
    String fixedTokenName = new UniqueNameGenerator(tokenMap.values(), null).generateUniqueName(StringUtil.notNullize(tokenName, "token"));
    String newAttrText = "tokens = [\n    " + fixedTokenName + "=" + StringUtil.notNullize(tokenText, "\"\"") + "\n  ]";
    BnfAttr newAttr = BnfElementFactory.createAttributeFromText(project, newAttrText);
    BnfAttrs attrs = ContainerUtil.getFirstItem(bnfFile.getAttributes());
    BnfAttr tokensAttr = null;
    if (attrs == null) {
View Full Code Here


  }

  public static class ProfileStateSplitter implements StateSplitter {

    public List<Pair<Element, String>> splitState(final Element e) {
      final UniqueNameGenerator generator = new UniqueNameGenerator();
      List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();

      final Element[] elements = JDOMUtil.getElements(e);
      for (Element element : elements) {
        if (element.getName().equals("profiles")) {
          element.detach();

          final Element[] profiles = JDOMUtil.getElements(element);
          for (Element profile : profiles) {
            String profileName = null;

            final Element[] options = JDOMUtil.getElements(profile);
            for (Element option : options) {
              if (option.getName().equals("option") && option.getAttributeValue("name").equals("myName")) {
                profileName = option.getAttributeValue("value");
              }
            }

            assert profileName != null;

            final String name = generator.generateUniqueName(FileUtil.sanitizeFileName(profileName)) + ".xml";
            result.add(new Pair<Element, String>(profile,  name));
          }
        }
      }


      result.add(new Pair<Element, String>(e, generator.generateUniqueName("profiles_settings") + ".xml"));

      return result;
    }
View Full Code Here

TOP

Related Classes of com.intellij.util.text.UniqueNameGenerator

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.