本文整理了Java中org.codehaus.groovy.ast.AnnotationNode.getColumnNumber()
方法的一些代码示例,展示了AnnotationNode.getColumnNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotationNode.getColumnNumber()
方法的具体详情如下:
包路径:org.codehaus.groovy.ast.AnnotationNode
类名称:AnnotationNode
方法名:getColumnNumber
暂无
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Handles the bulk of the processing, mostly delegating to other methods.
*
* @param nodes the AST nodes
* @param source the source unit for the nodes
*/
public void visit(ASTNode[] nodes, SourceUnit source) {
if (!(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
}
AnnotationNode node = (AnnotationNode) nodes[0];
if (nodes[1] instanceof ClassNode) {
addListenerToClass(source, (ClassNode) nodes[1]);
} else {
if ((((FieldNode)nodes[1]).getModifiers() & Opcodes.ACC_FINAL) != 0) {
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.beans.Vetoable cannot annotate a final property.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
}
addListenerToProperty(source, node, (AnnotatedNode) nodes[1]);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
private static ClassNode getTargetClass(SourceUnit source, AnnotationNode annotation) {
Expression value = annotation.getMember("value");
if (!(value instanceof ClassExpression)) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.lang.Category must define 'value' which is the class to apply this category to",
annotation.getLineNumber(), annotation.getColumnNumber(), annotation.getLastLineNumber(), annotation.getLastColumnNumber()),
source));
return null;
} else {
ClassExpression ce = (ClassExpression) value;
return ce.getType();
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
private void addListenerToProperty(SourceUnit source, AnnotationNode node, ClassNode declaringClass, FieldNode field) {
String fieldName = field.getName();
for (PropertyNode propertyNode : declaringClass.getProperties()) {
if (propertyNode.getName().equals(fieldName)) {
if (field.isStatic()) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.beans.Bindable cannot annotate a static property.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
} else {
if (needsPropertyChangeSupport(declaringClass, source)) {
addPropertyChangeSupport(declaringClass);
}
createListenerSetter(declaringClass, propertyNode);
}
return;
}
}
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.beans.Bindable must be on a property, not a field. Try removing the private, protected, or public modifier.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
}
代码示例来源:origin: org.codehaus.groovy/groovy
private void addListenerToProperty(SourceUnit source, AnnotationNode node, AnnotatedNode parent) {
ClassNode declaringClass = parent.getDeclaringClass();
FieldNode field = ((FieldNode) parent);
String fieldName = field.getName();
for (PropertyNode propertyNode : declaringClass.getProperties()) {
boolean bindable = BindableASTTransformation.hasBindableAnnotation(parent)
|| BindableASTTransformation.hasBindableAnnotation(parent.getDeclaringClass());
if (propertyNode.getName().equals(fieldName)) {
if (field.isStatic()) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.beans.Vetoable cannot annotate a static property.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
} else {
createListenerSetter(source, bindable, declaringClass, propertyNode);
}
return;
}
}
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.beans.Vetoable must be on a property, not a field. Try removing the private, protected, or public modifier.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
}
代码示例来源:origin: org.codehaus.groovy/groovy
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@groovy.beans.Bindable cannot annotate a final property.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal
protected void addError(String msg) {
this.errorCollector.addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(msg
+ " in @" + this.annotationClass.getName() + '\n',
this.annotation.getLineNumber(),
this.annotation.getColumnNumber()), this.source)
);
}
代码示例来源:origin: org.codehaus.groovyfx/groovyfx
/**
* Generates a SyntaxErrorMessage based on the current SourceUnit, AnnotationNode, and a specified
* error message.
*
* @param sourceUnit The SourceUnit
* @param node The node that was annotated
* @param msg The error message to display
*/
private void generateSyntaxErrorMessage(SourceUnit sourceUnit, AnnotationNode node, String msg) {
SyntaxException error = new SyntaxException(msg, node.getLineNumber(), node.getColumnNumber());
sourceUnit.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(error, sourceUnit));
}
代码示例来源:origin: org.codehaus.griffon/griffon-groovy-compile
/**
* Generates a SyntaxErrorMessage based on the current SourceUnit, AnnotationNode, and a specified
* error message.
*
* @param sourceUnit The SourceUnit
* @param node The node that was annotated
* @param msg The error message to display
*/
private void generateSyntaxErrorMessage(SourceUnit sourceUnit, AnnotationNode node, String msg) {
SyntaxException error = new SyntaxException(msg, node.getLineNumber(), node.getColumnNumber());
sourceUnit.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(error, sourceUnit));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor
private static OffsetRange getAnnotationRange(AnnotationNode annotation, BaseDocument doc, int cursorOffset) {
final int offset = ASTUtils.getOffset(doc, annotation.getLineNumber(), annotation.getColumnNumber());
final OffsetRange range = ASTUtils.getNextIdentifierByName(doc, annotation.getClassNode().getNameWithoutPackage(), offset);
if (range.containsInclusive(cursorOffset)) {
return range;
}
return OffsetRange.NONE;
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
private ClassNode getTargetClass(SourceUnit source, AnnotationNode annotation) {
final Expression value = annotation.getMember("value");
if (value == null || !(value instanceof ClassExpression)) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.lang.Category must define 'value' which is the class to apply this category to",
annotation.getLineNumber(),
annotation.getColumnNumber()),
source));
}
return value != null ? value.getType() : null;
}
}
代码示例来源:origin: org.kohsuke.droovy/groovy
private ClassNode getTargetClass(SourceUnit source, AnnotationNode annotation) {
final Expression value = annotation.getMember("value");
if (value == null || !(value instanceof ClassExpression)) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.lang.Category must define 'value' which is class to apply this category",
annotation.getLineNumber(),
annotation.getColumnNumber()),
source));
}
ClassNode targetClass = ((ClassExpression)value).getType();
return targetClass;
}
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
/**
* Handles the bulk of the processing, mostly delegating to other methods.
*
* @param nodes the AST nodes
* @param source the source unit for the nodes
*/
public void visit(ASTNode[] nodes, SourceUnit source) {
if (!(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
}
AnnotationNode node = (AnnotationNode) nodes[0];
if (nodes[1] instanceof ClassNode) {
addListenerToClass(source, node, (ClassNode) nodes[1]);
} else {
if ((((FieldNode)nodes[1]).getModifiers() & Opcodes.ACC_FINAL) != 0) {
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.beans.Vetoable cannot annotate a final property.",
node.getLineNumber(),
node.getColumnNumber()),
source));
}
addListenerToProperty(source, node, (AnnotatedNode) nodes[1]);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor
private void addAnnotationOccurrences(AnnotationNode annotation, ClassNode findingNode) {
ClassNode classNode = annotation.getClassNode();
classNode.setLineNumber(annotation.getLineNumber());
classNode.setColumnNumber(annotation.getColumnNumber());
classNode.setLastLineNumber(annotation.getLastLineNumber());
classNode.setLastColumnNumber(annotation.getLastColumnNumber());
addOccurrences(classNode, findingNode);
}
代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm
private ClassNode getTargetClass(SourceUnit source, AnnotationNode annotation) {
Expression value = annotation.getMember("value");
if (value == null || !(value instanceof ClassExpression)) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.lang.Category must define 'value' which is the class to apply this category to",
annotation.getLineNumber(),
annotation.getColumnNumber()),
source));
return null;
} else {
ClassExpression ce = (ClassExpression) value;
return ce.getType();
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
/**
* Handles the bulk of the processing, mostly delegating to other methods.
*
* @param nodes the AST nodes
* @param source the source unit for the nodes
*/
public void visit(ASTNode[] nodes, SourceUnit source) {
if (!(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
}
AnnotationNode node = (AnnotationNode) nodes[0];
if (nodes[1] instanceof ClassNode) {
addListenerToClass(source, node, (ClassNode) nodes[1]);
} else {
if ((((FieldNode)nodes[1]).getModifiers() & Opcodes.ACC_FINAL) != 0) {
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.beans.Vetoable cannot annotate a final property.",
node.getLineNumber(),
node.getColumnNumber()),
source));
}
addListenerToProperty(source, node, (AnnotatedNode) nodes[1]);
}
}
代码示例来源:origin: org.codehaus.griffon/griffon-groovy-compile
/**
* Handles the bulk of the processing, mostly delegating to other methods.
*
* @param nodes the ast nodes
* @param source the source unit for the nodes
*/
public void visit(ASTNode[] nodes, SourceUnit source) {
if (!(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
}
AnnotationNode node = (AnnotationNode) nodes[0];
if (nodes[1] instanceof ClassNode) {
addVetoableIfNeeded(source, (ClassNode) nodes[1]);
} else {
if ((((FieldNode) nodes[1]).getModifiers() & Modifier.FINAL) != 0) {
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@griffon.transform.Vetoable cannot annotate a final property.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
}
addVetoableIfNeeded(source, node, (AnnotatedNode) nodes[1]);
}
}
代码示例来源:origin: org.codehaus.groovy/groovy-jdk14
private void addListenerToProperty(SourceUnit source, AnnotationNode node, ClassNode declaringClass, FieldNode field) {
String fieldName = field.getName();
for (PropertyNode propertyNode : (Collection<PropertyNode>) declaringClass.getProperties()) {
if (propertyNode.getName().equals(fieldName)) {
if (field.isStatic()) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.beans.Bindable cannot annotate a static property.",
node.getLineNumber(),
node.getColumnNumber()),
source));
} else {
if (needsPropertyChangeSupport(declaringClass, source)) {
addPropertyChangeSupport(declaringClass);
}
createListenerSetter(source, node, declaringClass, propertyNode);
}
return;
}
}
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.beans.Bindable must be on a property, not a field. Try removing the private, protected, or public modifier.",
node.getLineNumber(),
node.getColumnNumber()),
source));
}
代码示例来源:origin: org.codehaus.griffon/griffon-groovy-compile
public static void addObservableIfNeeded(SourceUnit source, AnnotationNode annotationNode, ClassNode classNode, FieldNode field) {
String fieldName = field.getName();
for (PropertyNode propertyNode : classNode.getProperties()) {
if (propertyNode.getName().equals(fieldName)) {
if (field.isStatic()) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@griffon.transform.Observable cannot annotate a static property.",
annotationNode.getLineNumber(), annotationNode.getColumnNumber(), annotationNode.getLastLineNumber(), annotationNode.getLastColumnNumber()),
source));
} else {
if (needsObservableSupport(classNode, source)) {
LOG.debug("Injecting {} into {}", OBSERVABLE_TYPE, classNode.getName());
apply(classNode);
}
createListenerSetter(classNode, propertyNode);
}
return;
}
}
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@griffon.transform.Observable must be on a property, not a field. Try removing the private, protected, or public modifier.",
annotationNode.getLineNumber(), annotationNode.getColumnNumber(), annotationNode.getLastLineNumber(), annotationNode.getLastColumnNumber()),
source));
}
代码示例来源:origin: org.kohsuke.droovy/groovy
private void addListenerToProperty(SourceUnit source, AnnotationNode node, AnnotatedNode parent) {
ClassNode declaringClass = parent.getDeclaringClass();
FieldNode field = ((FieldNode) parent);
String fieldName = field.getName();
for (PropertyNode propertyNode : (Collection<PropertyNode>) declaringClass.getProperties()) {
boolean bindable = BindableASTTransformation.hasBindableAnnotation(parent)
|| BindableASTTransformation.hasBindableAnnotation(parent.getDeclaringClass());
if (propertyNode.getName().equals(fieldName)) {
if (field.isStatic()) {
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.beans.Vetoable cannot annotate a static property.",
node.getLineNumber(),
node.getColumnNumber()),
source));
} else {
createListenerSetter(source, node, bindable, declaringClass, propertyNode);
}
return;
}
}
//noinspection ThrowableInstanceNeverThrown
source.getErrorCollector().addErrorAndContinue(
new SyntaxErrorMessage(new SyntaxException(
"@groovy.beans.Vetoable must be on a property, not a field. Try removing the private, protected, or public modifier.",
node.getLineNumber(),
node.getColumnNumber()),
source));
}
代码示例来源:origin: org.codehaus.griffon/griffon-groovy-compile
private void addVetoableIfNeeded(SourceUnit source, AnnotationNode node, AnnotatedNode parent) {
ClassNode declaringClass = parent.getDeclaringClass();
FieldNode field = ((FieldNode) parent);
String fieldName = field.getName();
for (PropertyNode propertyNode : declaringClass.getProperties()) {
boolean bindable = hasObservableAnnotation(parent)
|| hasObservableAnnotation(parent.getDeclaringClass());
if (propertyNode.getName().equals(fieldName)) {
if (field.isStatic()) {
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@griffon.transform.Vetoable cannot annotate a static property.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
} else {
createListenerSetter(source, bindable, declaringClass, propertyNode);
}
return;
}
}
source.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(
new SyntaxException("@griffon.transform.Vetoable must be on a property, not a field. Try removing the private, protected, or public modifier.",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()),
source));
}
内容来源于网络,如有侵权,请联系作者删除!