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

项目:intellij-ce-playground    文件:MavenPropertyPsiReference.java   
@Nullable
private PsiElement resolveToCustomSystemProperty(@NotNull String propertyName, @Nullable String propertyValue) {
  if (propertyValue == null) return null;

  PsiFile propFile = PsiFileFactory.getInstance(myProject).createFileFromText("SystemProperties.properties", PropertiesLanguage.INSTANCE,
                                                                              propertyName + '=' + propertyValue);

  return ((PropertiesFile)propFile).getProperties().get(0).getPsiElement();
}
项目:tools-idea    文件:MavenPropertyPsiReference.java   
@Nullable
private PsiElement resolveToCustomSystemProperty(@NotNull String propertyName, @Nullable String propertyValue) {
  if (propertyValue == null) return null;

  PsiFile propFile = PsiFileFactory.getInstance(myProject).createFileFromText("SystemProperties.properties", PropertiesLanguage.INSTANCE,
                                                                              propertyName + '=' + propertyValue);

  return ((PropertiesFile)propFile).getProperties().get(0).getPsiElement();
}
项目:consulo-apache-velocity    文件:DefineVelocityPropertiesRefIntention.java   
protected void prepareTemplate(@NotNull Template template,
                               @NotNull final PsiElement element,
                               String relativePath,
                               @NotNull final PsiFile fileToInsertComment) {
  final List<String> allFiles = Util.collectFilePaths(element, new Function<PsiFile, String>() {
    public String fun(@NotNull final PsiFile psiFile) {
      PsiFile file = psiFile.getViewProvider().getPsi(PropertiesLanguage.INSTANCE);
      if (!(file instanceof PropertiesFile)) {
        return null;
      }
      final VelocityPropertiesProvider propertiesProvider = new VelocityPropertiesProvider((PropertiesFile)file);
      List<PsiFile> macroLibs = collectReferencedLibFiles(ModuleUtil.findModuleForPsiElement(element), propertiesProvider);

      for (PsiFile macroLib : macroLibs) {
        if (!(macroLib instanceof VtlFile) ||
            ((VtlFile)macroLib).getNumberOfMacros(((VtlReferenceExpression)element).getReferenceName()) <= 0) {
          continue;
        }
        VirtualFile vFile = macroLib.getViewProvider().getVirtualFile();
        String res = Util.computeFilePath(propertiesProvider, vFile.getPath(), vFile.getName(), fileToInsertComment);
        if(res != null) return res;
      }
      return null;
    }
  });

  template.addTextSegment("#* @velocityproperties path=");
  final Expression pathExpression = new StringCollectionExpression(allFiles);
  template.addVariable("PATH", pathExpression, pathExpression, true);
  final String fileRef = relativePath != null ? " file=\"" + relativePath + "\"" : "";
  template.addTextSegment(fileRef + " *#\n");
  template.addEndVariable();
}
项目:consulo-apache-velocity    文件:DefineVelocityPropertiesRefForFilesIntention.java   
private static List<String> computeFilePaths(final PsiElement element, final PsiFile fileToInsertComment) {
  final VtlFileReferenceSet refSet = findVtlFileReferenceSet(element);
  if (refSet == null) {
    return Collections.emptyList();
  }
  final PsiFile[] referencedFiles =
      findReferencedFiles(ModuleUtil.findModuleForPsiElement(element), refSet.getLastReference().getCanonicalText());

  if (referencedFiles.length == 0) {
    return Collections.emptyList();
  }

  return collectFilePaths(element, new Function<PsiFile, String>() {
    public String fun(@NotNull final PsiFile psiFile) {
      PsiFile file = psiFile.getViewProvider().getPsi(PropertiesLanguage.INSTANCE);
      if (file instanceof PropertiesFile) {
        PropertiesFile propFile = (PropertiesFile)file;
        VelocityPropertiesProvider velocityProperties = new VelocityPropertiesProvider(propFile);
        for (PsiFile referencedFile : referencedFiles) {
          String referencedFilePath = referencedFile.getViewProvider().getVirtualFile().getPath();
          String filePath = computeFilePath(velocityProperties, referencedFilePath, refSet.getPathString(), fileToInsertComment);
          if (filePath != null) return filePath;
        }
      }
      return null;
    }
  });
}
项目:intellij-spring-assistant    文件:PropertiesCompletionContributor.java   
public PropertiesCompletionContributor() {
  extend(CompletionType.BASIC,
      PlatformPatterns.psiElement().withLanguage(PropertiesLanguage.INSTANCE),
      new PropertiesCompletionProvider());
}
项目:intellij-ce-playground    文件:PropertiesStubElementImpl.java   
@NotNull
public Language getLanguage() {
  return PropertiesLanguage.INSTANCE;
}
项目:intellij-ce-playground    文件:PropertiesCodeStyleSettings.java   
public PropertiesCodeStyleSettings(CodeStyleSettings container) {
  super(PropertiesLanguage.INSTANCE.getID(), container);
}
项目:intellij-ce-playground    文件:PropertiesCodeStyleSettingsProvider.java   
@Nullable
@Override
public String getConfigurableDisplayName() {
  return PropertiesLanguage.INSTANCE.getDisplayName();
}
项目:intellij-ce-playground    文件:PropertiesElementType.java   
public PropertiesElementType(@NonNls String debugName) {
  super(debugName, PropertiesLanguage.INSTANCE);
}
项目:tools-idea    文件:PropertiesSeparatorManager.java   
private static String guessSeparator(final Project project, final VirtualFile file) {
  Collection<PropertiesFile> files;
  if (file instanceof ResourceBundleAsVirtualFile) {
    files = ((ResourceBundleAsVirtualFile)file).getResourceBundle().getPropertiesFiles(project);
  }
  else {
    PsiManager psiManager = PsiManager.getInstance(project);
    final FileViewProvider provider = psiManager.findViewProvider(file);
    files = new SmartList<PropertiesFile>();
    if (provider != null) {
      ContainerUtil.addIfNotNull((PropertiesFile)provider.getPsi(PropertiesLanguage.INSTANCE), files);
    }
  }
  final TIntLongHashMap charCounts = new TIntLongHashMap();
  for (PropertiesFile propertiesFile : files) {
    if (propertiesFile == null) continue;
    List<IProperty> properties = propertiesFile.getProperties();
    for (IProperty property : properties) {
      String key = property.getUnescapedKey();
      if (key == null) continue;
      for (int i =0; i<key.length(); i++) {
        char c = key.charAt(i);
        if (!Character.isLetterOrDigit(c)) {
          charCounts.put(c, charCounts.get(c) + 1);
        }
      }
    }
  }

  final char[] mostProbableChar = new char[]{'.'};
  charCounts.forEachKey(new TIntProcedure() {
    long count = -1;
    public boolean execute(int ch) {
      long charCount = charCounts.get(ch);
      if (charCount > count) {
        count = charCount;
        mostProbableChar[0] = (char)ch;
      }
      return true;
    }
  });
  if (mostProbableChar[0] == 0) {
    mostProbableChar[0] = '.';
  }
  return Character.toString(mostProbableChar[0]);
}
项目:tools-idea    文件:PropertiesFileImpl.java   
public PropertiesFileImpl(FileViewProvider viewProvider) {
  super(viewProvider, PropertiesLanguage.INSTANCE);
}
项目:consulo-play    文件:PlayJavaConfFileType.java   
private PlayJavaConfFileType()
{
    super(PropertiesLanguage.INSTANCE);
}