mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Add tests for CompilationUnit's subtypes
This commit is contained in:
@@ -81,5 +81,15 @@ public class GroovyCompilationUnitTest extends HttpServlet {
|
||||
cu.addSource(su);
|
||||
cu.compile(); // Safe
|
||||
}
|
||||
{
|
||||
JavaAwareCompilationUnit cu = new JavaAwareCompilationUnit();
|
||||
cu.addSource("test", request.getParameter("source"));
|
||||
cu.compile(); // $hasGroovyInjection
|
||||
}
|
||||
{
|
||||
JavaStubCompilationUnit cu = new JavaStubCompilationUnit(null, null);
|
||||
cu.addSource("test", request.getParameter("source"));
|
||||
cu.compile(); // Safe - JavaStubCompilationUnit only creates stubs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you 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.tools.javac;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
import org.codehaus.groovy.control.CompilationUnit;
|
||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||
import java.io.File;
|
||||
|
||||
public class JavaAwareCompilationUnit extends CompilationUnit {
|
||||
public JavaAwareCompilationUnit() {}
|
||||
|
||||
public JavaAwareCompilationUnit(final CompilerConfiguration configuration) {}
|
||||
|
||||
public JavaAwareCompilationUnit(final CompilerConfiguration configuration,
|
||||
final GroovyClassLoader groovyClassLoader) {}
|
||||
|
||||
public JavaAwareCompilationUnit(final CompilerConfiguration configuration,
|
||||
final GroovyClassLoader groovyClassLoader, final GroovyClassLoader transformClassLoader) {}
|
||||
|
||||
@Override
|
||||
public void addSources(final String[] paths) {}
|
||||
|
||||
@Override
|
||||
public void addSources(final File[] files) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you 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.tools.javac;
|
||||
|
||||
import groovy.lang.GroovyClassLoader;
|
||||
import org.codehaus.groovy.control.CompilationFailedException;
|
||||
import org.codehaus.groovy.control.CompilationUnit;
|
||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||
import org.codehaus.groovy.control.SourceUnit;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
public class JavaStubCompilationUnit extends CompilationUnit {
|
||||
public JavaStubCompilationUnit(final CompilerConfiguration config, final GroovyClassLoader gcl,
|
||||
File destDir) {}
|
||||
|
||||
public JavaStubCompilationUnit(final CompilerConfiguration config, final GroovyClassLoader gcl) {}
|
||||
|
||||
public int getStubCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compile() throws CompilationFailedException {}
|
||||
|
||||
@Override
|
||||
public SourceUnit addSource(final File file) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceUnit addSource(URL url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user