org.codehaus.groovy.vmplugin.v5.Java5 Maven / Gradle / Ivy
/*
* Copyright 2003-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.groovy.vmplugin.v5;
import java.lang.reflect.*;
import org.codehaus.groovy.GroovyBugError;
import org.codehaus.groovy.vmplugin.VMPlugin;
import org.codehaus.groovy.ast.*;
/**
* java 5 based functions
* @author Jochen Theodorou
*
*/
public class Java5 implements VMPlugin {
private static Class[] PLUGIN_DGM={PluginDefaultGroovyMethods.class};
public void setGenericsTypes(ClassNode cn) {
TypeVariable[] tvs = cn.getTypeClass().getTypeParameters();
GenericsType[] gts = configureTypeVariable(tvs);
cn.setGenericsTypes(gts);
}
private GenericsType[] configureTypeVariable(TypeVariable[] tvs) {
if (tvs.length==0) return null;
GenericsType[] gts = new GenericsType[tvs.length];
for (int i = 0; i < tvs.length; i++) {
gts[i] = configureTypeVariableDefintion(tvs[i]);
}
return gts;
}
private GenericsType configureTypeVariableDefintion(TypeVariable tv) {
ClassNode base = configureTypeVariableReference(tv);
ClassNode redirect = base.redirect();
base.setRedirect(null);
Type[] tBounds = tv.getBounds();
GenericsType gt;
if (tBounds.length==0) {
gt = new GenericsType(base);
} else {
ClassNode[] cBounds = configureTypes(tBounds);
gt = new GenericsType(base,cBounds,null);
gt.setName(base.getName());
gt.setPlaceholder(true);
}
base.setRedirect(redirect);
return gt;
}
private ClassNode[] configureTypes(Type[] types){
if (types.length==0) return null;
ClassNode[] nodes = new ClassNode[types.length];
for (int i=0; i0) {
params = new Parameter[types.length];
for (int i=0;i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy