• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IProperty类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getResolvedProperty

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Nullable
private static IProperty getResolvedProperty(@NotNull final XmlAttributeValue codeValue) {
    return CachedValuesManager.getCachedValue(codeValue, KEY, () -> {
        List<IProperty> allProperties = new SmartList<>();
        for (PsiReference nextRef : codeValue.getReferences()) {
            if (nextRef instanceof PsiPolyVariantReference) {
                Arrays.stream(((PsiPolyVariantReference) nextRef).multiResolve(false))
                      .filter(ResolveResult::isValidResult)
                      .map(ResolveResult::getElement)
                      .map(o -> ObjectUtils.tryCast(o, IProperty.class))
                      .filter(Objects::nonNull)
                      .forEach(allProperties::add);
            } else {
                Optional.ofNullable(nextRef.resolve())
                        .map(o -> ObjectUtils.tryCast(o, IProperty.class))
                        .ifPresent(allProperties::add);
            }
        }

        IProperty theChosenOne = chooseForLocale(allProperties);
        return new CachedValueProvider.Result<>(theChosenOne, PsiModificationTracker.MODIFICATION_COUNT);
    });
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:JspPropertyFoldingBuilder.java


示例2: chooseForLocale

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
private static IProperty chooseForLocale(
    final @NotNull List<Locale.LanguageRange> priorityList,
    final @NotNull List<IProperty> properties
) {
    if (properties.isEmpty()) {
        return null;
    }
    IProperty first = properties.get(0);
    if (properties.size() == 1) {
        return first;
    }
    final Map<Locale, IProperty> map = new HashMap<>();
    final List<Locale> locales = new LinkedList<>();
    for (IProperty nextProperty : properties) {
        Locale nextLocale = safeGetLocale(nextProperty);
        if (nextLocale != null) {
            map.put(nextLocale, nextProperty);
            locales.add(nextLocale);
        }
    }

    Locale best = Locale.lookup(priorityList, locales);
    //System.err.println("found locales: " + locales + ", best: " + best + ", result: " + map.get(best));
    return Optional.ofNullable(best).map(map::get).orElse(first);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:JspPropertyFoldingBuilder.java


示例3: extractConfigInfo

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例4: update

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Override
public void update(AnActionEvent anActionEvent) {
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext());

    boolean isProperty = false;
    boolean isPropertyFile = false;
    boolean isEncrypted = false;

    if (file != null) {
        isPropertyFile = "properties".equalsIgnoreCase(file.getExtension());
        if (isPropertyFile) {
            IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext());
            if (selectedProperty != null) {
                String propertyValue = selectedProperty.getValue();
                isEncrypted = (propertyValue.startsWith("![") && propertyValue.endsWith("]"));
                isProperty = true;
            }
        }
    }
    anActionEvent.getPresentation().setEnabled(isPropertyFile && isEncrypted && isProperty);
    anActionEvent.getPresentation().setVisible(isPropertyFile && isProperty);
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:23,代码来源:DecryptPropertyAction.java


示例5: update

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Override
public void update(AnActionEvent anActionEvent)
{
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext());

    boolean isProperty = false;
    boolean isPropertyFile = false;
    boolean isEncrypted = false;

    if (file != null)
    {
        isPropertyFile = "properties".equalsIgnoreCase(file.getExtension());
        if (isPropertyFile) {

            IProperty selectedProperty = getSelectedProperty(anActionEvent.getDataContext());
            if (selectedProperty != null) {
                String propertyValue = selectedProperty.getValue();
                isEncrypted = (propertyValue.startsWith("![") && propertyValue.endsWith("]"));
                isProperty = true;
            }
        }
    }

    anActionEvent.getPresentation().setEnabled(isPropertyFile && !isEncrypted && isProperty);
    anActionEvent.getPresentation().setVisible(isPropertyFile && isProperty);
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:27,代码来源:EncryptPropertyAction.java


示例6: testLocalProperties

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例7: resolve

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例8: resolve

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Nullable public String resolve(@Nullable StringDescriptor descriptor, @Nullable Locale locale) {
  if (descriptor == null) {
    return null;
  }

  if (descriptor.getValue() != null) {
    return descriptor.getValue();
  }

  IProperty prop = resolveToProperty(descriptor, locale);
  if (prop != null) {
    final String value = prop.getUnescapedValue();
    if (value != null) {
      return value;
    }
  }
  // We have to return surrogate string in case if propFile name is invalid or bundle doesn't have specified key
  return "[" + descriptor.getKey() + " / " + descriptor.getBundleName() + "]";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StringDescriptorManager.java


示例9: resolveToProperty

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例10: getExistingValueKeys

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例11: doOKAction

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例12: getResourceBundleFromDataContext

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
/**
 * Tries to derive {@link com.intellij.lang.properties.ResourceBundle resource bundle} related to the given context.
 *
 * @param dataContext   target context
 * @return              {@link com.intellij.lang.properties.ResourceBundle resource bundle} related to the given context if any;
 *                      <code>null</code> otherwise
 */
@Nullable
public static ResourceBundle getResourceBundleFromDataContext(@NotNull DataContext dataContext) {
  PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
  if (element instanceof IProperty) return null; //rename property
  final ResourceBundle[] bundles = ResourceBundle.ARRAY_DATA_KEY.getData(dataContext);
  if (bundles != null && bundles.length == 1) return bundles[0];
  VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
  if (virtualFile == null) {
    return null;
  }
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (virtualFile instanceof ResourceBundleAsVirtualFile && project != null) {
    return ((ResourceBundleAsVirtualFile)virtualFile).getResourceBundle();
  }
  if (project != null) {
    final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
    if (psiFile instanceof PropertiesFile) {
      return ((PropertiesFile)psiFile).getResourceBundle();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ResourceBundleUtil.java


示例13: update

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
  final FileEditor fileEditor = PlatformDataKeys.FILE_EDITOR.getData(e.getDataContext());
  if (fileEditor instanceof ResourceBundleEditor) {
    ResourceBundleEditor resourceBundleEditor = (ResourceBundleEditor)fileEditor;
    final Project project = getEventProject(e);
    if (project != null) {
      if (!processSelectedIncompleteProperties(new Processor<IProperty>() {
        @Override
        public boolean process(IProperty property) {
          return false;
        }
      }, resourceBundleEditor, project)) {
        e.getPresentation().setEnabledAndVisible(true);
        return;
      }
    }
  }
  e.getPresentation().setEnabledAndVisible(false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:IgnoreIncompletePropertyPropertiesFilesAction.java


示例14: processSelectedIncompleteProperties

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
private static boolean processSelectedIncompleteProperties(final @NotNull Processor<IProperty> processor,
                                                           final @NotNull ResourceBundleEditor resourceBundleEditor,
                                                           final @NotNull Project project) {
  final IgnoredPropertiesFilesSuffixesManager suffixesManager = IgnoredPropertiesFilesSuffixesManager.getInstance(project);
  for (ResourceBundleEditorViewElement element : resourceBundleEditor.getSelectedElements()) {
    final IProperty[] properties = element.getProperties();
    if (properties != null) {
      for (IProperty property : properties) {
        if (!suffixesManager.isPropertyComplete(resourceBundleEditor.getResourceBundle(), property.getKey()) && !processor.process(property)) {
          return false;
        }
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:IgnoreIncompletePropertyPropertiesFilesAction.java


示例15: deleteElement

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull final DataContext dataContext) {
  final List<PropertiesFile> bundlePropertiesFiles = myResourceBundle.getPropertiesFiles();

  final List<PsiElement> toDelete = new ArrayList<PsiElement>();
  for (IProperty property : myProperties) {
    final String key = property.getKey();
    if (key == null) {
      LOG.error("key must be not null " + property);
    } else {
      for (PropertiesFile propertiesFile : bundlePropertiesFiles) {
        for (final IProperty iProperty : propertiesFile.findPropertiesByKey(key)) {
          toDelete.add(iProperty.getPsiElement());
        }
      }
    }
  }
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  LOG.assertTrue(project != null);
  new SafeDeleteHandler().invoke(project, PsiUtilCore.toPsiElementArray(toDelete), dataContext);
  myInsertDeleteManager.reload();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ResourceBundleStructureViewComponent.java


示例16: insertOrUpdateTranslation

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例17: deletePropertyIfExist

import com.intellij.lang.properties.IProperty; //导入依赖的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


示例18: findCollisions

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@Override
public void findCollisions(PsiElement element,
                           final String newName,
                           Map<? extends PsiElement, String> allRenames,
                           List<UsageInfo> result) {
  for (final Map.Entry<? extends PsiElement, String> e: allRenames.entrySet()) {
    for (IProperty property : ((PropertiesFile)e.getKey().getContainingFile()).getProperties()) {
      if (Comparing.strEqual(e.getValue(), property.getKey())) {
        result.add(new UnresolvableCollisionUsageInfo(property.getPsiElement(), e.getKey()) {
          @Override
          public String getDescription() {
            return "New property name \'" + e.getValue() + "\' hides existing property";
          }
        });
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:RenamePropertyProcessor.java


示例19: checkFile

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
  if (!(file instanceof PropertiesFile)) return null;
  final List<IProperty> properties = ((PropertiesFile)file).getProperties();
  final List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
  for (IProperty property : properties) {
    ProgressManager.checkCanceled();
    final PropertyImpl propertyImpl = (PropertyImpl)property;
    for (ASTNode node : ContainerUtil.ar(propertyImpl.getKeyNode(), propertyImpl.getValueNode())) {
      if (node != null) {
        PsiElement key = node.getPsi();
        TextRange textRange = getTrailingSpaces(key, myIgnoreVisibleSpaces);
        if (textRange != null) {
          descriptors.add(manager.createProblemDescriptor(key, textRange, "Trailing spaces", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true, new RemoveTrailingSpacesFix(myIgnoreVisibleSpaces)));
        }
      }
    }
  }
  return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TrailingSpacesInPropertyInspection.java


示例20: getProperties

import com.intellij.lang.properties.IProperty; //导入依赖的package包/类
@NotNull
@Override
public IProperty[] getProperties() {
  final List<IProperty> elements = ContainerUtil.mapNotNull(getChildren(), new NullableFunction<TreeElement, IProperty>() {
    @Nullable
    @Override
    public IProperty fun(final TreeElement treeElement) {
      if (treeElement instanceof PropertiesStructureViewElement) {
        PropertiesStructureViewElement propertiesElement = (PropertiesStructureViewElement)treeElement;
        return propertiesElement.getValue();
      }
      else if (treeElement instanceof ResourceBundlePropertyStructureViewElement) {
        return ((ResourceBundlePropertyStructureViewElement)treeElement).getProperties()[0];
      }
      return null;
    }
  });
  return elements.toArray(new IProperty[elements.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PropertiesPrefixGroup.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityAIWatchClosest2类代码示例发布时间:2022-05-21
下一篇:
Java CodeSignature类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap