本文整理汇总了Java中com.intellij.lang.properties.IProperty类的典型用法代码示例。如果您正苦于以下问题:Java IProperty类的具体用法?Java IProperty怎么用?Java IProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProperty类属于com.intellij.lang.properties包,在下文中一共展示了IProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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);
}
示例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();
}
示例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() + "]";
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}