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


Java ASTNodes.isLiteral方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.corext.dom.ASTNodes.isLiteral方法的典型用法代码示例。如果您正苦于以下问题:Java ASTNodes.isLiteral方法的具体用法?Java ASTNodes.isLiteral怎么用?Java ASTNodes.isLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.corext.dom.ASTNodes的用法示例。


在下文中一共展示了ASTNodes.isLiteral方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
@Override
public boolean visit(ReturnStatement node) {
  Expression expression = node.getExpression();
  if (!(ASTNodes.isLiteral(expression) || expression instanceof Name)) {
    fMustEvalReturnedExpression = true;
  }
  if (Invocations.isInvocation(expression) || expression instanceof ClassInstanceCreation) {
    fReturnValueNeedsLocalVariable = false;
  }
  fReturnExpressions.add(expression);
  return false;
}
 
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:SourceProvider.java

示例2: visit

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
@Override
public boolean visit(Expression node) {
  int accessMode = fFormalArgument.getSimplifiedAccessMode();
  if (accessMode == FlowInfo.WRITE) return setResult(false);
  if (accessMode == FlowInfo.UNUSED) return setResult(true);
  if (ASTNodes.isLiteral(node)) return setResult(true);
  return setResult(fFormalArgument.getNumberOfAccesses() <= 1);
}
 
开发者ID:eclipse,项目名称:che,代码行数:9,代码来源:CallInliner.java

示例3: computeReceiver

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
private void computeReceiver() throws BadLocationException {
  Expression receiver = Invocations.getExpression(fInvocation);
  if (receiver == null) return;
  final boolean isName = receiver instanceof Name;
  if (isName)
    fContext.receiverIsStatic = ((Name) receiver).resolveBinding() instanceof ITypeBinding;
  if (ASTNodes.isLiteral(receiver) || isName || receiver instanceof ThisExpression) {
    fContext.receiver =
        fBuffer.getDocument().get(receiver.getStartPosition(), receiver.getLength());
    return;
  }
  switch (fSourceProvider.getReceiversToBeUpdated()) {
    case 0:
      // Make sure we evaluate the current receiver. Best is to assign to
      // local.
      fLocals.add(
          createLocalDeclaration(
              receiver.resolveTypeBinding(),
              fInvocationScope.createName("r", true), // $NON-NLS-1$
              (Expression) fRewrite.createCopyTarget(receiver)));
      return;
    case 1:
      fContext.receiver =
          fBuffer.getDocument().get(receiver.getStartPosition(), receiver.getLength());
      return;
    default:
      String local = fInvocationScope.createName("r", true); // $NON-NLS-1$
      fLocals.add(
          createLocalDeclaration(
              receiver.resolveTypeBinding(),
              local,
              (Expression) fRewrite.createCopyTarget(receiver)));
      fContext.receiver = local;
      return;
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:37,代码来源:CallInliner.java

示例4: makeExpressionOrTypeVariable

import org.eclipse.jdt.internal.corext.dom.ASTNodes; //导入方法依赖的package包/类
public ConstraintVariable makeExpressionOrTypeVariable(Expression expression, IContext context) {
  IBinding binding = ExpressionVariable.resolveBinding(expression);

  if (binding instanceof ITypeBinding) {
    ICompilationUnit cu = ASTCreator.getCu(expression);
    Assert.isNotNull(cu);
    CompilationUnitRange range = new CompilationUnitRange(cu, expression);
    return makeTypeVariable((ITypeBinding) getKey(binding), expression.toString(), range);
  }

  if (ASTNodes.isLiteral(expression)) {
    Integer nodeType = new Integer(expression.getNodeType());
    if (!fLiteralMap.containsKey(nodeType)) {
      fLiteralMap.put(nodeType, new ExpressionVariable(expression));
      if (REPORT) nrCreated++;
    } else {
      if (REPORT) nrRetrieved++;
    }
    if (REPORT) dumpConstraintStats();
    return fLiteralMap.get(nodeType);
  }

  // For ExpressionVariables, there are two cases. If the expression has a binding
  // we use that as the key. Otherwise, we use the CompilationUnitRange. See
  // also ExpressionVariable.equals()
  ExpressionVariable ev;
  Object key;
  if (binding != null) {
    key = getKey(binding);
  } else {
    key = new CompilationUnitRange(ASTCreator.getCu(expression), expression);
  }
  ev = fExpressionMap.get(key);

  if (ev != null) {
    if (REPORT) nrRetrieved++;
  } else {
    ev = new ExpressionVariable(expression);
    fExpressionMap.put(key, ev);
    if (REPORT) nrCreated++;
    if (REPORT) dumpConstraintStats();
  }
  return ev;
}
 
开发者ID:eclipse,项目名称:che,代码行数:45,代码来源:ConstraintVariableFactory.java


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