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


Java PropertiesFile.findPropertyByKey方法代码示例

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


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

示例1: resolve

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public PsiElement resolve() {
  final Project project = myFile.getProject();
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  final VirtualFile formVirtualFile = myFile.getVirtualFile();
  if (formVirtualFile == null) {
    return null;
  }
  final Module module = fileIndex.getModuleForFile(formVirtualFile);
  if (module == null) {
    return null;
  }
  final PropertiesFile propertiesFile = PropertiesUtilBase.getPropertiesFile(myBundleName, module, null);
  if (propertiesFile == null) {
    return null;
  }
  IProperty property = propertiesFile.findPropertyByKey(getRangeText());
  return property == null ? null : property.getPsiElement();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ResourceBundleKeyReference.java

示例2: doOKAction

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Override protected void doOKAction() {
  if (myForm.myRbResourceBundle.isSelected()) {
    final StringDescriptor descriptor = getDescriptor();
    if (descriptor != null && descriptor.getKey().length() > 0) {
      final String value = myForm.myTfRbValue.getText();
      final PropertiesFile propFile = getPropertiesFile(descriptor);
      if (propFile != null && propFile.findPropertyByKey(descriptor.getKey()) == null) {
        saveCreatedProperty(propFile, descriptor.getKey(), value, myEditor.getPsiFile());
      }
      else {
        final String newKeyName = saveModifiedPropertyValue(myEditor.getModule(), descriptor, myLocale, value, myEditor.getPsiFile());
        if (newKeyName != null) {
          myForm.myTfKey.setText(newKeyName);
        }
      }
    }
  }
  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StringEditorDialog.java

示例3: resolveToProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public IProperty resolveToProperty(@NotNull StringDescriptor descriptor, @Nullable Locale locale) {
  String propFileName = descriptor.getDottedBundleName();
  Pair<Locale, String> cacheKey = Pair.create(locale, propFileName);
  PropertiesFile propertiesFile;
  synchronized (myPropertiesFileCache) {
    propertiesFile = myPropertiesFileCache.get(cacheKey);
  }
  if (propertiesFile == null || !propertiesFile.getContainingFile().isValid()) {
    propertiesFile = PropertiesUtilBase.getPropertiesFile(propFileName, myModule, locale);
    synchronized (myPropertiesFileCache) {
      myPropertiesFileCache.put(cacheKey, propertiesFile);
    }
  }

  if (propertiesFile != null) {
    final IProperty propertyByKey = propertiesFile.findPropertyByKey(descriptor.getKey());
    if (propertyByKey != null) {
      return propertyByKey;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:StringDescriptorManager.java

示例4: doOKAction

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Override
protected void doOKAction() {
  if (!createPropertiesFileIfNotExists()) return;
  Collection<PropertiesFile> propertiesFiles = getAllPropertiesFiles();
  for (PropertiesFile propertiesFile : propertiesFiles) {
    IProperty existingProperty = propertiesFile.findPropertyByKey(getKey());
    final String propValue = myValue.getText();
    if (existingProperty != null && !Comparing.strEqual(existingProperty.getValue(), propValue)) {
      final String messageText = CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.message", getKey(), propertiesFile.getName());
      final int code = Messages.showOkCancelDialog(myProject,
                                                   messageText,
                                                   CodeInsightBundle.message("i18nize.dialog.error.property.already.defined.title"),
                                                   null);
      if (code == Messages.CANCEL) {
        return;
      }
    }
  }

  super.doOKAction();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:I18nizeQuickFixDialog.java

示例5: insertOrUpdateTranslation

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void insertOrUpdateTranslation(String key, String value, final PropertiesFile propertiesFile) throws IncorrectOperationException {
  final IProperty property = propertiesFile.findPropertyByKey(key);
  if (property != null) {
    property.setValue(value);
    return;
  }

  if (myOrdered) {
    if (myAlphaSorted) {
      propertiesFile.addProperty(key, value);
      return;
    }
    final Pair<IProperty, Integer> propertyAndPosition = findExistedPrevSiblingProperty(key, propertiesFile);
    propertiesFile.addPropertyAfter(key, value, propertyAndPosition == null ? null : (Property)propertyAndPosition.getFirst());
  }
  else {
    insertPropertyLast(key, value, propertiesFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ResourceBundlePropertiesUpdateManager.java

示例6: deletePropertyIfExist

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void deletePropertyIfExist(String key, PropertiesFile file) {
  final IProperty property = file.findPropertyByKey(key);
  if (property != null && myKeysOrder != null) {
    boolean keyExistInOtherPropertiesFiles = false;
    for (PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) {
      if (!propertiesFile.equals(file) && propertiesFile.findPropertyByKey(key) != null) {
        keyExistInOtherPropertiesFiles = true;
        break;
      }
    }
    if (!keyExistInOtherPropertiesFiles) {
      myKeysOrder.remove(key);
    }
  }
  if (property != null) {
    property.getPsiElement().delete();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ResourceBundlePropertiesUpdateManager.java

示例7: testAddProperty2

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public void testAddProperty2() {
  final PsiFile psiFile = myFixture.configureByFile("foo.xml");
  final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile);
  assertNotNull(propertiesFile);

  WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
    public void run() {
      propertiesFile.addProperty("kkk", "vvv");
    }
  });

  final IProperty property = propertiesFile.findPropertyByKey("kkk");
  assertNotNull(property);
  assertEquals("vvv", property.getValue());

  WriteCommandAction.runWriteCommandAction(getProject(), new Runnable() {
    public void run() {
      propertiesFile.addProperty("kkk2", "vvv");
    }
  });

  final IProperty property2 = propertiesFile.findPropertyByKey("kkk2");
  assertNotNull(property2);
  assertEquals("vvv", property2.getValue());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlPropertiesTest.java

示例8: isPropertyComplete

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public static boolean isPropertyComplete(final ResourceBundle resourceBundle, final String propertyName) {
  List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
  for (PropertiesFile propertiesFile : propertiesFiles) {
    if (propertiesFile.findPropertyByKey(propertyName) == null) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PropertiesUtil.java

示例9: checkDescriptor

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
@Nullable
private static String checkDescriptor(final StringDescriptor descriptor, final Module module) {
  final String bundleName = descriptor.getDottedBundleName();
  final String key = descriptor.getKey();
  if (bundleName == null && key == null) return null;
  if (bundleName == null) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.bundle.not.specified");
  }

  if (key == null) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.property.key.not.specified");
  }

  PropertiesReferenceManager manager = PropertiesReferenceManager.getInstance(module.getProject());
  List<PropertiesFile> propFiles = manager.findPropertiesFiles(module, bundleName);

  if (propFiles.size() == 0) {
    return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.bundle.not.found", bundleName);
  }

  for(PropertiesFile propFile: propFiles) {
    final com.intellij.lang.properties.IProperty property = propFile.findPropertyByKey(key);
    if (property == null) {
      return UIDesignerBundle.message("inspection.invalid.property.in.form.quickfix.error.key.not.found",
                                       key, bundleName, propFile.getLocale().getDisplayName());
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:InvalidPropertyKeyFormInspection.java

示例10: doPropertyUsageTest

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
private void doPropertyUsageTest(final String propertyFileName) {
  PropertiesFile propFile = (PropertiesFile) myPsiManager.findFile(myTestProjectRoot.findChild(propertyFileName));
  assertNotNull(propFile);
  final Property prop = (Property)propFile.findPropertyByKey("key");
  assertNotNull(prop);
  final Query<PsiReference> query = ReferencesSearch.search(prop);
  final Collection<PsiReference> result = query.findAll();
  assertEquals(1, result.size());
  verifyReference(result, 0, "form.form", 960);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:FormPropertyUsageTest.java

示例11: createProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public static void createProperty(final Project project,
                                  final Collection<PropertiesFile> propertiesFiles,
                                  final String key,
                                  final String value) throws IncorrectOperationException {
  for (PropertiesFile file : propertiesFiles) {
    PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    documentManager.commitDocument(documentManager.getDocument(file.getContainingFile()));

    IProperty existingProperty = file.findPropertyByKey(key);
    if (existingProperty == null) {
      file.addProperty(key, value);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:I18nUtil.java

示例12: containsProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public static boolean containsProperty(final ResourceBundle resourceBundle, final String propertyName) {
  for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
    if (propertiesFile.findPropertyByKey(propertyName) != null) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PropertiesUtil.java

示例13: findExistedPrevSiblingProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
private Pair<IProperty, Integer> findExistedPrevSiblingProperty(String key, PropertiesFile file) {
  if (myKeysOrder.isEmpty()) {
    return null;
  }
  final int prevPosition = myKeysOrder.indexOf(key);
  for (int i = prevPosition; i >= 0 ; i--) {
    final String prevKey = myKeysOrder.get(i);
    final IProperty property = file.findPropertyByKey(prevKey);
    if (property != null) {
      return Pair.create(property, prevPosition + 1);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ResourceBundlePropertiesUpdateManager.java

示例14: isPropertyComplete

import com.intellij.lang.properties.psi.PropertiesFile; //导入方法依赖的package包/类
public boolean isPropertyComplete(final ResourceBundle resourceBundle, final String key) {
  List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles();
  for (PropertiesFile propertiesFile : propertiesFiles) {
    if (propertiesFile.findPropertyByKey(key) == null && !myState.getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile))) {
        return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:IgnoredPropertiesFilesSuffixesManager.java

示例15: testDeletePropertyWhitespaceAround

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

  final Property property = (Property)propertiesFile.findPropertyByKey("xxx2");
  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    public void run() {
      property.delete();
    }
  });


  assertEquals("xxx=yyy\nxxx3=ttt\n\n", propertiesFile.getContainingFile().getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PropertiesFileTest.java


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