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


Java Node.getLength方法代码示例

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


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

示例1: createNewProposals

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void createNewProposals(Node inspectedNode, Map<Integer, List<Proposal>> proposals, ArrayList<Var> internalVars, ArrayList<Var> externalVars) {
    Node firstChild = inspectedNode.getFirstChild();
    List<Proposal> ret = new ArrayList<>();
    Predicate<Var> isClass = v -> v.getNode().getJSType().isConstructor();
    internalVars.stream().filter(v->v.getNameNode().getSourceOffset() < firstChild.getSourceOffset())
            .filter(isClass)
            .map(v->new Proposal(v.getName())).forEach(ret::add);
    externalVars.stream()
            .filter(isClass)
            .map(v->new Proposal(v.getName())).forEach(ret::add);
    int sourceOffset = firstChild.getSourceOffset()+1;
    if (sourceOffset < 1) {
        sourceOffset = inspectedNode.getSourceOffset()+inspectedNode.getLength();
    }
    proposals.put(sourceOffset,ret);
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:17,代码来源:ContentAssist.java

示例2: createBlockProposals

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void createBlockProposals(String code, Node inspectedNode, Map<Integer, List<Proposal>> proposals, ArrayList<Var> internalVars, ArrayList<Var> externalVars) {
    List<Proposal> ret = new ArrayList<>();
    internalVars.stream().filter(v->v.getNameNode().getSourceOffset() < inspectedNode.getSourceOffset()).map(v->new Proposal(v.getName())).forEach(ret::add);
    externalVars.stream().map(v->new Proposal(v.getName())).forEach(ret::add);
    proposals.put(inspectedNode.getSourceOffset()+1,ret);
    Node lastChild = inspectedNode.getLastChild();
    ret = new ArrayList<>();
    internalVars.stream().filter(v->v.getNameNode().getSourceOffset() < inspectedNode.getSourceOffset()).map(v->new Proposal(v.getName())).forEach(ret::add);
    externalVars.stream().map(v->new Proposal(v.getName())).forEach(ret::add);
    int sourceOffset = lastChild != null?lastChild.getSourceOffset()+lastChild.getLength():inspectedNode.getSourceOffset()+inspectedNode.getLength();
    if (code.length() > sourceOffset && Character.isWhitespace(code.charAt(sourceOffset)))
        ++sourceOffset;
    if (code.length() > sourceOffset && !proposals.containsKey(sourceOffset)) {
        proposals.put(sourceOffset, ret);
    }
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:17,代码来源:ContentAssist.java

示例3: createExprResultProposals

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void createExprResultProposals(String code, Node inspectedNode, Map<Integer, List<Proposal>> proposals, ArrayList<Var> internalVars, ArrayList<Var> externalVars) {
    List<Proposal> ret = new ArrayList<>();
    Node lastChild = inspectedNode.getLastChild();
    internalVars.stream().filter(v->v.getNameNode().getSourceOffset() < inspectedNode.getSourceOffset()).map(v->new Proposal(v.getName())).forEach(ret::add);
    externalVars.stream().map(v->new Proposal(v.getName())).forEach(ret::add);
    int sourceOffset = lastChild != null?lastChild.getSourceOffset()+lastChild.getLength():inspectedNode.getSourceOffset()+inspectedNode.getLength();
    while (sourceOffset < code.length() && (!Character.isWhitespace(sourceOffset))) {
        ++sourceOffset;
        if (code.charAt(sourceOffset-1) == ';')
            break;
    }
    if (sourceOffset < code.length() && !proposals.containsKey(sourceOffset)) {
        proposals.put(sourceOffset, ret);
    }
    sourceOffset = inspectedNode.getSourceOffset();
    if (sourceOffset >= 0) {
        proposals.put(sourceOffset, ret);
    }
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:20,代码来源:ContentAssist.java

示例4: createGetPropProposals

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void createGetPropProposals(String code, Node inspectedNode, Map<Integer, List<Proposal>> proposals, ArrayList<Var> internalVars, ArrayList<Var> externalVars) {
    Node firstChild = inspectedNode.getFirstChild();
    Optional<JSType> firstChildType = Optional.ofNullable(firstChild.getJSType());
    if (firstChildType.isPresent()) {
        JSType t = fixNullType(firstChildType.get());
        if (t instanceof ObjectType) {
            ObjectType ot = ObjectType.cast(t);

            ArrayList<String> internalProperties = new ArrayList<>();
            ArrayList<String> externalProperties = new ArrayList<>();
            Comparator<String> sortProps = (s1,s2)->{
                Optional<JSType> propertyType1 = Optional.ofNullable(ot.getPropertyType(s1));
                Optional<JSType> propertyType2 = Optional.ofNullable(ot.getPropertyType(s2));
                if (propertyType1.isPresent()) {
                    if (!propertyType2.isPresent())
                        return -1;
                    return compareJsType(propertyType1.get(),propertyType2.get());
                }
                if (propertyType2.isPresent())
                    return 1;
                return 0;
            };

            ot.getPropertyNames().stream().filter(n -> !n.startsWith("__"))
                    .forEach(n -> {
                        if (isIntern(ot.getPropertyDefSite(n))) {
                            internalProperties.add(n);
                        } else {
                            externalProperties.add(n);
                        }
                    });
            internalProperties.sort(sortProps);
            externalProperties.sort(sortProps);
            UnaryOperator<String> addFunctionBrackets = s -> {
                Optional<JSType> propertyType = Optional.ofNullable(ot.getPropertyType(s));
                boolean isFunction = propertyType.map(pt -> pt instanceof FunctionType).orElse(false);
                return isFunction ? s + "()" : s;
            };
            internalProperties.replaceAll(addFunctionBrackets);
            externalProperties.replaceAll(addFunctionBrackets);
            List<Proposal> ret = new ArrayList<>();
            int sourcePosition = firstChild.getSourceOffset();
            if (sourcePosition > -1) {
                sourcePosition += firstChild.getLength();
                while (sourcePosition < code.length() &&
                        (Character.isWhitespace(code.charAt(sourcePosition)))) {
                    ++sourcePosition;
                }
                if (sourcePosition < code.length() && '.' == code.charAt(sourcePosition))
                    ++sourcePosition;
            }
            int sp = sourcePosition;
            if (sp > -1) {
                if (ot instanceof FunctionType) {
                    internalVars.stream().filter(v -> v.getNameNode().getSourceOffset() < sp).map(v -> new Proposal(v.getName())).forEach(ret::add);
                    internalProperties.stream().map(s -> new Proposal(s)).forEach(ret::add);
                    externalVars.stream().map(v -> new Proposal(v.getName())).forEach(ret::add);
                    externalProperties.stream().map(s -> new Proposal(s)).forEach(ret::add);
                } else {
                    internalProperties.stream().map(s -> new Proposal(s)).forEach(ret::add);
                    externalProperties.stream().map(s -> new Proposal(s)).forEach(ret::add);
                }
                proposals.put(sourcePosition, ret);
            }
        }
    }
}
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:68,代码来源:ContentAssist.java


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