本文整理汇总了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;
}
示例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");
}
示例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;
}
示例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));
}
}
}
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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]);
}
示例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);
}
}
示例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;
}
示例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);
}