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

Java Property类代码示例

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

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



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

示例1: isUsed

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
@Override
protected boolean isUsed(Property property) {
  PsiFile file = property.getContainingFile();
  if (Comparing.equal(file.getName(), FN_GRADLE_WRAPPER_PROPERTIES, SystemInfo.isFileSystemCaseSensitive)) {
    // Ignore all properties in the gradle wrapper: read by the gradle wrapper .jar code
    return true;
  }

  // The android gradle plugin reads sdk.dir, ndk.dir and android.dir from local.properties
  if (Comparing.equal(file.getName(), FN_LOCAL_PROPERTIES, SystemInfo.isFileSystemCaseSensitive)) {
    String name = property.getName();
    return SDK_DIR_PROPERTY.equals(name) || "ndk.dir".equals(name) || "android.dir".equals(name);
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GradleImplicitPropertyUsageProvider.java


示例2: testLocalProperties

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


示例3: findPropertyReferences

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
private static Collection<PsiReference> findPropertyReferences(final Property pproperty, final Module module) {
  final Collection<PsiReference> references = Collections.synchronizedList(new ArrayList<PsiReference>());
  ProgressManager.getInstance().runProcessWithProgressSynchronously(
        new Runnable() {
      public void run() {
        ReferencesSearch.search(pproperty).forEach(new Processor<PsiReference>() {
          public boolean process(final PsiReference psiReference) {
            PsiMethod method = PsiTreeUtil.getParentOfType(psiReference.getElement(), PsiMethod.class);
            if (method == null || !AsmCodeGenerator.SETUP_METHOD_NAME.equals(method.getName())) {
              references.add(psiReference);
            }
            return true;
          }
        });
      }
    }, UIDesignerBundle.message("edit.text.searching.references"), false, module.getProject()
  );
  return references;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:StringEditorDialog.java


示例4: insertOrUpdateTranslation

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


示例5: annotate

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


示例6: invoke

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
  final PsiFile file = element.getContainingFile();
  if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;

  final Property property = PsiTreeUtil.getParentOfType(element, Property.class);
  LOG.assertTrue(property != null);
  final int start = property.getTextRange().getStartOffset();

  @NonNls final Document doc = PsiDocumentManager.getInstance(project).getDocument(file);
  LOG.assertTrue(doc != null);
  final int line = doc.getLineNumber(start);
  final int lineStart = doc.getLineStartOffset(line);

  doc.insertString(lineStart, "# suppress inspection \"" + shortName +
                              "\"\n");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PropertySuppressableInspectionBase.java


示例7: ensurePropertiesLoaded

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
private void ensurePropertiesLoaded() {
  if (myPropertiesMap != null) return;

  final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES);
  MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>();
  List<IProperty> properties = new ArrayList<IProperty>(props.length);
  for (final ASTNode prop : props) {
    final Property property = (Property)prop.getPsi();
    String key = property.getUnescapedKey();
    propertiesMap.add(key, property);
    properties.add(property);
  }
  final boolean isAlphaSorted = PropertiesImplUtil.isAlphaSorted(properties);
  synchronized (lock) {
    if (myPropertiesMap != null) return;
    myProperties = properties;
    myPropertiesMap = propertiesMap;
    myAlphaSorted = isAlphaSorted;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PropertiesFileImpl.java


示例8: getPropertyArgument

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
@Nullable
private static Property getPropertyArgument(PsiMethodCallExpression arg) {
  PsiExpression[] args = arg.getArgumentList().getExpressions();
  if (args.length > 0) {
    PsiReference[] references = args[0].getReferences();
    for (PsiReference reference : references) {
      if (reference instanceof PropertyReference) {
        ResolveResult[] resolveResults = ((PropertyReference)reference).multiResolve(false);
        if (resolveResults.length == 1 && resolveResults[0].isValidResult()) {
          PsiElement element = resolveResults[0].getElement();
          if (element instanceof Property) {
            return (Property) element;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TitleCapitalizationInspection.java


示例9: isUsed

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
@Override
protected boolean isUsed(Property property) {
    PropertiesFileCndKeyModel cndKeyModel = null;
    try {
        cndKeyModel = new PropertiesFileCndKeyModel(property.getKey());
    } catch (IllegalArgumentException e) {
        //Nothing to do
    }

    if (cndKeyModel != null) {
        Project project = property.getProject();
        String namespace = cndKeyModel.getNamespace();
        String nodeTypeName = cndKeyModel.getNodeTypeName();

        if (cndKeyModel.isProperty() || cndKeyModel.isProperty() || cndKeyModel.isChoicelistElement()) {
            return CndUtil.findProperty(project, namespace, nodeTypeName, cndKeyModel.getPropertyName()) != null;
        } else {
            return CndUtil.findNodeType(project, namespace, nodeTypeName) != null;
        }
    }

    return false;
}
 
开发者ID:Tolc,项目名称:IntelliJ_Jahia_plugin,代码行数:24,代码来源:CndImplicitPropertyUsageProvider.java


示例10: annotate

import com.intellij.lang.properties.psi.Property; //导入依赖的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(new RemovePropertyFix(property));
  }

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


示例11: invoke

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
  final PsiFile file = element.getContainingFile();
  if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;

  final Property property = PsiTreeUtil.getParentOfType(element, Property.class);
  LOG.assertTrue(property != null);
  final int start = property.getTextRange().getStartOffset();

  @NonNls final Document doc = PsiDocumentManager.getInstance(project).getDocument(file);
  LOG.assertTrue(doc != null);
  final int line = doc.getLineNumber(start);
  final int lineStart = doc.getLineStartOffset(line);

  doc.insertString(lineStart, "# suppress inspection \"" + shortName +
                              "\"\n");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:PropertySuppressableInspectionBase.java


示例12: ensurePropertiesLoaded

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
private void ensurePropertiesLoaded() {
  if (myPropertiesMap != null) return;

  final ASTNode[] props = getPropertiesList().getChildren(PropertiesElementTypes.PROPERTIES);
  MostlySingularMultiMap<String, IProperty> propertiesMap = new MostlySingularMultiMap<String, IProperty>();
  List<IProperty> properties = new ArrayList<IProperty>(props.length);
  for (final ASTNode prop : props) {
    final Property property = (Property)prop.getPsi();
    String key = property.getUnescapedKey();
    propertiesMap.add(key, property);
    properties.add(property);
  }
  synchronized (lock) {
    if (myPropertiesMap != null) return;
    myProperties = properties;
    myPropertiesMap = propertiesMap;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:PropertiesFileImpl.java


示例13: addPropertyAfter

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
@Override
@NotNull
public PsiElement addPropertyAfter(@NotNull final Property property, @Nullable final Property anchor) throws IncorrectOperationException {
  final TreeElement copy = ChangeUtil.copyToElement(property);
  List<IProperty> properties = getProperties();
  ASTNode anchorBefore = anchor == null ? properties.isEmpty() ? null : properties.get(0).getPsiElement().getNode()
                         : anchor.getNode().getTreeNext();
  if (anchorBefore != null) {
    if (anchorBefore.getElementType() == TokenType.WHITE_SPACE) {
      anchorBefore = anchorBefore.getTreeNext();
    }
  }
  if (anchorBefore == null && haveToAddNewLine()) {
    insertLineBreakBefore(null);
  }
  getPropertiesList().addChild(copy, anchorBefore);
  if (anchorBefore != null) {
    insertLineBreakBefore(anchorBefore);
  }
  return copy.getPsi();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:PropertiesFileImpl.java


示例14: testGradleWrapper

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


示例15: doPropertyUsageTest

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


示例16: testDeletePropertyWhitespaceAround

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


示例17: testDeletePropertyWhitespaceAhead

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

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


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


示例18: testAddPropertyAfter

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
public void testAddPropertyAfter() throws IncorrectOperationException {
  final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f");
  final Property c = (Property)propertiesFile.findPropertyByKey("c");
  WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() {
      propertiesFile.addPropertyAfter(myPropertyToAdd, c);
    }
  });

  assertEquals("a=b\nc=d\nkkk=vvv\ne=f", propertiesFile.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PropertiesFileTest.java


示例19: testAddPropertyAfterLast

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
public void testAddPropertyAfterLast() throws IncorrectOperationException {
  final PropertiesFile propertiesFile = PropertiesElementFactory.createPropertiesFile(getProject(), "a=b\nc=d\ne=f");
  final Property p = (Property)propertiesFile.findPropertyByKey("e");
  WriteCommandAction.runWriteCommandAction(null, new Runnable(){public void run() {
      propertiesFile.addPropertyAfter(myPropertyToAdd, p);
    }
  });

  assertEquals("a=b\nc=d\ne=f\nkkk=vvv", propertiesFile.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PropertiesFileTest.java


示例20: getChildrenBase

import com.intellij.lang.properties.psi.Property; //导入依赖的package包/类
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
  List<? extends IProperty> properties = getElement().getProperties();

  Collection<StructureViewTreeElement> elements = new ArrayList<StructureViewTreeElement>(properties.size());
  for (IProperty property : properties) {
    elements.add(new PropertiesStructureViewElement((Property)property));
  }
  return elements;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PropertiesFileStructureViewElement.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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