• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SimpleMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parse

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的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: verifyCompilePhase

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private void verifyCompilePhase(AnnotationNode annotation, Class<?> klass) {
    GroovyASTTransformation transformationClass = klass.getAnnotation(GroovyASTTransformation.class);
    if (transformationClass != null) {
        CompilePhase specifiedCompilePhase = transformationClass.phase();
        if (specifiedCompilePhase.getPhaseNumber() < CompilePhase.SEMANTIC_ANALYSIS.getPhaseNumber()) {
            source.getErrorCollector().addError(
                    new SimpleMessage(
                            annotation.getClassNode().getName() + " is defined to be run in compile phase " + specifiedCompilePhase + ". Local AST transformations must run in " + CompilePhase.SEMANTIC_ANALYSIS + " or later!",
                            source));
        }

    } else {
        source.getErrorCollector().addError(
                new SimpleMessage("AST transformation implementation classes must be annotated with " + GroovyASTTransformation.class.getName() + ". " + klass.getName() + " lacks this annotation.", source));
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:ASTTransformationCollectorCodeVisitor.java


示例3: getTransformClassNames

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private List<String> getTransformClassNames(AnnotationNode annotation, Annotation transformClassAnnotation) {
    List<String> result = new ArrayList<String>();

    try {
        Method valueMethod = transformClassAnnotation.getClass().getMethod("value");
        String[] names = (String[]) valueMethod.invoke(transformClassAnnotation);
        result.addAll(Arrays.asList(names));

        Method classesMethod = transformClassAnnotation.getClass().getMethod("classes");
        Class[] classes = (Class[]) classesMethod.invoke(transformClassAnnotation);
        for (Class klass : classes) {
            result.add(klass.getName());
        }

        if (names.length > 0 && classes.length > 0) {
            source.getErrorCollector().addError(new SimpleMessage("@GroovyASTTransformationClass in " +
                    annotation.getClassNode().getName() +
                    " should specify transforms only by class names or by classes and not by both", source));
        }
    } catch (Exception e) {
        source.addException(e);
    }

    return result;
}
 
开发者ID:apache,项目名称:groovy,代码行数:26,代码来源:ASTTransformationCollectorCodeVisitor.java


示例4: needsTwitter4jContribution

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
protected static boolean needsTwitter4jContribution(ClassNode declaringClass, SourceUnit sourceUnit) {
    boolean found1 = false, found2 = false, found3 = false;
    ClassNode consideredClass = declaringClass;
    while (consideredClass != null) {
        for (MethodNode method : consideredClass.getMethods()) {
            // just check length, MOP will match it up
            found1 = method.getName().equals(METHOD_WITH_TWITTER) && method.getParameters().length == 2;
            found2 = method.getName().equals(METHOD_SET_TWITTER4j_PROVIDER) && method.getParameters().length == 1;
            found3 = method.getName().equals(METHOD_GET_TWITTER4j_PROVIDER) && method.getParameters().length == 0;
            if (found1 && found2 && found3) {
                return false;
            }
        }
        consideredClass = consideredClass.getSuperClass();
    }
    if (found1 || found2 || found3) {
        sourceUnit.getErrorCollector().addErrorAndContinue(
            new SimpleMessage("@Twitter4jAware cannot be processed on "
                + declaringClass.getName()
                + " because some but not all of methods from " + Twitter4jContributionHandler.class.getName() + " were declared in the current class or super classes.",
                sourceUnit)
        );
        return false;
    }
    return true;
}
 
开发者ID:griffon-legacy,项目名称:griffon-twitter4j-plugin,代码行数:27,代码来源:Twitter4jAwareASTTransformation.java


示例5: visit

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
public void visit(ASTNode[] nodes, SourceUnit source) {
  if (nodes.length == 0 || !(nodes[0] instanceof ModuleNode)) {
    source.getErrorCollector().addError(new SimpleMessage(
      "internal error in DetectorTransform", source));
    return;
  }
  ModuleNode module = (ModuleNode)nodes[0];
  for (ClassNode clazz : (List<ClassNode>)module.getClasses()) {
    FieldNode field = clazz.getField(VERSION_FIELD_NAME);
    if (field != null) {
      field.setInitialValueExpression(new ConstantExpression(ReleaseInfo.getVersion()));
      break;
    }
  }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:DetectorTransform.java


示例6: call

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
public void call(SourceUnit source) throws CompilationFailedException {
    List<ClassNode> classes = source.ast.getClasses();
    for (ClassNode node : classes) {
        CompileUnit cu = node.getCompileUnit();
        for (Iterator iter = cu.iterateClassNodeToCompile(); iter.hasNext();) {
            String name = (String) iter.next();
            SourceUnit su = ast.getScriptSourceLocation(name);
            List<ClassNode> classesInSourceUnit = su.ast.getClasses();
            StringBuilder message = new StringBuilder();
            message
                    .append("Compilation incomplete: expected to find the class ")
                    .append(name)
                    .append(" in ")
                    .append(su.getName());
            if (classesInSourceUnit.isEmpty()) {
                message.append(", but the file seems not to contain any classes");
            } else {
                message.append(", but the file contains the classes: ");
                boolean first = true;
                for (ClassNode cn : classesInSourceUnit) {
                    if (!first) {
                        message.append(", ");
                    } else {
                        first = false;
                    }
                    message.append(cn.getName());
                }
            }

            getErrorCollector().addErrorAndContinue(
                    new SimpleMessage(message.toString(), CompilationUnit.this)
            );
            iter.remove();
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:37,代码来源:CompilationUnit.java


示例7: addTransformsToClassNode

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private void addTransformsToClassNode(AnnotationNode annotation, Annotation transformClassAnnotation) {
    List<String> transformClassNames = getTransformClassNames(annotation, transformClassAnnotation);

    if (transformClassNames.isEmpty()) {
        source.getErrorCollector().addError(new SimpleMessage("@GroovyASTTransformationClass in " +
                annotation.getClassNode().getName() + " does not specify any transform class names/classes", source));
    }

    for (String transformClass : transformClassNames) {
        Class klass = loadTransformClass(transformClass, annotation);
        if (klass != null) {
            verifyAndAddTransform(annotation, klass);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:ASTTransformationCollectorCodeVisitor.java


示例8: loadTransformClass

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private Class loadTransformClass(String transformClass, AnnotationNode annotation) {
    try {
        return transformLoader.loadClass(transformClass, false, true, false);
    } catch (ClassNotFoundException e) {
        source.getErrorCollector().addErrorAndContinue(
                new SimpleMessage(
                        "Could not find class for Transformation Processor " + transformClass
                                + " declared by " + annotation.getClassNode().getName(),
                        source));
    }
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:ASTTransformationCollectorCodeVisitor.java


示例9: addJavacError

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private static void addJavacError(String header, CompilationUnit cu, StringBuilderWriter msg) {
    if (msg != null) {
        header = header + "\n" + msg.getBuilder().toString();
    } else {
        header = header +
                "\nThis javac version does not support compile(String[],PrintWriter), " +
                "so no further details of the error are available. The message error text " +
                "should be found on System.err.\n";
    }
    cu.getErrorCollector().addFatalError(new SimpleMessage(header, cu));
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:JavacJavaCompiler.java


示例10: needsPropertyChangeSupport

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
/**
 * Snoops through the declaring class and all parents looking for methods
 * <code>void addPropertyChangeListener(PropertyChangeListener)</code>,
 * <code>void removePropertyChangeListener(PropertyChangeListener)</code>, and
 * <code>void firePropertyChange(String, Object, Object)</code>. If any are defined all
 * must be defined or a compilation error results.
 *
 * @param declaringClass the class to search
 * @param sourceUnit the source unit, for error reporting. {@code @NotNull}.
 * @return true if property change support should be added
 */
protected boolean needsPropertyChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit) {
    boolean foundAdd = false, foundRemove = false, foundFire = false;
    ClassNode consideredClass = declaringClass;
    while (consideredClass!= null) {
        for (MethodNode method : consideredClass.getMethods()) {
            // just check length, MOP will match it up
            foundAdd = foundAdd || method.getName().equals("addPropertyChangeListener") && method.getParameters().length == 1;
            foundRemove = foundRemove || method.getName().equals("removePropertyChangeListener") && method.getParameters().length == 1;
            foundFire = foundFire || method.getName().equals("firePropertyChange") && method.getParameters().length == 3;
            if (foundAdd && foundRemove && foundFire) {
                return false;
            }
        }
        consideredClass = consideredClass.getSuperClass();
    }
    // check if a super class has @Bindable annotations
    consideredClass = declaringClass.getSuperClass();
    while (consideredClass!=null) {
        if (hasBindableAnnotation(consideredClass)) return false;
        for (FieldNode field : consideredClass.getFields()) {
            if (hasBindableAnnotation(field)) return false;
        }
        consideredClass = consideredClass.getSuperClass();
    }
    if (foundAdd || foundRemove || foundFire) {
        sourceUnit.getErrorCollector().addErrorAndContinue(
            new SimpleMessage("@Bindable cannot be processed on "
                + declaringClass.getName()
                + " because some but not all of addPropertyChangeListener, removePropertyChange, and firePropertyChange were declared in the current or super classes.",
            sourceUnit)
        );
        return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:47,代码来源:BindableASTTransformation.java


示例11: needsVetoableChangeSupport

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
/**
 * Snoops through the declaring class and all parents looking for a field
 * of type VetoableChangeSupport.  Remembers the field and returns false
 * if found otherwise returns true to indicate that such support should
 * be added.
 *
 * @param declaringClass the class to search
 * @return true if vetoable change support should be added
 */
protected boolean needsVetoableChangeSupport(ClassNode declaringClass, SourceUnit sourceUnit) {
    boolean foundAdd = false, foundRemove = false, foundFire = false;
    ClassNode consideredClass = declaringClass;
    while (consideredClass!= null) {
        for (MethodNode method : consideredClass.getMethods()) {
            // just check length, MOP will match it up
            foundAdd = foundAdd || method.getName().equals("addVetoableChangeListener") && method.getParameters().length == 1;
            foundRemove = foundRemove || method.getName().equals("removeVetoableChangeListener") && method.getParameters().length == 1;
            foundFire = foundFire || method.getName().equals("fireVetoableChange") && method.getParameters().length == 3;
            if (foundAdd && foundRemove && foundFire) {
                return false;
            }
        }
        consideredClass = consideredClass.getSuperClass();
    }
    // check if a super class has @Vetoable annotations
    consideredClass = declaringClass.getSuperClass();
    while (consideredClass!=null) {
        if (hasVetoableAnnotation(consideredClass)) return false;
        for (FieldNode field : consideredClass.getFields()) {
            if (hasVetoableAnnotation(field)) return false;
        }
        consideredClass = consideredClass.getSuperClass();
    }
    if (foundAdd || foundRemove || foundFire) {
        sourceUnit.getErrorCollector().addErrorAndContinue(
            new SimpleMessage("@Vetoable cannot be processed on "
                + declaringClass.getName()
                + " because some but not all of addVetoableChangeListener, removeVetoableChange, and fireVetoableChange were declared in the current or super classes.",
            sourceUnit)
        );
        return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:45,代码来源:VetoableASTTransformation.java


示例12: needsDelegate

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
public static boolean needsDelegate(@Nonnull ClassNode classNode, @Nonnull SourceUnit sourceUnit,
                                    @Nonnull MethodDescriptor[] methods, @Nonnull String annotationType,
                                    @Nonnull String delegateType) {
    boolean implemented = false;
    int implementedCount = 0;
    ClassNode consideredClass = classNode;
    while (consideredClass != null) {
        for (MethodNode method : consideredClass.getMethods()) {
            for (MethodDescriptor md : methods) {
                if (method.getName().equals(md.methodName) && method.getParameters().length == md.arguments.length) {
                    implemented |= true;
                    implementedCount++;
                }
                if (implementedCount == methods.length) {
                    return false;
                }
            }
        }

        consideredClass = consideredClass.getSuperClass();
    }
    if (implemented) {
        sourceUnit.getErrorCollector().addErrorAndContinue(
            new SimpleMessage("@" + annotationType + " cannot be processed on "
                + classNode.getName()
                + " because some but not all methods from "
                + delegateType
                + " were declared in the current class or super classes.",
                sourceUnit)
        );
        return false;
    }
    return true;
}
 
开发者ID:aalmiray,项目名称:griffon2,代码行数:35,代码来源:AbstractASTTransformation.java


示例13: needsJdbiContribution

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
protected static boolean needsJdbiContribution(ClassNode declaringClass, SourceUnit sourceUnit) {
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    ClassNode consideredClass = declaringClass;
    while (consideredClass != null) {
        for (MethodNode method : consideredClass.getMethods()) {
            // just check length, MOP will match it up
            found1 = method.getName().equals(METHOD_WITH_JDBI) && method.getParameters().length == 1;
            found2 = method.getName().equals(METHOD_WITH_JDBI) && method.getParameters().length == 2;
            found3 = method.getName().equals(METHOD_SET_JDBI_PROVIDER) && method.getParameters().length == 1;
            found4 = method.getName().equals(METHOD_GET_JDBI_PROVIDER) && method.getParameters().length == 0;
            if (found1 && found2 && found3 && found4) {
                return false;
            }
        }
        consideredClass = consideredClass.getSuperClass();
    }
    if (found1 || found2 || found3 || found4) {
        sourceUnit.getErrorCollector().addErrorAndContinue(
            new SimpleMessage("@JdbiAware cannot be processed on "
                + declaringClass.getName()
                + " because some but not all of methods from " + JdbiContributionHandler.class.getName() + " were declared in the current class or super classes.",
                sourceUnit)
        );
        return false;
    }
    return true;
}
 
开发者ID:griffon-legacy,项目名称:griffon-jdbi-plugin,代码行数:28,代码来源:JdbiAwareASTTransformation.java


示例14: addPhaseOperationsForGlobalTransforms

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private static void addPhaseOperationsForGlobalTransforms(CompilationUnit compilationUnit,
        Map<String, URL> transformNames, boolean isFirstScan) {
    GroovyClassLoader transformLoader = compilationUnit.getTransformLoader();
    for (Map.Entry<String, URL> entry : transformNames.entrySet()) {
        try {
            Class gTransClass = transformLoader.loadClass(entry.getKey(), false, true, false);
            //no inspection unchecked
            GroovyASTTransformation transformAnnotation = (GroovyASTTransformation) gTransClass.getAnnotation(GroovyASTTransformation.class);
            if (transformAnnotation == null) {
                compilationUnit.getErrorCollector().addWarning(new WarningMessage(
                    WarningMessage.POSSIBLE_ERRORS,
                    "Transform Class " + entry.getKey() + " is specified as a global transform in " + entry.getValue().toExternalForm()
                    + " but it is not annotated by " + GroovyASTTransformation.class.getName()
                    + " the global transform associated with it may fail and cause the compilation to fail.",
                    null,
                    null));
                continue;
            }
            if (ASTTransformation.class.isAssignableFrom(gTransClass)) {
                final ASTTransformation instance = (ASTTransformation)gTransClass.newInstance();
                if (instance instanceof CompilationUnitAware) {
                    ((CompilationUnitAware)instance).setCompilationUnit(compilationUnit);
                }
                CompilationUnit.SourceUnitOperation suOp = new CompilationUnit.SourceUnitOperation() {
                    public void call(SourceUnit source) throws CompilationFailedException {
                        instance.visit(new ASTNode[] {source.getAST()}, source);
                    }
                }; 
                if(isFirstScan) {
                    compilationUnit.addPhaseOperation(suOp, transformAnnotation.phase().getPhaseNumber());
                } else {
                    compilationUnit.addNewPhaseOperation(suOp, transformAnnotation.phase().getPhaseNumber());
                }
            } else {
                compilationUnit.getErrorCollector().addError(new SimpleMessage(
                    "Transform Class " + entry.getKey() + " specified at "
                    + entry.getValue().toExternalForm() + " is not an ASTTransformation.", null));
            }
        } catch (Exception e) {
            compilationUnit.getErrorCollector().addError(new SimpleMessage(
                "Could not instantiate global transform class " + entry.getKey() + " specified at "
                + entry.getValue().toExternalForm() + "  because of exception " + e.toString(), null));
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:46,代码来源:ASTTransformationVisitor.java


示例15: addLoadingError

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private void addLoadingError(final CompilerConfiguration config) {
    context.getErrorCollector().addFatalError(
            new SimpleMessage("Static type checking extension '" + scriptPath + "' could not be loaded.",
                    config.getDebug(), typeCheckingVisitor.getSourceUnit())
    );
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:GroovyTypeCheckingExtensionSupport.java


示例16: verifyClass

import org.codehaus.groovy.control.messages.SimpleMessage; //导入依赖的package包/类
private void verifyClass(AnnotationNode annotation, Class klass) {
    if (!ASTTransformation.class.isAssignableFrom(klass)) {
        source.getErrorCollector().addError(new SimpleMessage("Not an ASTTransformation: " +
                klass.getName() + " declared by " + annotation.getClassNode().getName(), source));
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:ASTTransformationCollectorCodeVisitor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DockKey类代码示例发布时间:2022-05-22
下一篇:
Java DelegationTokenIdentifier类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap