Java 类com.intellij.lang.properties.PropertiesFileType 实例源码

项目:IntelliJ_Jahia_plugin    文件:CndTranslationUtil.java   
public static String getNodeTypeTranslation(Project project, String namespace, String nodeTypeName) {
    Collection<VirtualFile> virtualFiles = CndProjectFilesUtil.findFilesInSourcesOnly(project, PropertiesFileType.INSTANCE);

    String key = convertNodeTypeIdentifierToPropertyName(namespace, nodeTypeName);
    PsiManager psiManager = PsiManager.getInstance(project);
    for (VirtualFile virtualFile : virtualFiles) {
        PropertiesFile propertiesFile = (PropertiesFile) psiManager.findFile(virtualFile);
        if (propertiesFile != null) {
            IProperty property = propertiesFile.findPropertyByKey(key);
            if (property != null) {
                return property.getValue();
            }
        }
    }
    return null;
}
项目:intellij-ce-playground    文件:PropertiesElementFactory.java   
@NotNull
public static PropertiesFile createPropertiesFile(@NotNull Project project, Properties properties, String fileName) {
  ByteArrayOutputStream stream = new ByteArrayOutputStream();
  try {
    properties.store(stream, "");
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
  @NonNls String filename = fileName + "." + PropertiesFileType.INSTANCE.getDefaultExtension();
  return (PropertiesFile)PsiFileFactory.getInstance(project)
    .createFileFromText(filename, PropertiesFileType.INSTANCE, stream.toString());
}
项目:intellij-ce-playground    文件:ResourceBundleFileReference.java   
public PsiElement handleElementRename(final String newElementName) {
  return handleFileRename(newElementName, PropertiesFileType.DOT_DEFAULT_EXTENSION, false);
}
项目:intellij-ce-playground    文件:PropertiesElementFactory.java   
@NotNull
public static PropertiesFile createPropertiesFile(@NotNull Project project, @NonNls @NotNull String text) {
  @NonNls String filename = "dummy." + PropertiesFileType.INSTANCE.getDefaultExtension();
  return (PropertiesFile)PsiFileFactory.getInstance(project)
    .createFileFromText(filename, PropertiesFileType.INSTANCE, text);
}
项目:intellij-ce-playground    文件:DGMFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
  ExactFileNameMatcher matcher = new ExactFileNameMatcher(GroovyExtensionProvider.ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE,
                                                          !SystemInfo.isFileSystemCaseSensitive);
  consumer.consume(PropertiesFileType.INSTANCE, matcher);
}
项目:tools-idea    文件:ResourceBundleFileReference.java   
public PsiElement handleElementRename(final String newElementName) {
  return handleFileRename(newElementName, PropertiesFileType.DOT_DEFAULT_EXTENSION, false);
}
项目:tools-idea    文件:DGMFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
  ExactFileNameMatcher matcher = new ExactFileNameMatcher(GroovyExtensionProvider.ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE,
                                                          !SystemInfo.isFileSystemCaseSensitive);
  consumer.consume(PropertiesFileType.INSTANCE, matcher);
}
项目:consulo-ui-designer    文件:ResourceBundleFileReference.java   
public PsiElement handleElementRename(final String newElementName) {
  return handleFileRename(newElementName, PropertiesFileType.DOT_DEFAULT_EXTENSION, false);
}
项目:consulo-apache-ant    文件:CustomAntElementsRegistry.java   
private void defineCustomElementsFromResources(AntDomTypeDef typedef, final String uri, AntDomProject antProject, ClassLoader loader) {
  final XmlElement xmlElement = antProject.getXmlElement();
  final Project project = xmlElement != null? xmlElement.getProject() : null;
  if (project == null) {
    return;
  }
  XmlFile xmlFile = null;
  PropertiesFile propFile = null;

  final String resource = typedef.getResource().getStringValue();
  if (resource != null) {
    if (loader == null) {
      loader = getClassLoader(typedef, antProject);
    }
    final InputStream stream = loader.getResourceAsStream(resource);
    if (stream != null) {
      try {
        if (isXmlFormat(typedef, resource)) {
          xmlFile = (XmlFile)loadContentAsFile(project, stream, XmlFileType.INSTANCE);
        }
        else {
          propFile = (PropertiesFile)loadContentAsFile(project, stream, PropertiesFileType.INSTANCE);
        }
      }
      catch (IOException e) {
        LOG.info(e);
      }
    }
    else {
      myTypeDefErrors.put(typedef, "Resource \"" + resource + "\" not found in the classpath");
    }
  }
  else {
    final PsiFileSystemItem file = typedef.getFile().getValue();
    if (file instanceof PsiFile) {
      if (isXmlFormat(typedef, file.getName())) {
        xmlFile = file instanceof XmlFile ? (XmlFile)file : (XmlFile)loadContentAsFile((PsiFile)file, XmlFileType.INSTANCE);
      }
      else { // assume properties format
        propFile = file instanceof PropertiesFile ? (PropertiesFile)file : (PropertiesFile)loadContentAsFile((PsiFile)file, PropertiesFileType.INSTANCE);
      }
    }
  }

  if (propFile != null) {
    if (loader == null) { // if not initialized yet
      loader = getClassLoader(typedef, antProject);
    }
    for (final IProperty property : propFile.getProperties()) {
      addCustomDefinition(typedef, property.getUnescapedKey(), uri, ClassProvider.create(property.getValue(), loader));
    }
  }

  if (xmlFile != null) {
    if (loader == null) { // if not initialized yet
      loader = getClassLoader(typedef, antProject);
    }
    loadDefinitionsFromAntlib(xmlFile, uri, loader, typedef, antProject);
  }
}