Java 类com.intellij.util.xml.GenericDomValue 实例源码

项目:intellij-ce-playground    文件:AbstractMethodResolveConverter.java   
public static String getReferenceCanonicalText(final String name, @Nullable final AbstractMethodParams methodParams) {
  StringBuilder sb = new StringBuilder(name);
  if (methodParams == null) {
    sb.append("()");
  }
  else if (methodParams.getXmlTag() != null) {
    sb.append("(");
    final List<GenericDomValue<PsiType>> list = methodParams.getMethodParams();
    boolean first = true;
    for (GenericDomValue<PsiType> value : list) {
      if (first) first = false;
      else sb.append(", ");
      sb.append(value.getStringValue());
    }
    sb.append(")");
  }
  return sb.toString();
}
项目:intellij-ce-playground    文件:BasicDomElementsInspection.java   
/**
 * The default implementations checks for resolve problems (if {@link #shouldCheckResolveProblems(com.intellij.util.xml.GenericDomValue)}
 * returns true), then runs annotators (see {@link com.intellij.util.xml.DomFileDescription#createAnnotator()}),
 * checks for {@link com.intellij.util.xml.Required} and {@link com.intellij.util.xml.ExtendClass} annotation
 * problems, checks for name identity (see {@link com.intellij.util.xml.NameValue} annotation) and custom annotation
 * checkers (see {@link com.intellij.util.xml.highlighting.DomCustomAnnotationChecker}).
 *
 * @param element element to check
 * @param holder  a place to add problems to
 * @param helper  helper object
 */
@Override
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  final int oldSize = holder.getSize();
  if (element instanceof GenericDomValue) {
    final GenericDomValue genericDomValue = (GenericDomValue) element;
    if (shouldCheckResolveProblems(genericDomValue)) {
      helper.checkResolveProblems(genericDomValue, holder);
    }
  }
  for (final Class<? extends T> aClass : getDomClasses()) {
    helper.runAnnotators(element, holder, aClass);
  }
  if (oldSize != holder.getSize()) return;

  if (!helper.checkRequired(element, holder).isEmpty()) return;
  if (!(element instanceof GenericAttributeValue) && !GenericDomValue.class.equals(ReflectionUtil.getRawType(element.getDomElementType()))) {
    if (!helper.checkNameIdentity(element, holder).isEmpty()) return;
  }

  helper.checkCustomAnnotations(element, holder);
}
项目:intellij-ce-playground    文件:MavenRepositoryConverter.java   
@NotNull
@Override
public PsiReference[] createReferences(GenericDomValue value, final PsiElement element, final ConvertContext context) {
  return new PsiReference[]{new WebReference(element) {
    @NotNull
    @Override
    public Object[] getVariants() {
      Module module = context.getModule();

      if (module != null) {
        String name = MavenRepositoriesProvider.getInstance().getRepositoryUrl(getRepositoryId(context));
        if (!StringUtil.isEmptyOrSpaces(name)) return new Object[]{name};
      }
      return super.getVariants();
    }
  }};
}
项目:intellij-ce-playground    文件:StyleItemConverter.java   
@Override
public Converter getConverter(@NotNull GenericDomValue element) {
  StyleItem item = (StyleItem)element;
  String name = item.getName().getValue();
  if (name != null) {
    String[] strs = name.split(":");
    if (strs.length == 1 || strs.length == 2) {
      AndroidFacet facet = AndroidFacet.getInstance(element);
      if (facet != null) {
        String namespacePrefix = strs.length == 2 ? strs[0] : null;
        String localName = strs[strs.length - 1];
        return findConverterForAttribute(namespacePrefix, localName, facet, element);
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:GenericDomValueConvertersRegistry.java   
public void registerConverter(@NotNull Converter<?> provider, @NotNull Class type) {
  final String name = type.getCanonicalName();
  registerConverter(provider, new Condition<Pair<PsiType, GenericDomValue>>() {
    public boolean value(final Pair<PsiType, GenericDomValue> pair) {
      return pair.first != null && Comparing.equal(name, pair.first.getCanonicalText());
    }
  });
}
项目:intellij-ce-playground    文件:AntDomDeclarationSearcher.java   
protected DomTarget createDomTarget(DomElement parent, DomElement nameElement) {
  if (parent instanceof AntDomElement && nameElement.equals(((AntDomElement)parent).getId())) { // id attrib is defined
    return DomTarget.getTarget(parent, (GenericDomValue)nameElement);
  }
  if (parent instanceof AntDomProperty && nameElement.equals(((AntDomProperty)parent).getEnvironment())) { // environment attrib is defined
    return DomTarget.getTarget(parent, (GenericDomValue)nameElement);
  }
  return null;
}
项目:intellij-ce-playground    文件:GenericDomValuePattern.java   
protected GenericDomValuePattern(final Class<T> aClass) {
  super(new InitialPatternCondition(aClass) {
    @Override
    public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
      return o instanceof GenericDomValue && aClass.equals(DomUtil.getGenericValueParameter(((GenericDomValue)o).getDomElementType()));
    }

  });
}
项目:intellij-ce-playground    文件:DomUIFactory.java   
@NotNull
private static BaseControl createGenericValueControl(final Type type, final GenericDomValue<?> element, boolean commitOnEveryChange) {
  final DomStringWrapper stringWrapper = new DomStringWrapper(element);
  final Class rawType = ReflectionUtil.getRawType(type);
  if (type instanceof Class && Enum.class.isAssignableFrom(rawType)) {
    return new ComboControl(stringWrapper, rawType);
  }
  if (DomElement.class.isAssignableFrom(rawType)) {
    final ComboControl control = new ComboControl(element);
    final Required annotation = element.getAnnotation(Required.class);
    if (annotation == null || !annotation.value() || !annotation.nonEmpty()) {
      control.setNullable(true);
    }
    return control;
  }

  final DomFixedWrapper wrapper = new DomFixedWrapper(element);
  if (type.equals(boolean.class) || type.equals(Boolean.class)) {
    return new BooleanControl(wrapper);
  }
  if (type.equals(String.class)) {
    return getDomUIFactory().createTextControl(wrapper, commitOnEveryChange);
  }

  final BaseControl customControl = getDomUIFactory().createCustomControl(type, stringWrapper, commitOnEveryChange);
  if (customControl != null) return customControl;

  return getDomUIFactory().createTextControl(stringWrapper, commitOnEveryChange);
}
项目:intellij-ce-playground    文件:AntDomPropertyValueConverter.java   
@NotNull public List<Converter> getConverters(@NotNull GenericDomValue domElement) {
  final String raw = domElement.getRawText();
  if (raw != null) {
    if (raw.contains("${") || raw.contains(File.separator) || (File.separatorChar != '/' && raw.contains("/"))) {
      return Collections.<Converter>singletonList(new AntPathConverter());
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:RngDefineMetaData.java   
@Override
@Nullable
protected GenericDomValue getNameElement(final RngDefine element) {
  final GenericAttributeValue<String> id = element.getNameAttr();
  if (id.getXmlElement() != null) {
    return id;
  }
  return null;
}
项目:intellij-ce-playground    文件:ParentStyleConverter.java   
@NotNull
@Override
public PsiReference[] createReferences(GenericDomValue<ResourceValue> value, PsiElement element, ConvertContext context) {
  if (element instanceof XmlAttributeValue) {
    // parent="" is allowed; it's used to deliberately allow style A.B.C to not be a child of A.B
    XmlAttributeValue attributeValue = (XmlAttributeValue)element;
    if (attributeValue.isValid() && attributeValue.getValue().isEmpty()) {
      return PsiReference.EMPTY_ARRAY;
    }
  }

  final PsiReference[] refsFromSuper = super.createReferences(value, element, context);

  final ResourceValue resValue = value.getValue();

  if (resValue == null || resValue.getPackage() != null) {
    return refsFromSuper;
  }
  final AndroidFacet facet = AndroidFacet.getInstance(context);

  if (facet != null) {
    final PsiReference[] refs = getReferencesInStyleName(value, facet);

    if (refs.length > 0) {
      return ArrayUtil.mergeArrays(refsFromSuper, refs);
    }
  }
  return refsFromSuper;
}
项目:intellij-ce-playground    文件:MavenModelInspection.java   
private static boolean isElementInsideManagedFile(GenericDomValue value) {
  VirtualFile virtualFile = DomUtil.getFile(value).getVirtualFile();
  if (virtualFile == null) {
    return false;
  }

  MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(value.getManager().getProject());

  return projectsManager.findProject(virtualFile) != null;
}
项目:intellij-ce-playground    文件:OnClickConverter.java   
@NotNull
@Override
public PsiReference[] createReferences(GenericDomValue<String> value, PsiElement element, ConvertContext context) {
  final int length = element.getTextLength();
  if (length > 1) {
    return new PsiReference[]{new MyReference((XmlAttributeValue)element, new TextRange(1, length - 1))};
  }
  return PsiReference.EMPTY_ARRAY;
}
项目:intellij-ce-playground    文件:MetadataValueConverter.java   
@NotNull
@Override
public PsiReference[] createReferences(GenericDomValue value, PsiElement element, ConvertContext context) {
  if (isClassContext(context)) {
    return myPsiClassConverter.createReferences(value, element, context);
  }

  return myResourceReferenceConverter.createReferences(value, element, context);
}
项目:intellij-ce-playground    文件:FormatConverter.java   
@Override
protected Object[] getReferenceVariants(final ConvertContext context, final GenericDomValue<List<AttributeFormat>> value) {
  List<AttributeFormat> variants = new ArrayList<AttributeFormat>();
  Collections.addAll(variants, AttributeFormat.values());
  filterVariants(variants, value);
  String[] stringVariants = new String[variants.size()];
  for (int i = 0, variantsSize = variants.size(); i < variantsSize; i++) {
    stringVariants[i] = StringUtil.decapitalize(variants.get(i).name());
  }
  return stringVariants;
}
项目:intellij-ce-playground    文件:AntDomTargetDependsListConverter.java   
@NotNull
public PsiReference[] createReferences(GenericDomValue<TargetResolver.Result> value, PsiElement element, ConvertContext context) {
  final XmlElement xmlElement = value.getXmlElement();
  if (!(xmlElement instanceof XmlAttribute)) {
    return PsiReference.EMPTY_ARRAY;
  }
  final XmlAttributeValue valueElement = ((XmlAttribute)xmlElement).getValueElement();
  if (valueElement == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final String refsString = value.getStringValue();
  if (refsString == null) {
    return PsiReference.EMPTY_ARRAY;
  }
  final List<PsiReference> refs = new ArrayList<PsiReference>();
  final AntDomTargetReference.ReferenceGroup group = new AntDomTargetReference.ReferenceGroup();
  final TextRange wholeStringRange = ElementManipulators.getValueTextRange(valueElement);
  final StringTokenizer tokenizer = new StringTokenizer(refsString, ",", false);
  while (tokenizer.hasMoreTokens()) {
    final String token = tokenizer.nextToken();
    int tokenStartOffset = tokenizer.getCurrentPosition() - token.length();
    final String ref = token.trim();
    if (ref.length() != token.length()) {
      for (int idx = 0; idx < token.length(); idx++) {
        if (Character.isWhitespace(token.charAt(idx))) {
          tokenStartOffset++;
        }
        else {
          break;
        }
      }
    }
    refs.add(new AntDomTargetReference(element, TextRange.from(wholeStringRange.getStartOffset() + tokenStartOffset, ref.length()), group));
  }
  return refs.toArray(new PsiReference[refs.size()]);
}
项目:intellij-ce-playground    文件:PluginPsiClassConverter.java   
@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue,
                                                                  ConvertContext context,
                                                                  ExtendClass extendClass) {
  final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context, extendClass);
  provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
  provider.setOption(JavaClassReferenceProvider.ALLOW_DOLLAR_NAMES, Boolean.TRUE);
  return provider;
}
项目:intellij-ce-playground    文件:PropertyKeyReferenceProvider.java   
private static List<String> getPluginResourceBundles(PsiElement element) {
  final DomElement domElement = DomUtil.getDomElement(element);
  if (domElement == null) return Collections.emptyList();
  final DomElement rootElement = DomUtil.getFileElement(domElement).getRootElement();
  if (!(rootElement instanceof IdeaPlugin)) return Collections.emptyList();

  IdeaPlugin plugin = (IdeaPlugin)rootElement;
  return ContainerUtil.map(plugin.getResourceBundles(), new Function<GenericDomValue<String>, String>() {
    @Override
    public String fun(GenericDomValue<String> value) {
      return value.getStringValue();
    }
  });
}
项目:intellij-ce-playground    文件:MavenDomRepositoryBase.java   
@NotNull
@Required(value = false, nonEmpty = true)
@Convert(MavenRepositoryLayoutConverter.class)
GenericDomValue<String> getLayout();
项目:intellij-ce-playground    文件:MavenDomRepositoryBase.java   
@NotNull
@Convert(MavenRepositoryConverter.Url.class)
GenericDomValue<String> getUrl();
项目:intellij-ce-playground    文件:MavenDomExtension.java   
@Required(value = false, nonEmpty = true)
GenericDomValue<String> getGroupId();
项目:intellij-ce-playground    文件:ClassValueConverterImpl.java   
@NotNull
public PsiReference[] createReferences(final GenericDomValue genericDomValue, final PsiElement element, final ConvertContext context) {
  return REFERENCE_PROVIDER.getReferencesByElement(element);
}
项目:intellij-ce-playground    文件:DynamicGenericInfo.java   
@Override
public GenericDomValue getNameDomElement(DomElement element) {
  return myStaticGenericInfo.getNameDomElement(element);
}
项目:intellij-ce-playground    文件:GenericDomValuePattern.java   
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
  return o instanceof GenericDomValue;
}
项目:intellij-ce-playground    文件:DomHighlightingHelper.java   
@NotNull
public abstract List<DomElementProblemDescriptor> checkResolveProblems(GenericDomValue element, DomElementAnnotationHolder holder);
项目:intellij-ce-playground    文件:BooleanColumnInfo.java   
@Override
public TableCellEditor getEditor(GenericDomValue<Boolean> value) {
  return new DefaultCellEditor(new JCheckBox());
}
项目:intellij-ce-playground    文件:DomUIFactory.java   
@NotNull
public static DomUIControl<GenericDomValue> createControl(GenericDomValue element, boolean commitOnEveryChange) {
  return createGenericValueControl(DomUtil.getGenericValueParameter(element.getDomElementType()), element, commitOnEveryChange);
}
项目:intellij-ce-playground    文件:DomUIFactory.java   
public static BaseControl createTextControl(GenericDomValue value, final boolean commitOnEveryChange) {
  return getDomUIFactory().createTextControl(new DomStringWrapper(value), commitOnEveryChange);
}
项目:intellij-ce-playground    文件:DomUIFactory.java   
public DomUIControl createCollectionControl(DomElement element, DomCollectionChildDescription description) {
  final ColumnInfo columnInfo = createColumnInfo(description, element);
  final Class aClass = DomUtil.extractParameterClassFromGenericType(description.getType());
  return new DomCollectionControl<GenericDomValue<?>>(element, description, aClass == null, columnInfo);
}
项目:intellij-ce-playground    文件:MavenDomPlugin.java   
@Required(value = false, nonEmpty = true)
GenericDomValue<String> getGroupId();
项目:intellij-ce-playground    文件:CreateDomElementAction.java   
public static void replaceElementValue(TemplateBuilder builder, GenericDomValue element, Expression expression) {
  element.setStringValue("");
  XmlElement xmlElement = element.getXmlElement();
  builder.replaceElement(xmlElement, ElementManipulators.getValueTextRange(xmlElement), expression);
}
项目:intellij-ce-playground    文件:BasicDomElementComponent.java   
protected boolean commitOnEveryChange(GenericDomValue element) {
  return false;
}
项目:intellij-ce-playground    文件:PathReferenceConverter.java   
@Override
@NotNull
public PsiReference[] createReferences(final GenericDomValue genericDomValue, final PsiElement element, final ConvertContext context) {
  return createReferences(element, true);
}
项目:intellij-ce-playground    文件:MavenDomDependency.java   
@Required(value = false, nonEmpty = true)
GenericDomValue<String> getVersion();
项目:intellij-ce-playground    文件:FlagConverter.java   
@Override
protected Object[] getReferenceVariants(final ConvertContext context, final GenericDomValue<List<String>> value) {
  List<String> variants = new ArrayList<String>(myValues);
  filterVariants(variants, value);
  return ArrayUtil.toStringArray(variants);
}
项目:intellij-ce-playground    文件:AppEngineUploader.java   
@Nullable
public static AppEngineUploader createUploader(@NotNull Project project,
                                               @NotNull Artifact artifact,
                                               @NotNull AppEngineServerConfiguration configuration,
                                               @NotNull ServerRuntimeInstance.DeploymentOperationCallback callback, @NotNull LoggingHandler loggingHandler) {
  final String explodedPath = artifact.getOutputPath();
  if (explodedPath == null) {
    callback.errorOccurred("Output path isn't specified for '" + artifact.getName() + "' artifact");
    return null;
  }

  final AppEngineFacet appEngineFacet = AppEngineUtil.findAppEngineFacet(project, artifact);
  if (appEngineFacet == null) {
    callback.errorOccurred("App Engine facet not found in '" + artifact.getName() + "' artifact");
    return null;
  }

  final AppEngineSdk sdk = appEngineFacet.getSdk();
  if (!sdk.getAppCfgFile().exists()) {
    callback.errorOccurred("Path to App Engine SDK isn't specified correctly in App Engine Facet settings");
    return null;
  }

  PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
  VirtualFile descriptorFile = ArtifactUtil.findSourceFileByOutputPath(artifact, "WEB-INF/appengine-web.xml", context);
  final AppEngineWebApp root = AppEngineFacet.getDescriptorRoot(descriptorFile, appEngineFacet.getModule().getProject());
  if (root != null) {
    final GenericDomValue<String> application = root.getApplication();
    if (StringUtil.isEmptyOrSpaces(application.getValue())) {
      final String name = Messages.showInputDialog(project, "<html>Application name is not specified in appengine-web.xml.<br>" +
            "Enter application name (see your <a href=\"http://appengine.google.com\">AppEngine account</a>):</html>", CommonBundle.getErrorTitle(), null, "", null);
      if (name == null) return null;

      final PsiFile file = application.getXmlTag().getContainingFile();
      new WriteCommandAction(project, file) {
        protected void run(@NotNull final Result result) {
          application.setStringValue(name);
        }
      }.execute();
      final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
      if (document != null) {
        FileDocumentManager.getInstance().saveDocument(document);
      }
    }
  }

  AppEngineAuthData authData = AppEngineAccountDialog.createAuthData(project, configuration);
  if (authData == null) return null;

  return new AppEngineUploader(project, artifact, appEngineFacet, sdk, authData, callback, loggingHandler);
}
项目:intellij-ce-playground    文件:MavenDomPlugin.java   
@Required(value = false, nonEmpty = true)
GenericDomValue<String> getVersion();
项目:intellij-ce-playground    文件:MavenDomMirror.java   
@NotNull
@Convert(MavenRepositoryConverter.Url.class)
GenericDomValue<String> getUrl();
项目:intellij-ce-playground    文件:MavenDomParameter.java   
@NotNull
GenericDomValue<Boolean> getEditable();
项目:intellij-ce-playground    文件:MavenDomDistributionManagement.java   
@NotNull
@Required(value = false, nonEmpty = true)
@Convert(MavenDistributionStatusConverter.class)
GenericDomValue<String> getStatus();