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


Java PropertiesFile类代码示例

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


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

示例1: extractConfigInfo

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
private Optional<ConfigInfo> extractConfigInfo(PropertiesFile propertiesFile, CoffigResolver.Match match) {
    Optional<String> description = Optional.ofNullable(propertiesFile.findPropertyByKey(match.getUnmatchedPath())).map(IProperty::getValue);
    if (description.isPresent()) {
        // Base info
        ConfigInfo configInfo = new ConfigInfo(match.getFullPath(), description.get());

        // Extended info
        Optional.ofNullable(propertiesFile.findPropertyByKey(match.getUnmatchedPath() + ".long")).map(IProperty::getValue).ifPresent(configInfo::setLongDescription);

        // Field info
        CoffigResolver.Match resolvedMatch = match.fullyResolve();
        if (resolvedMatch.isFullyResolved()) {
            Optional<PsiField> psiField = resolvedMatch.resolveField(resolvedMatch.getUnmatchedPath());
            psiField.map(PsiVariable::getType).map(PsiType::getPresentableText).ifPresent(configInfo::setType);
        }

        return Optional.of(configInfo);
    }
    return Optional.empty();
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:21,代码来源:CoffigDocumentationProvider.java

示例2: findResourceBundle

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
private Optional<PropertiesFile> findResourceBundle(Project project, PsiClass configClass) {
    String qualifiedName = configClass.getQualifiedName();
    if (qualifiedName != null) {
        int lastDotIndex = qualifiedName.lastIndexOf(".");
        String packageName = qualifiedName.substring(0, lastDotIndex);
        String className = qualifiedName.substring(lastDotIndex + 1);
        PsiPackage psiPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
        if (psiPackage != null) {
            return Arrays.stream(psiPackage.getFiles(GlobalSearchScope.allScope(project)))
                    .filter(psiFile -> psiFile instanceof PropertiesFile && psiFile.getVirtualFile().getNameWithoutExtension().equals(className))
                    .map(psiFile -> (PropertiesFile) psiFile)
                    .findFirst();
        }
    }
    return Optional.empty();
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:17,代码来源:CoffigDocumentationProvider.java

示例3: updateLibraryProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
public static void updateLibraryProperty(@NotNull AndroidFacet facet,
                                       @NotNull final PropertiesFile propertiesFile,
                                       @NotNull List<Runnable> changes) {
final IProperty property = propertiesFile.findPropertyByKey(AndroidUtils.ANDROID_LIBRARY_PROPERTY);

if (property != null) {
  final String value = Boolean.toString(facet.isLibraryProject());

  if (!value.equals(property.getValue())) {
    changes.add(new Runnable() {
      @Override
      public void run() {
        property.setValue(value);
      }
    });
  }
}
else if (facet.isLibraryProject()) {
  changes.add(new Runnable() {
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidPropertyFilesUpdater.java

示例4: findPropertiesByKey

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
@NotNull
public static List<IProperty> findPropertiesByKey(@NotNull final Project project, @NotNull final String key) {
  final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
  final ArrayList<IProperty> properties =
    new ArrayList<IProperty>(PropertyKeyIndex.getInstance().get(key, project, scope));
  final Set<VirtualFile> files = new HashSet<VirtualFile>();
  FileBasedIndex.getInstance().processValues(XmlPropertiesIndex.NAME, new XmlPropertiesIndex.Key(key), null, new FileBasedIndex.ValueProcessor<String>() {
    @Override
    public boolean process(VirtualFile file, String value) {
      if (files.add(file)) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
        PropertiesFile propertiesFile = XmlPropertiesFileImpl.getPropertiesFile(psiFile);
        if (propertiesFile != null) {
          properties.addAll(propertiesFile.findPropertiesByKey(key));
        }
      }
      return false;
    }
  }, scope);
  return properties;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PropertiesImplUtil.java

示例5: checkDomElement

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
protected void checkDomElement(DomElement element, DomElementAnnotationHolder holder, DomHighlightingHelper helper) {
  if (element instanceof AntDomProperty) {
    final AntDomProperty property = (AntDomProperty)element;
    final GenericAttributeValue<PsiFileSystemItem> fileValue = property.getFile();
    final String fileName = fileValue.getStringValue();
    if (fileName != null) {
      final PropertiesFile propertiesFile = property.getPropertiesFile();
      if (propertiesFile == null) {
        final PsiFileSystemItem file = fileValue.getValue();
        if (file instanceof XmlFile) {
          holder.createProblem(fileValue, AntBundle.message("file.type.xml.not.supported", fileName));
        }
        else if (file instanceof PsiFile) {
          holder.createProblem(fileValue, AntBundle.message("file.type.not.supported", fileName));
        }
        else {
          holder.createProblem(fileValue, AntBundle.message("file.doesnt.exist", fileName));
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AntMissingPropertiesFileInspection.java

示例6: processReferencesInUIForms

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
private static boolean processReferencesInUIForms(final Processor<PsiReference> processor,
                                                  PsiManager psiManager,
                                                  final PropertiesFile propFile,
                                                  final GlobalSearchScope globalSearchScope,
                                                  final LocalSearchScope filterScope) {
  final Project project = psiManager.getProject();
  GlobalSearchScope scope = GlobalSearchScope.projectScope(project).intersectWith(globalSearchScope);
  final String baseName = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
    @Override
    public String compute() {
      return propFile.getResourceBundle().getBaseName();
    }
  });
  PsiFile containingFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
    @Override
    public PsiFile compute() {
      return propFile.getContainingFile();
    }
  });

  List<PsiFile> files = Arrays.asList(CacheManager.SERVICE.getInstance(project).getFilesWithWord(baseName, UsageSearchContext.IN_PLAIN_TEXT, scope, true));
  return processReferencesInFiles(files, psiManager, baseName, containingFile, filterScope, processor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FormReferencesSearcher.java

示例7: dissociateResourceBundle

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
public void dissociateResourceBundle(final @NotNull ResourceBundle resourceBundle) {
  if (resourceBundle instanceof CustomResourceBundle) {
    final CustomResourceBundleState state =
      getCustomResourceBundleState(resourceBundle.getDefaultPropertiesFile().getVirtualFile());
    LOG.assertTrue(state != null);
    myState.getCustomResourceBundles().remove(state);
  } else {
    if (EmptyResourceBundle.getInstance() != resourceBundle) {
      ((ResourceBundleImpl) resourceBundle).invalidate();
    }
    for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
      final VirtualFile file = propertiesFile.getContainingFile().getVirtualFile();
      myState.getDissociatedFiles().add(file.getUrl());
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ResourceBundleManager.java

示例8: 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

示例9: annotate

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
  if (!(element instanceof IProperty)) return;
  final Property property = (Property)element;
  PropertiesFile propertiesFile = property.getPropertiesFile();
  Collection<IProperty> others = propertiesFile.findPropertiesByKey(property.getUnescapedKey());
  ASTNode keyNode = ((PropertyImpl)property).getKeyNode();
  if (others.size() != 1) {
    Annotation annotation = holder.createErrorAnnotation(keyNode, PropertiesBundle.message("duplicate.property.key.error.message"));
    annotation.registerFix(PropertiesQuickFixFactory.getInstance().createRemovePropertyFix(property));
  }

  highlightTokens(property, keyNode, holder, new PropertiesHighlighter());
  ASTNode valueNode = ((PropertyImpl)property).getValueNode();
  if (valueNode != null) {
    highlightTokens(property, valueNode, holder, new PropertiesValueHighlighter());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PropertiesAnnotator.java

示例10: saveCreatedProperty

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
public static boolean saveCreatedProperty(final PropertiesFile bundle, final String name, final String value,
                                          final PsiFile formFile) {
  final ReadonlyStatusHandler.OperationStatus operationStatus =
    ReadonlyStatusHandler.getInstance(bundle.getProject()).ensureFilesWritable(bundle.getVirtualFile());
  if (operationStatus.hasReadonlyFiles()) {
    return false;
  }
  CommandProcessor.getInstance().executeCommand(
    bundle.getProject(),
    new Runnable() {
      public void run() {
        UndoUtil.markPsiFileForUndo(formFile);
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          public void run() {
            try {
              bundle.addProperty(name, value);
            }
            catch (IncorrectOperationException e1) {
              LOG.error(e1);
            }
          }
        });
      }
    }, UIDesignerBundle.message("command.create.property"), null);
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:StringEditorDialog.java

示例11: handleEvent

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
private void handleEvent(final PsiTreeChangeEvent event) {
  if (event.getParent() != null) {
    PsiFile containingFile = event.getParent().getContainingFile();
    if (containingFile instanceof PropertiesFile) {
      LOG.debug("Received PSI change event for properties file");
      myAlarm.cancelRequest(myRefreshPropertiesRequest);
      myAlarm.addRequest(myRefreshPropertiesRequest, 500, ModalityState.stateForComponent(GuiEditor.this));
    }
    else if (containingFile instanceof PsiPlainTextFile && containingFile.getFileType().equals(StdFileTypes.GUI_DESIGNER_FORM)) {
      // quick check if relevant
      String resourceName = FormEditingUtil.buildResourceName(containingFile);
      if (myDocument.getText().indexOf(resourceName) >= 0) {
        LOG.debug("Received PSI change event for nested form");
        // TODO[yole]: handle multiple nesting
        myAlarm.cancelRequest(mySynchronizeRequest);
        myAlarm.addRequest(mySynchronizeRequest, 500, ModalityState.stateForComponent(GuiEditor.this));
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GuiEditor.java

示例12: testUnsortedSuppressed

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
public void testUnsortedSuppressed() throws Exception {
  final ExtensionPoint<AlphaUnsortedPropertiesFileInspectionSuppressor> ep =
    Extensions.getRootArea().getExtensionPoint(AlphaUnsortedPropertiesFileInspectionSuppressor.EP_NAME);
  final AlphaUnsortedPropertiesFileInspectionSuppressor suppressor = new AlphaUnsortedPropertiesFileInspectionSuppressor() {
    @Override
    public boolean suppressInspectionFor(PropertiesFile propertiesFile) {
      return propertiesFile.getName().toLowerCase().contains("suppress");
    }
  };
  try {
    ep.registerExtension(suppressor);
    doTest();
  } finally {
    ep.unregisterExtension(suppressor);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AlphaUnsortedInspectionTest.java

示例13: getPropertiesFilesWithoutTranslation

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
public List<PropertiesFile> getPropertiesFilesWithoutTranslation(final ResourceBundle resourceBundle, final Set<String> keys) {
  final PropertiesFile defaultPropertiesFile = resourceBundle.getDefaultPropertiesFile();
  return ContainerUtil.filter(resourceBundle.getPropertiesFiles(), new Condition<PropertiesFile>() {
    @Override
    public boolean value(PropertiesFile propertiesFile) {
      if (defaultPropertiesFile.equals(propertiesFile)) {
        return false;
      }
      for (String key : keys) {
        if (propertiesFile.findPropertyByKey(key) == null && !myState.getIgnoredSuffixes().contains(PropertiesUtil.getSuffix(propertiesFile))) {
          return true;
        }
      }
      return false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:IgnoredPropertiesFilesSuffixesManager.java

示例14: canCreateAllFilesForAllLocales

import com.intellij.lang.properties.psi.PropertiesFile; //导入依赖的package包/类
private String canCreateAllFilesForAllLocales() {
  final String name = getBaseName();
  if (name.isEmpty()) {
    return "Base name is empty";
  }
  final Set<String> files = getFileNamesToCreate();
  if (files.isEmpty()) {
    return "No locales added";
  }
  for (PsiElement element : myDirectory.getChildren()) {
    if (element instanceof PsiFile) {
      if (element instanceof PropertiesFile) {
        PropertiesFile propertiesFile = (PropertiesFile)element;
        final String propertiesFileName = propertiesFile.getName();
        if (files.contains(propertiesFileName)) {
          return "Some of files already exist";
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CreateResourceBundleDialogComponent.java

示例15: 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


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