Java 类com.intellij.util.xml.reflect.DomExtension 实例源码

项目:intellij-ce-playground    文件:MavenPluginConfigurationDomExtender.java   
private static void registerPluginParameter(boolean isInPluginManagement, DomExtensionsRegistrar r, final ParameterData data, final String parameterName) {
  DomExtension e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);

  if (isCollection(data.parameter)) {
    e.addExtender(new DomExtender() {
      public void registerExtensions(@NotNull DomElement domElement, @NotNull DomExtensionsRegistrar registrar) {
        for (String each : collectPossibleNameForCollectionParameter(parameterName)) {
          DomExtension inner = registrar.registerCollectionChildrenExtension(new XmlName(each), MavenDomConfigurationParameter.class);
          inner.setDeclaringElement(data.parameter);
        }
      }
    });
  }
  else {
    addValueConverter(e, data.parameter);
    if (!isInPluginManagement) {
      addRequiredAnnotation(e, data);
    }
  }

  e.setDeclaringElement(data.parameter);

  data.parameter.getXmlElement().putUserData(PLUGIN_PARAMETER_KEY, data);
}
项目:intellij-ce-playground    文件:MavenPluginConfigurationDomExtender.java   
private static void addRequiredAnnotation(DomExtension e, final ParameterData data) {
  if (Boolean.parseBoolean(data.parameter.getRequired().getStringValue())
      && StringUtil.isEmptyOrSpaces(data.defaultValue)
      && StringUtil.isEmptyOrSpaces(data.expression)) {
    e.addCustomAnnotation(new Required(){
      @Override
      public boolean value() {
        return true;
      }

      @Override
      public boolean nonEmpty() {
        return false;
      }

      @Override
      public boolean identifier() {
        return false;
      }
      public Class<? extends Annotation> annotationType() {
            return Required.class;
      }
    });
  }
}
项目:tools-idea    文件:MavenPluginConfigurationDomExtender.java   
private static void registerPluginParameter(boolean isInPluginManagement, DomExtensionsRegistrar r, final ParameterData data, final String parameterName) {
  DomExtension e = r.registerFixedNumberChildExtension(new XmlName(parameterName), MavenDomConfigurationParameter.class);

  if (isCollection(data.parameter)) {
    e.addExtender(new DomExtender() {
      public void registerExtensions(@NotNull DomElement domElement, @NotNull DomExtensionsRegistrar registrar) {
        for (String each : collectPossibleNameForCollectionParameter(parameterName)) {
          DomExtension inner = registrar.registerCollectionChildrenExtension(new XmlName(each), MavenDomConfigurationParameter.class);
          inner.setDeclaringElement(data.parameter);
        }
      }
    });
  }
  else {
    addValueConverter(e, data.parameter);
    if (!isInPluginManagement) {
      addRequiredAnnotation(e, data);
    }
  }

  e.setDeclaringElement(data.parameter);

  data.parameter.getXmlElement().putUserData(PLUGIN_PARAMETER_KEY, data);
}
项目:tools-idea    文件:MavenPluginConfigurationDomExtender.java   
private static void addRequiredAnnotation(DomExtension e, final ParameterData data) {
  if (Boolean.parseBoolean(data.parameter.getRequired().getStringValue())
      && StringUtil.isEmptyOrSpaces(data.defaultValue)
      && StringUtil.isEmptyOrSpaces(data.expression)) {
    e.addCustomAnnotation(new Required(){
      @Override
      public boolean value() {
        return true;
      }

      @Override
      public boolean nonEmpty() {
        return false;
      }

      @Override
      public boolean identifier() {
        return false;
      }
      public Class<? extends Annotation> annotationType() {
            return Required.class;
      }
    });
  }
}
项目:intellij-ce-playground    文件:AndroidDomExtender.java   
@Override
public void process(@NotNull XmlName attrName, @NotNull DomExtension extension, @NotNull DomElement element) {
  // Mark layout_width and layout_height required - if the context calls for it
  String localName = attrName.getLocalName();
  if (!(ATTR_LAYOUT_WIDTH.equals(localName) || ATTR_LAYOUT_HEIGHT.equals(localName))) {
    return;
  }
  if ((element instanceof LayoutViewElement || element instanceof Fragment) &&
      SdkConstants.NS_RESOURCES.equals(attrName.getNamespaceKey())) {
    XmlElement xmlElement = element.getXmlElement();
    XmlTag tag = xmlElement instanceof XmlTag ? (XmlTag)xmlElement : null;
    String tagName = tag != null ? tag.getName() : null;
    if (!VIEW_MERGE.equals(tagName) &&
        !TABLE_ROW.equals(tagName) &&
        !VIEW_INCLUDE.equals(tagName) &&
        !REQUEST_FOCUS.equals(tagName) &&
        !TAG_LAYOUT.equals(tagName) &&
        !TAG_DATA.equals(tagName) &&
        !TAG_VARIABLE.equals(tagName) &&
        !TAG_IMPORT.equals(tagName) &&
        !TAG.equals(tagName) &&
        (tag == null || tag.getAttribute(ATTR_STYLE) == null)) {
      XmlTag parentTag = tag != null ? tag.getParentTag() : null;
      String parentTagName = parentTag != null ? parentTag.getName() : null;
      if (!TABLE_ROW.equals(parentTagName) &&
          !TABLE_LAYOUT.equals(parentTagName) &&
          !VIEW_MERGE.equals(parentTagName) &&
          !GRID_LAYOUT.equals(parentTagName) &&
          !FQCN_GRID_LAYOUT_V7.equals(parentTagName)) {
        extension.addCustomAnnotation(new MyRequired());
      }
    }
  }
}
项目:intellij-ce-playground    文件:AndroidDomExtender.java   
private static void registerAttribute(@NotNull AttributeDefinition attrDef,
                                      @Nullable String parentStyleableName,
                                      String namespaceKey,
                                      MyCallback callback,
                                      @Nullable MyAttributeProcessor processor,
                                      @NotNull DomElement element) {
  String name = attrDef.getName();
  if (!SdkConstants.NS_RESOURCES.equals(namespaceKey) && name.startsWith(SdkConstants.PREFIX_ANDROID)) {
    // A styleable-definition in the app namespace (user specified or from a library) can include
    // a reference to a platform attribute. In such a case, register it under the android namespace
    // as opposed to the app namespace. See https://code.google.com/p/android/issues/detail?id=171162
    name = name.substring(SdkConstants.PREFIX_ANDROID.length());
    namespaceKey = SdkConstants.NS_RESOURCES;
  }
  XmlName xmlName = new XmlName(name, namespaceKey);
  final DomExtension extension = callback.processAttribute(xmlName, attrDef, parentStyleableName);

  if (extension == null) {
    return;
  }
  Converter converter = AndroidDomUtil.getSpecificConverter(xmlName, element);
  if (converter == null) {
    converter = AndroidDomUtil.getConverter(attrDef);
  }

  if (converter != null) {
    extension.setConverter(converter, mustBeSoft(converter, attrDef.getFormats()));
  }
  if (processor != null) {
    processor.process(xmlName, extension, element);
  }
}
项目:intellij-ce-playground    文件:ExtensionDomExtender.java   
private static void registerExtensionPoint(final DomExtensionsRegistrar registrar,
                                           final ExtensionPoint extensionPoint,
                                           String epPrefix,
                                           @Nullable String pluginId) {
  String epName = extensionPoint.getName().getStringValue();
  if (epName != null && StringUtil.isNotEmpty(pluginId)) epName = pluginId + "." + epName;
  if (epName == null) epName = extensionPoint.getQualifiedName().getStringValue();
  if (epName == null) return;
  if (!epName.startsWith(epPrefix)) return;

  final DomExtension domExtension = registrar.registerCollectionChildrenExtension(new XmlName(epName.substring(epPrefix.length())), Extension.class);
  domExtension.setDeclaringElement(extensionPoint);
  domExtension.addExtender(EXTENSION_EXTENDER);
}
项目:intellij-ce-playground    文件:ExtensionDomExtender.java   
private static void markAsClass(DomExtension extension, String fieldName, @Nullable With withElement) {
  if (withElement != null) {
    final String withClassName = withElement.getImplements().getStringValue();
    extension.addCustomAnnotation(new ExtendClassImpl() {
      @Override
      public String value() {
        return withClassName;
      }
    });
  }
  if (withElement != null || isClassField(fieldName)) {
    extension.setConverter(CLASS_CONVERTER);
  }
}
项目:tools-idea    文件:ExtensionDomExtender.java   
private static void registerExtensionPoint(final DomExtensionsRegistrar registrar,
                                           final ExtensionPoint extensionPoint,
                                           String prefix,
                                           @Nullable String pluginId) {
  String epName = extensionPoint.getName().getStringValue();
  if (epName != null && StringUtil.isNotEmpty(pluginId)) epName = pluginId + "." + epName;
  if (epName == null) epName = extensionPoint.getQualifiedName().getStringValue();
  if (epName == null) return;
  if (!epName.startsWith(prefix)) return;

  final DomExtension domExtension = registrar.registerCollectionChildrenExtension(new XmlName(epName.substring(prefix.length())), Extension.class);
  domExtension.setDeclaringElement(extensionPoint);
  domExtension.addExtender(EXTENSION_EXTENDER);
}
项目:tools-idea    文件:ExtensionDomExtender.java   
private static void markAsClass(DomExtension extension, String fieldName, @Nullable With withElement) {
  if (withElement != null) {
    final String withClassName = withElement.getImplements().getStringValue();
    extension.addCustomAnnotation(new ExtendClassImpl() {
      @Override
      public String value() {
        return withClassName;
      }
    });
  }
  if (isClassField(fieldName) || withElement != null) {
    extension.setConverter(CLASS_CONVERTER);
  }
}
项目:consulo-apache-ant    文件:AntDomExtender.java   
@Nullable
private static DomExtension registerChild(DomExtensionsRegistrar registrar, DomGenericInfo elementInfo, String childName) {
  if (elementInfo.getCollectionChildDescription(childName) == null) { // register if not yet defined statically
    Class<? extends AntDomElement> modelClass = getModelClass(childName);
    if (modelClass == null) {
      modelClass = AntDomElement.class;
    }
    return registrar.registerCollectionChildrenExtension(new XmlName(childName), modelClass);
  }
  return null;
}
项目:intellij-ce-playground    文件:AndroidDomExtender.java   
@Nullable
DomExtension processAttribute(@NotNull XmlName xmlName, @NotNull AttributeDefinition attrDef, @Nullable String parentStyleableName) {
  return null;
}
项目:intellij-ce-playground    文件:MavenPluginConfigurationDomExtender.java   
private static void addValueConverter(DomExtension e, MavenDomParameter parameter) {
  String type = parameter.getType().getStringValue();
  if (!StringUtil.isEmptyOrSpaces(type)) {
    e.setConverter(new MavenPluginCustomParameterValueConverter(type), MavenDomConvertersRegistry.getInstance().isSoft(type));
  }
}
项目:intellij-ce-playground    文件:ExtensionDomExtender.java   
private static void markAsLanguage(DomExtension extension, String fieldName) {
  if ("language".equals(fieldName)) {
    extension.setConverter(LANGUAGE_CONVERTER);
  }
}
项目:tools-idea    文件:MavenPluginConfigurationDomExtender.java   
private static void addValueConverter(DomExtension e, MavenDomParameter parameter) {
  String type = parameter.getType().getStringValue();
  if (!StringUtil.isEmptyOrSpaces(type)) {
    e.setConverter(new MavenPluginCustomParameterValueConverter(type), MavenDomConvertersRegistry.getInstance().isSoft(type));
  }
}
项目:intellij-ce-playground    文件:AndroidDomExtender.java   
void process(@NotNull XmlName attrName, @NotNull DomExtension extension, @NotNull DomElement element);