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


Java Pair.of方法代码示例

本文整理汇总了Java中com.sun.tools.javac.util.Pair.of方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.of方法的具体用法?Java Pair.of怎么用?Java Pair.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.util.Pair的用法示例。


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

示例1: findSource

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
private Pair<JavacTask, CompilationUnitTree> findSource(String moduleName,
                                                        String binaryName) throws IOException {
    JavaFileObject jfo = fm.getJavaFileForInput(StandardLocation.SOURCE_PATH,
                                                binaryName,
                                                JavaFileObject.Kind.SOURCE);

    if (jfo == null)
        return null;

    List<JavaFileObject> jfos = Arrays.asList(jfo);
    JavaFileManager patchFM = moduleName != null
            ? new PatchModuleFileManager(baseFileManager, jfo, moduleName)
            : baseFileManager;
    JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, patchFM, d -> {}, null, null, jfos);
    Iterable<? extends CompilationUnitTree> cuts = task.parse();

    task.enter();

    return Pair.of(task, cuts.iterator().next());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:JavadocHelper.java

示例2: findSource

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
private Pair<JavacTask, CompilationUnitTree> findSource(String binaryName) throws IOException {
    JavaFileObject jfo = fm.getJavaFileForInput(StandardLocation.SOURCE_PATH,
                                                binaryName,
                                                JavaFileObject.Kind.SOURCE);

    if (jfo == null)
        return null;

    List<JavaFileObject> jfos = Arrays.asList(jfo);
    JavacTaskImpl task = (JavacTaskImpl) compiler.getTask(null, fm, d -> {}, null, null, jfos);
    Iterable<? extends CompilationUnitTree> cuts = task.parse();

    task.enter();

    return Pair.of(task, cuts.iterator().next());
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:17,代码来源:SourceCodeAnalysisImpl.java

示例3: isSatisfiedBy

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean isSatisfiedBy(TreePath path) {
  if (path == null) {
    return false;
  }

  TreePath parentPath = path.getParentPath();
  if (parentPath == null) {
    return false;
  }

  Tree parent = parentPath.getLeaf();
  Tree leaf = path.getLeaf();
  if (parent instanceof VariableTree) {
    // parent is a variable declaration

    if (parentPath.getParentPath().getLeaf() instanceof MethodTree) {
      // formal parameter, not local variable
      return false;
    }

    VariableTree vtt = (VariableTree) parent;
    if (leaf.equals(vtt.getInitializer())) {
      // don't match in initializer
      return false;
    }

    String varName = vtt.getName().toString();

    if (Objects.equals(loc.varName, varName)) {
      int varIndex = LocalVariableScanner.indexOfVarTree(path, vtt, varName);
      return (loc.varIndex == varIndex);
    }

    Pair<String, Pair<Integer, Integer>> key =
            Pair.of(fullMethodName, Pair.of(loc.index, loc.scopeStart));
    String potentialVarName =
            LocalVariableScanner.getFromMethodNameIndexMap(key);
    if (potentialVarName != null) {
      if (varName.equals(potentialVarName)) {
        // now use methodNameCounter to ensure that if this is the
        // i'th variable of this name, its offset is the i'th offset
        // of all variables with this name
        List<Integer> allOffsetsWithThisName =
                LocalVariableScanner.getFromMethodNameCounter(fullMethodName, potentialVarName);
        //      methodNameCounter.get(fullMethodName).get(potentialVarName);
        Integer thisVariablesOffset =
                allOffsetsWithThisName.indexOf(loc.scopeStart);

        // now you need to make sure that this is the
        // thisVariablesOffset'th variable tree in the entire source
        int i = LocalVariableScanner.indexOfVarTree(path, parent, potentialVarName);

        if (i == thisVariablesOffset) {
          return true;
        }
      }
    }
    return false;
  }
  // isSatisfiedBy should return true not just for the local variable itself, but for its type.
  // So, if this is part of a type, try its parent.
  // For example, return true for the tree for "Integer"
  // within the local variable "List<Integer> foo;"
  //
  // But, stop the search once it gets to certain types, such as MethodTree.
  // Is it OK to stop at ExpressionTree too?
  else if (parent instanceof MethodTree) {
    return false;
  } else {
    return this.isSatisfiedBy(parentPath);
  }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:75,代码来源:LocalVariableCriterion.java

示例4: addConstant

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
private static Pair<Integer, Character> addConstant(List<CPInfo> constantPool, Object value, boolean annotation) {
    if (value instanceof Boolean) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info(((Boolean) value) ? 1 : 0)), 'Z');
    } else if (value instanceof Byte) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((byte) value)), 'B');
    } else if (value instanceof Character) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((char) value)), 'C');
    } else if (value instanceof Short) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((short) value)), 'S');
    } else if (value instanceof Integer) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Integer_info((int) value)), 'I');
    } else if (value instanceof Long) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Long_info((long) value)), 'J');
    } else if (value instanceof Float) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Float_info((float) value)), 'F');
    } else if (value instanceof Double) {
        return Pair.of(addToCP(constantPool, new CONSTANT_Double_info((double) value)), 'D');
    } else if (value instanceof String) {
        int stringIndex = addString(constantPool, (String) value);
        if (annotation) {
            return Pair.of(stringIndex, 's');
        } else {
            return Pair.of(addToCP(constantPool, new CONSTANT_String_info(null, stringIndex)), 's');
        }
    }

    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:CreateSymbols.java

示例5: createPipeStream

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
private Pair<InputStream, OutputStream> createPipeStream() throws Exception {
    Class<?> pipeStreamClass = Class.forName("jdk.jshell.execution.PipeInputStream");
    Constructor<?> c = pipeStreamClass.getDeclaredConstructor();
    c.setAccessible(true);
    Object pipeStream = c.newInstance();
    Method createOutputStream = pipeStreamClass.getDeclaredMethod("createOutput");
    createOutputStream.setAccessible(true);
    return Pair.of((InputStream) pipeStream, (OutputStream) createOutputStream.invoke(pipeStream));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:PipeInputStreamTest.java

示例6: outerThisDef

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
private void outerThisDef(Symbol owner) {
    Type target = types.erasure(owner.enclClass().type.getEnclosingType());
    Pair<TypeSymbol, Symbol> outerThis = Pair.of(target.tsym, owner);
    outerThisStack = outerThisStack.prepend(outerThis);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:PostFlowAnalysis.java

示例7: elemPair

import com.sun.tools.javac.util.Pair; //导入方法依赖的package包/类
/**
 * Convenience method for ensuring returned {@link Pair} is of the
 * most general type.
 */
private Pair<AElement, AElement> elemPair(AElement stype,
    AElement dtype) {
  return Pair.of(stype, dtype);
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:9,代码来源:SceneOps.java


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