当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesFile.getProperties方法代码示例

本文整理汇总了Java中com.intellij.lang.properties.psi.PropertiesFile.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesFile.getProperties方法的具体用法?Java PropertiesFile.getProperties怎么用?Java PropertiesFile.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.properties.psi.PropertiesFile的用法示例。


在下文中一共展示了PropertiesFile.getProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLocalProperties

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testLocalProperties() {
  VirtualFile vFile = myFixture.copyFileToProject("test.properties", "local.properties");
  PsiFile file = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(file);
  PropertiesFile propertiesFile = (PropertiesFile)file;
  GradleImplicitPropertyUsageProvider provider = new GradleImplicitPropertyUsageProvider();
  for (IProperty property : propertiesFile.getProperties()) {
    Property p = (Property)property;
    // Only but the property with "unused" in its name are considered used
    String name = property.getName();
    if (name.contains("unused")) {
      assertFalse(name, provider.isUsed(p));
    } else {
      assertTrue(name, provider.isUsed(p));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GradleImplicitPropertyUsageProviderTest.java

示例2: getExistingValueKeys

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@NotNull
protected List<String> getExistingValueKeys(String value) {
  if(!myCustomization.suggestExistingProperties) {
    return Collections.emptyList();
  }
  final ArrayList<String> result = new ArrayList<String>();

  // check if property value already exists among properties file values and suggest corresponding key
  PropertiesFile propertiesFile = getPropertiesFile();
  if (propertiesFile != null) {
    for (IProperty property : propertiesFile.getProperties()) {
      if (Comparing.strEqual(property.getValue(), value)) {
        result.add(0, property.getUnescapedKey());
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:I18nizeQuickFixDialog.java

示例3: testDeleteProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testDeleteProperty() throws Exception {
  PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "xxx=yyy\n#s\nzzz=ttt\n\n");

  final List<IProperty> properties = propertiesFile.getProperties();
  assertEquals(2, properties.size());
  assertPropertyEquals(properties.get(0), "xxx", "yyy");
  assertPropertyEquals(properties.get(1), "zzz", "ttt");

  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    public void run() {
      properties.get(1).getPsiElement().delete();
    }
  });

  List<IProperty> propertiesAfter = propertiesFile.getProperties();
  assertEquals(1, propertiesAfter.size());
  assertPropertyEquals(propertiesAfter.get(0), "xxx", "yyy");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PropertiesFileTest.java

示例4: getPropertiesMap

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public static MultiMap<String, IProperty> getPropertiesMap(ResourceBundle resourceBundle, boolean onlyIncomplete) {
  List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
  final MultiMap<String, IProperty> propertyNames;
  if (onlyIncomplete) {
    propertyNames = getChildrenIdShowOnlyIncomplete(resourceBundle);
  } else {
    propertyNames = MultiMap.createLinked();
    for (PropertiesFile propertiesFile : propertiesFiles) {
      List<IProperty> properties = propertiesFile.getProperties();
      for (IProperty property : properties) {
        String name = property.getKey();
        propertyNames.putValue(name, property);
      }
    }
  }
  return propertyNames;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ResourceBundleFileStructureViewElement.java

示例5: testGradleWrapper

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testGradleWrapper() {
  VirtualFile vFile = myFixture.copyFileToProject("projects/projectWithAppandLib/gradle/wrapper/gradle-wrapper.properties", "gradle/wrapper/gradle-wrapper.properties");
  PsiFile file = PsiManager.getInstance(getProject()).findFile(vFile);
  assertNotNull(file);
  PropertiesFile propertiesFile = (PropertiesFile)file;
  GradleImplicitPropertyUsageProvider provider = new GradleImplicitPropertyUsageProvider();
  for (IProperty property : propertiesFile.getProperties()) {
    // All properties are considered used in this file
    String name = property.getName();
    assertTrue(name, provider.isUsed((Property)property));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GradleImplicitPropertyUsageProviderTest.java

示例6: collectPropertiesFileVariants

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
protected static void collectPropertiesFileVariants(@Nullable PropertiesFile file, @Nullable String prefix, List<Object> result, Set<String> variants) {
  if (file == null) return;

  for (IProperty each : file.getProperties()) {
    String name = each.getKey();
    if (name != null) {
      if (prefix != null) name = prefix + name;

      if (variants.add(name)) {
        result.add(createLookupElement(each, name, PlatformIcons.PROPERTY_ICON));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:MavenPropertyPsiReference.java

示例7: findUsages

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public NonCodeUsageSearchInfo findUsages(@NotNull final PsiElement element, @NotNull final PsiElement[] allElementsToDelete, @NotNull final List<UsageInfo> result) {
  PropertiesFile file = (PropertiesFile) element;
  List<PsiElement> elements = new ArrayList<PsiElement>();
  elements.add(file.getContainingFile());
  for (IProperty property : file.getProperties()) {
    elements.add(property.getPsiElement());
  }
  for(PsiElement psiElement: elements) {
    SafeDeleteProcessor.findGenericElementUsages(psiElement, result, allElementsToDelete);
  }
  return new NonCodeUsageSearchInfo(SafeDeleteProcessor.getDefaultInsideDeletedCondition(allElementsToDelete), elements);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PropertiesFilesSafeDeleteProcessor.java

示例8: testAddPropertyAfterComment

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testAddPropertyAfterComment() throws Exception {
  final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "#xxxxx");
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      propertiesFile.addProperty(myPropertyToAdd);
    }
  });


  List<IProperty> properties = propertiesFile.getProperties();
  IProperty added = properties.get(0);
  assertPropertyEquals(added, myPropertyToAdd.getName(), myPropertyToAdd.getValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PropertiesFileTest.java

示例9: testAddPropertyAfterProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testAddPropertyAfterProperty() throws Exception {
  final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "xxx=yyy");
  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    public void run() {
      propertiesFile.addProperty(myPropertyToAdd);
    }
  });


  List<IProperty> properties = propertiesFile.getProperties();
  assertEquals(2, properties.size());
  assertPropertyEquals(properties.get(1), "xxx", "yyy");
  assertPropertyEquals(properties.get(0), myPropertyToAdd.getName(), myPropertyToAdd.getValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PropertiesFileTest.java

示例10: testUnescapedKey

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testUnescapedKey() throws IncorrectOperationException {
  PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a\\:b=xxx\nc\\ d=xxx\n\\ e\\=f=xxx\n\\u1234\\uxyzt=xxxx");
  List<IProperty> properties = propertiesFile.getProperties();
  assertEquals("a:b", properties.get(0).getUnescapedKey());
  assertEquals("c d", properties.get(1).getUnescapedKey());
  assertEquals(" e=f", properties.get(2).getUnescapedKey());
  assertEquals("\u1234\\uxyzt", properties.get(3).getUnescapedKey());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PropertiesFileTest.java

示例11: sortPropertiesFile

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
private static void sortPropertiesFile(final PropertiesFile file) {
  final List<IProperty> properties = new ArrayList<IProperty>(file.getProperties());

  Collections.sort(properties, new Comparator<IProperty>() {
    @Override
    public int compare(@NotNull IProperty p1, @NotNull IProperty p2) {
      return Comparing.compare(p1.getKey(), p2.getKey(), String.CASE_INSENSITIVE_ORDER);
    }
  });
  final char delimiter = PropertiesCodeStyleSettings.getInstance(file.getProject()).KEY_VALUE_DELIMITER;
  final StringBuilder rawText = new StringBuilder();
  for (int i = 0; i < properties.size(); i++) {
    IProperty property = properties.get(i);
    final String value = property.getValue();
    final String commentAboveProperty = property.getDocCommentText();
    if (commentAboveProperty != null) {
      rawText.append(commentAboveProperty).append("\n");
    }
    final String propertyText =
      PropertiesElementFactory.getPropertyText(property.getKey(), value != null ? value : "", delimiter, null, false);
    rawText.append(propertyText);
    if (i != properties.size() - 1) {
      rawText.append("\n");
    }
  }

  final PropertiesFile fakeFile = PropertiesElementFactory.createPropertiesFile(file.getProject(), rawText.toString());

  final PropertiesList propertiesList = PsiTreeUtil.findChildOfType(file.getContainingFile(), PropertiesList.class);
  LOG.assertTrue(propertiesList != null);
  final PropertiesList fakePropertiesList = PsiTreeUtil.findChildOfType(fakeFile.getContainingFile(), PropertiesList.class);
  LOG.assertTrue(fakePropertiesList != null);
  propertiesList.replace(fakePropertiesList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:AlphaUnsortedPropertiesFileInspection.java

示例12: guessSeparator

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
private static String guessSeparator(final ResourceBundleImpl resourceBundle) {
  final TIntLongHashMap charCounts = new TIntLongHashMap();
  for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
    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]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:PropertiesSeparatorManager.java

示例13: addVariantsFromFile

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public static void addVariantsFromFile(PropertyReferenceBase propertyReference,
                                       final PropertiesFile propertiesFile,
                                       final Set<Object> variants) {
  if (propertiesFile == null) return;
  if (!ProjectRootManager.getInstance(propertyReference.getElement().getProject()).getFileIndex().isInContent(propertiesFile.getVirtualFile())) return;
  List<? extends IProperty> properties = propertiesFile.getProperties();
  for (IProperty property : properties) {
    propertyReference.addKey(property, variants);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PropertiesPsiCompletionUtil.java

示例14: extractUrl

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Nullable
private static String extractUrl(PropertiesFile properties, String artifactName) {
  String prefix = "artifact:" + artifactName + "#source#jar#";

  for (IProperty property : properties.getProperties()) {
    String key = property.getUnescapedKey();
    if (key != null && key.startsWith(prefix) && key.endsWith(".location")) {
      return property.getUnescapedValue();
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:IvyAttachSourceProvider.java

示例15: insertPropertyLast

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
private void insertPropertyLast(String key, String value, PropertiesFile propertiesFile) {
  final List<IProperty> properties = propertiesFile.getProperties();
  final IProperty lastProperty = properties.isEmpty() ? null : properties.get(properties.size() - 1);
  propertiesFile.addPropertyAfter(key, value, lastProperty);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ResourceBundlePropertiesUpdateManager.java


注:本文中的com.intellij.lang.properties.psi.PropertiesFile.getProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。