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


Java GroovyBugError类代码示例

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


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

示例1: parse

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
/**
 * Parses the source to a CST.  You can retrieve it with getCST().
 */
public void parse() throws CompilationFailedException {
    if (this.phase > Phases.PARSING) {
        throw new GroovyBugError("parsing is already complete");
    }

    if (this.phase == Phases.INITIALIZATION) {
        nextPhase();
    }

    //
    // Create a reader on the source and run the parser.

    try (Reader reader = source.getReader()) {
        // let's recreate the parser each time as it tends to keep around state
        parserPlugin = getConfiguration().getPluginFactory().createParserPlugin();

        cst = parserPlugin.parseCST(this, reader);
    } catch (IOException e) {
        getErrorCollector().addFatalError(new SimpleMessage(e.getMessage(), this));
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:SourceUnit.java

示例2: handleMissingMethod

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<MethodNode> handleMissingMethod(final ClassNode receiver, final String name, final ArgumentListExpression argumentList, final ClassNode[] argumentTypes, final MethodCall call) {
    List<Closure> onMethodSelection = eventHandlers.get("handleMissingMethod");
    List<MethodNode> methodList = new LinkedList<MethodNode>();
    if (onMethodSelection != null) {
        for (Closure closure : onMethodSelection) {
            Object result = safeCall(closure, receiver, name, argumentList, argumentTypes, call);
            if (result != null) {
                if (result instanceof MethodNode) {
                    methodList.add((MethodNode) result);
                } else if (result instanceof Collection) {
                    methodList.addAll((Collection<? extends MethodNode>) result);
                } else {
                    throw new GroovyBugError("Type checking extension returned unexpected method list: " + result);
                }
            }
        }
    }
    return methodList;
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:GroovyTypeCheckingExtensionSupport.java

示例3: handleAmbiguousMethods

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<MethodNode> handleAmbiguousMethods(final List<MethodNode> nodes, final Expression origin) {
    List<Closure> onMethodSelection = eventHandlers.get("handleAmbiguousMethods");
    List<MethodNode> methodList = nodes;
    if (onMethodSelection != null) {
        Iterator<Closure> iterator = onMethodSelection.iterator();
        while (methodList.size()>1 && iterator.hasNext() ) {
            final Closure closure = iterator.next();
            Object result = safeCall(closure, methodList, origin);
            if (result != null) {
                if (result instanceof MethodNode) {
                    methodList = Collections.singletonList((MethodNode) result);
                } else if (result instanceof Collection) {
                    methodList = new LinkedList<MethodNode>((Collection<? extends MethodNode>) result);
                } else {
                    throw new GroovyBugError("Type checking extension returned unexpected method list: " + result);
                }
            }
        }
    }
    return methodList;
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:GroovyTypeCheckingExtensionSupport.java

示例4: parameterizedType

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
public ClassNode parameterizedType(ClassNode baseType, ClassNode... genericsTypeArguments) {
    ClassNode result = baseType.getPlainNodeReference();
    if (result.isUsingGenerics()) {
        GenericsType[] gts = new GenericsType[genericsTypeArguments.length];
        int expectedLength = result.getGenericsTypes().length;
        if (expectedLength!=genericsTypeArguments.length) {
            throw new GroovyBugError("Expected number of generic type arguments for "+baseType.toString(false)+" is "+expectedLength
            + " but you gave "+genericsTypeArguments.length);
        }
        for (int i = 0; i < gts.length; i++) {
            gts[i] = new GenericsType(genericsTypeArguments[i]);
        }
        result.setGenericsTypes(gts);
    }
    return result;
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:TypeCheckingExtension.java

示例5: extractTarget

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
private static groovy.transform.PackageScopeTarget extractTarget(PropertyExpression expr) {
    Expression oe = expr.getObjectExpression();
    if (oe instanceof ClassExpression) {
        ClassExpression ce = (ClassExpression) oe;
        if (ce.getType().getName().equals("groovy.transform.PackageScopeTarget")) {
            Expression prop = expr.getProperty();
            if (prop instanceof ConstantExpression) {
                String propName = (String) ((ConstantExpression) prop).getValue();
                try {
                    return PackageScopeTarget.valueOf(propName);
                } catch(IllegalArgumentException iae) {
                    /* ignore */
                }
            }
        }
    }
    throw new GroovyBugError("Internal error during " + MY_TYPE_NAME
            + " processing. Annotation parameters must be of type: " + TARGET_CLASS_NAME + ".");
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:PackageScopeASTTransformation.java

示例6: makePostfix

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
/**
*  Converts a node from a generic type to a specific postfix type.
*  Throws a <code>GroovyBugError</code> if the type can't be converted.
*/

public static void makePostfix(CSTNode node, boolean throwIfInvalid ) {

    switch( node.getMeaning() ) {
        case PLUS_PLUS:
            node.setMeaning( POSTFIX_PLUS_PLUS );
            break;

        case MINUS_MINUS:
            node.setMeaning( POSTFIX_MINUS_MINUS );
            break;

        default:
            if( throwIfInvalid ) {
                throw new GroovyBugError( "cannot convert to postfix for type [" + node.getMeaning() + "]" );
            }
    }

}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:Types.java

示例7: visitMethodCallExpression

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
public void visitMethodCallExpression(MethodCallExpression call) {
    if (call.isImplicitThis() && call.getMethod() instanceof ConstantExpression) {
        ConstantExpression methodNameConstant = (ConstantExpression) call.getMethod();
        Object value = methodNameConstant.getText();

        if (!(value instanceof String)) {
            throw new GroovyBugError("tried to make a method call with a non-String constant method name.");
        }

        String methodName = (String) value;
        Variable v = checkVariableNameForDeclaration(methodName, call);
        if (v != null && !(v instanceof DynamicVariable)) {
            checkVariableContextAccess(v, call);
        }

        if (v instanceof VariableExpression || v instanceof Parameter) {
            VariableExpression object = new VariableExpression(v);
            object.setSourcePosition(methodNameConstant);
            call.setObjectExpression(object);
            ConstantExpression method = new ConstantExpression("call");
            method.setSourcePosition(methodNameConstant); // important for GROOVY-4344
            call.setImplicitThis(false);
            call.setMethod(method);
        }

    }
    super.visitMethodCallExpression(call);
}
 
开发者ID:apache,项目名称:groovy,代码行数:29,代码来源:VariableScopeVisitor.java

示例8: encodeAsValidClassName

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
public static String encodeAsValidClassName(String name) {
    final int l = name.length();
    StringBuilder b = null;
    int lastEscape = -1;
    for(int i = 0; i < l; ++i) {
        final int encodeIndex = name.charAt(i) - MIN_ENCODING;
        if (encodeIndex >= 0 && encodeIndex < CHARACTERS_TO_ENCODE.length) {
            if (CHARACTERS_TO_ENCODE[encodeIndex]) {
                if(b == null) {
                    b = new StringBuilder(name.length() + 3);
                    b.append(name, 0, i);
                } else {
                    b.append(name, lastEscape + 1, i);
                }
                b.append('_');
                lastEscape = i;
            }
        }
    }
    if(b == null) return name.toString();
    if (lastEscape == -1) throw new GroovyBugError("unexpected escape char control flow in "+name);
    b.append(name, lastEscape + 1, l);
    return b.toString();
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:GeneratorContext.java

示例9: addGeneratedClosureConstructorCall

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
public boolean addGeneratedClosureConstructorCall(ConstructorCallExpression call) {
    ClassNode classNode = controller.getClassNode();
    if (!classNode.declaresInterface(ClassHelper.GENERATED_CLOSURE_Type)) return false;

    AsmClassGenerator acg = controller.getAcg();
    OperandStack operandStack = controller.getOperandStack();
    
    MethodVisitor mv = controller.getMethodVisitor();
    mv.visitVarInsn(ALOAD, 0);
    ClassNode callNode = classNode.getSuperClass();
    TupleExpression arguments = (TupleExpression) call.getArguments();
    if (arguments.getExpressions().size()!=2) throw new GroovyBugError("expected 2 arguments for closure constructor super call, but got"+arguments.getExpressions().size());
    arguments.getExpression(0).visit(acg);
    operandStack.box();
    arguments.getExpression(1).visit(acg);
    operandStack.box();
    //TODO: replace with normal String, p not needed
    Parameter p = new Parameter(ClassHelper.OBJECT_TYPE,"_p");
    String descriptor = BytecodeHelper.getMethodDescriptor(ClassHelper.VOID_TYPE, new Parameter[]{p,p});
    mv.visitMethodInsn(INVOKESPECIAL, BytecodeHelper.getClassInternalName(callNode), "<init>", descriptor, false);
    operandStack.remove(2);
    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:ClosureWriter.java

示例10: chooseBytecodeVersion

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
private static int chooseBytecodeVersion(final boolean invokedynamic, final String targetBytecode) {
    if (invokedynamic) {
        if (CompilerConfiguration.JDK7.equals(targetBytecode)) {
            return Opcodes.V1_7;
        }

        return Opcodes.V1_8;
    } else {
        Integer bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode);

        if (null != bytecodeVersion) {
            return bytecodeVersion;
        }
    }

    throw new GroovyBugError("Bytecode version ["+targetBytecode+"] is not supported by the compiler");
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:WriterController.java

示例11: makeSingleArgumentCall

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
@Override
public void makeSingleArgumentCall(final Expression receiver, final String message, final Expression arguments, boolean safe) {
    TypeChooser typeChooser = controller.getTypeChooser();
    ClassNode classNode = controller.getClassNode();
    ClassNode rType = typeChooser.resolveType(receiver, classNode);
    ClassNode aType = typeChooser.resolveType(arguments, classNode);
    if (trySubscript(receiver, message, arguments, rType, aType, safe)) {
        return;
    }
    // now try with flow type instead of declaration type
    rType = receiver.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
    if (receiver instanceof VariableExpression && rType == null) {
        // TODO: can STCV be made smarter to avoid this check?
        VariableExpression ve = (VariableExpression) ((VariableExpression)receiver).getAccessedVariable();
        rType = ve.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
    }
    if (rType!=null && trySubscript(receiver, message, arguments, rType, aType, safe)) {
        return;
    }
    // todo: more cases
    throw new GroovyBugError(
            "At line " + receiver.getLineNumber() + " column " + receiver.getColumnNumber() + "\n" +
            "On receiver: " + receiver.getText() + " with message: " + message + " and arguments: " + arguments.getText() + "\n" +
            "This method should not have been called. Please try to create a simple example reproducing\n" +
            "this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY");
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:StaticTypesCallSiteWriter.java

示例12: createClosureClass

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
@Override
protected ClassNode createClosureClass(final ClosureExpression expression, final int mods) {
    ClassNode closureClass = super.createClosureClass(expression, mods);
    List<MethodNode> methods = closureClass.getDeclaredMethods("call");
    List<MethodNode> doCall = closureClass.getMethods("doCall");
    if (doCall.size() != 1) {
        throw new GroovyBugError("Expected to find one (1) doCall method on generated closure, but found " + doCall.size());
    }
    MethodNode doCallMethod = doCall.get(0);
    if (methods.isEmpty() && doCallMethod.getParameters().length == 1) {
        createDirectCallMethod(closureClass, doCallMethod);
    }
    MethodTargetCompletionVisitor visitor = new MethodTargetCompletionVisitor(doCallMethod);
    Object dynamic = expression.getNodeMetaData(StaticTypesMarker.DYNAMIC_RESOLUTION);
    if (dynamic != null) {
        doCallMethod.putNodeMetaData(StaticTypesMarker.DYNAMIC_RESOLUTION, dynamic);
    }
    for (MethodNode method : methods) {
        visitor.visitMethod(method);
    }
    closureClass.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.TRUE);
    return closureClass;
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:StaticTypesClosureWriter.java

示例13: getInvokeSpecialHandle

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
@Override
public Object getInvokeSpecialHandle(final Method method, final Object receiver) {
    if (LOOKUP_Constructor==null) {
        return super.getInvokeSpecialHandle(method, receiver);
    }
    if (!method.isAccessible()) {
        AccessController.doPrivileged(new PrivilegedAction() {
            @Override
            public Object run() {
                method.setAccessible(true);
                return null;
            }
        });
    }
    Class declaringClass = method.getDeclaringClass();
    try {
        return LOOKUP_Constructor.
                newInstance(declaringClass, -1).
                unreflectSpecial(method, declaringClass).
                bindTo(receiver);
    } catch (ReflectiveOperationException e) {
        throw new GroovyBugError(e);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:Java7.java

示例14: bootstrap

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
/**
 * bootstrap method for method calls from Groovy compiled code with indy 
 * enabled. This method gets a flags parameter which uses the following 
 * encoding:<ul>
 * <li>{@value #SAFE_NAVIGATION} is the flag value for safe navigation see {@link #SAFE_NAVIGATION}<li/>
 * <li>{@value #THIS_CALL} is the flag value for a call on this see {@link #THIS_CALL}</li>
 * </ul> 
 * @param caller - the caller
 * @param callType - the type of the call
 * @param type - the call site type
 * @param name - the real method name
 * @param flags - call flags
 * @return the produced CallSite
 * @since Groovy 2.1.0
 */
public static CallSite bootstrap(Lookup caller, String callType, MethodType type, String name, int flags) {
    boolean safe = (flags&SAFE_NAVIGATION)!=0;
    boolean thisCall = (flags&THIS_CALL)!=0;
    boolean spreadCall = (flags&SPREAD_CALL)!=0;
    int callID;
    if (callType.equals(CALL_TYPES.METHOD.getCallSiteName())) {
        callID = CALL_TYPES.METHOD.ordinal();
    } else if (callType.equals(CALL_TYPES.INIT.getCallSiteName())) {
        callID = CALL_TYPES.INIT.ordinal();
    } else if (callType.equals(CALL_TYPES.GET.getCallSiteName())) {
        callID = CALL_TYPES.GET.ordinal();
    } else if (callType.equals(CALL_TYPES.SET.getCallSiteName())) {
        callID = CALL_TYPES.SET.ordinal();
    } else if (callType.equals(CALL_TYPES.CAST.getCallSiteName())) {
        callID = CALL_TYPES.CAST.ordinal();
    }else {
        throw new GroovyBugError("Unknown call type: "+callType);
    }
    return realBootstrap(caller, name, callID, type, safe, thisCall, spreadCall);
}
 
开发者ID:apache,项目名称:groovy,代码行数:36,代码来源:IndyInterface.java

示例15: configureType

import org.codehaus.groovy.GroovyBugError; //导入依赖的package包/类
private ClassNode configureType(Type type) {
    if (type instanceof WildcardType) {
        return configureWildcardType((WildcardType) type);
    } else if (type instanceof ParameterizedType) {
        return configureParameterizedType((ParameterizedType) type);
    } else if (type instanceof GenericArrayType) {
        return configureGenericArray((GenericArrayType) type);
    } else if (type instanceof TypeVariable) {
        return configureTypeVariableReference(((TypeVariable) type).getName());
    } else if (type instanceof Class) {
        return configureClass((Class) type);
    } else if (type==null) {
        throw new GroovyBugError("Type is null. Most probably you let a transform reuse existing ClassNodes with generics information, that is now used in a wrong context.");
    } else {
        throw new GroovyBugError("unknown type: " + type + " := " + type.getClass());
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:Java5.java


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