Java 类com.intellij.psi.PsiLiteral 实例源码

项目:consulo-java    文件:SliceTreeTest.java   
public void testLeafExpressionsMoreComplex() throws Exception {
  SliceTreeStructure treeStructure = configureTree("Duplicate");
  SliceNode root = (SliceNode)treeStructure.getRootElement();
  Collection<PsiElement> leaves = SliceLeafAnalyzer.calcLeafExpressions(root, treeStructure, SliceLeafAnalyzer.createMap());
  assertNotNull(leaves);
  assertEquals(2, leaves.size());
  List<PsiElement> list = new ArrayList<PsiElement>(leaves);
  Collections.sort(list, new Comparator<PsiElement>() {
    @Override
    public int compare(PsiElement o1, PsiElement o2) {
      return o1.getText().compareTo(o2.getText());
    }
  });
  assertTrue(list.get(0) instanceof PsiLiteralExpression);
  assertEquals(false, ((PsiLiteral)list.get(0)).getValue());
  assertTrue(list.get(1) instanceof PsiLiteralExpression);
  assertEquals(true, ((PsiLiteral)list.get(1)).getValue());
}
项目:tools-idea    文件:GrAnnotationUtil.java   
@Nullable
public static String inferStringAttribute(@NotNull PsiAnnotation annotation, @NotNull String attributeName) {
  final PsiAnnotationMemberValue targetValue = annotation.findAttributeValue(attributeName);
  if (targetValue instanceof PsiLiteral) {
    final Object value = ((PsiLiteral)targetValue).getValue();
    if (value instanceof String) return (String)value;
  }
  return null;
}
项目:tools-idea    文件:GrAnnotationUtil.java   
@Nullable
public static Integer inferIntegerAttribute(@NotNull PsiAnnotation annotation, @NotNull String attributeName) {
  final PsiAnnotationMemberValue targetValue = annotation.findAttributeValue(attributeName);
  if (targetValue instanceof PsiLiteral) {
    final Object value = ((PsiLiteral)targetValue).getValue();
    if (value instanceof Integer) return (Integer)value;
  }
  return null;
}
项目:consulo-javaee    文件:JamSimpleReferenceConverter.java   
@NotNull
@Override
public PsiReference[] createReferences(JamStringAttributeElement<T> context) {
  final PsiLiteral literal = context.getPsiLiteral();
  if (literal == null) return PsiReference.EMPTY_ARRAY;

  return new PsiReference[]{createReference(context)};
}
项目:consulo-java    文件:SliceTreeTest.java   
public void testLeafExpressionsSimple() throws Exception {
  SliceTreeStructure treeStructure = configureTree("DupSlice");
  SliceNode root = (SliceNode)treeStructure.getRootElement();
  Collection<PsiElement> leaves = SliceLeafAnalyzer.calcLeafExpressions(root, treeStructure, SliceLeafAnalyzer.createMap());
  assertNotNull(leaves);
  PsiElement element = assertOneElement(leaves);
  assertTrue(element instanceof PsiLiteralExpression);
  assertEquals(1111111111, ((PsiLiteral)element).getValue());
}
项目:intellij-ce-playground    文件:JavaAnnotationSupport.java   
@Override
@NotNull
public PsiLiteral createLiteralValue(@NotNull String value, @NotNull PsiElement context) {
  return (PsiLiteral)JavaPsiFacade.getInstance(context.getProject()).getElementFactory().createExpressionFromText("\"" + StringUtil.escapeStringCharacters(value) + "\"", null);
}
项目:intellij-ce-playground    文件:StringLiteralReference.java   
public StringLiteralReference(PsiLiteral value) {
  myValue = value;
}
项目:intellij-ce-playground    文件:LanguageReference.java   
public LanguageReference(PsiLiteral value) {
  super(value);
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLEndpointVisitor.java   
public void visitPsiLiteral(@NotNull PsiLiteral o) {
  visitElement(o);
}
项目:tools-idea    文件:JavaAnnotationSupport.java   
@Override
@NotNull
public PsiLiteral createLiteralValue(@NotNull String value, @NotNull PsiElement context) {
  return (PsiLiteral)JavaPsiFacade.getInstance(context.getProject()).getElementFactory().createExpressionFromText("\"" + StringUtil.escapeStringCharacters(value) + "\"", null);
}
项目:consulo-javaee    文件:JamPomTarget.java   
@Nullable
public TextRange getNameIdentifierRange() {
  final PsiLiteral psiLiteral = myNameAttr.getPsiLiteral();
  return psiLiteral == null ? null : ElementManipulators.getValueTextRange(psiLiteral);
}
项目:consulo-java    文件:JavaAnnotationSupport.java   
@Override
@NotNull
public PsiLiteral createLiteralValue(@NotNull String value, @NotNull PsiElement context) {
  return (PsiLiteral)JavaPsiFacade.getInstance(context.getProject()).getElementFactory().createExpressionFromText("\"" + StringUtil.escapeStringCharacters(value) + "\"", null);
}