mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'origin/master'
This commit is contained in:
+2
-2
@@ -32,7 +32,7 @@ import com.intellij.psi.impl.source.DummyHolder;
|
||||
import com.intellij.psi.impl.source.PsiFileImpl;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.IStubFileElementType;
|
||||
import com.intellij.psi.tree.IFileElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.util.CharTable;
|
||||
@@ -46,7 +46,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class TemplateDataElementType extends IStubFileElementType implements ITemplateDataElementType {
|
||||
public class TemplateDataElementType extends IFileElementType implements ITemplateDataElementType {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.templateLanguages.TemplateDataElementType");
|
||||
|
||||
public static final LanguageExtension<TreePatcher> TREE_PATCHER = new LanguageExtension<TreePatcher>("com.intellij.lang.treePatcher", new SimpleTreePatcher());
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
package com.intellij.ide.projectView;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.HashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public interface RootsProvider {
|
||||
|
||||
Set<VirtualFile> EMPTY_ROOTS = new HashSet<VirtualFile>();
|
||||
Set<VirtualFile> EMPTY_ROOTS = Collections.emptySet();
|
||||
|
||||
@NotNull
|
||||
Collection<VirtualFile> getRoots();
|
||||
|
||||
+22
-4
@@ -25,7 +25,7 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.lang.*;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -34,6 +34,7 @@ import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -125,10 +126,27 @@ class InProcessGroovyc {
|
||||
return pair.second;
|
||||
}
|
||||
|
||||
ClassLoader result =
|
||||
UrlClassLoader groovyAllLoader =
|
||||
UrlClassLoader.build().urls(toUrls(Arrays.asList(GroovyBuilder.getGroovyRtRoot().getPath(), groovyAll))).useCache().get();
|
||||
ourParentLoaderCache = new SoftReference<Pair<String, ClassLoader>>(Pair.create(groovyAll, result));
|
||||
return result;
|
||||
ClassLoader wrapper = new URLClassLoader(new URL[0], groovyAllLoader) {
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
try {
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
catch (NoClassDefFoundError e) {
|
||||
// We might attempt to load some class in groovy-all.jar that depends on a class from another library
|
||||
// (e.g. GroovyTestCase extends TestCase).
|
||||
// We don't want groovyc's resolve to stop at this point.
|
||||
// Let's try in the child class loader which contains full compilation class with all libraries, including groovy-all.
|
||||
// For this to happen we should throw ClassNotFoundException
|
||||
throw new ClassNotFoundException(name, e);
|
||||
}
|
||||
}
|
||||
};
|
||||
;
|
||||
ourParentLoaderCache = new SoftReference<Pair<String, ClassLoader>>(Pair.create(groovyAll, wrapper));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -77,15 +77,15 @@ public class GroovyFacetUtil {
|
||||
}
|
||||
|
||||
public static File getBundledGroovyJar() {
|
||||
String root;
|
||||
if (new File(PathUtil.getJarPathForClass(GroovyFacetUtil.class)).isDirectory()) {
|
||||
root = FileUtil.toCanonicalPath(PluginPathManager.getPluginHomePath("groovy") + "/../../lib/");
|
||||
}
|
||||
else {
|
||||
root = PathManager.getHomePath() + "/lib/";
|
||||
}
|
||||
final File[] groovyJars = LibrariesUtil.getFilesInDirectoryByPattern(root, GroovyConfigUtils.GROOVY_ALL_JAR_PATTERN);
|
||||
final File[] groovyJars = LibrariesUtil.getFilesInDirectoryByPattern(getLibDirectory(), GroovyConfigUtils.GROOVY_ALL_JAR_PATTERN);
|
||||
assert groovyJars.length == 1;
|
||||
return groovyJars[0];
|
||||
}
|
||||
|
||||
public static String getLibDirectory() {
|
||||
if (new File(PathUtil.getJarPathForClass(GroovyFacetUtil.class)).isDirectory()) {
|
||||
return FileUtil.toCanonicalPath(PluginPathManager.getPluginHomePath("groovy") + "/../../lib/");
|
||||
}
|
||||
return PathManager.getHomePath() + "/lib/";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.psi.PsiFile
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.TestLoggerFactory
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.plugins.groovy.config.GroovyFacetUtil
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
|
||||
/**
|
||||
* @author peter
|
||||
@@ -858,6 +859,13 @@ class AppTest {
|
||||
assertTrue(exceptionFound.get());
|
||||
}
|
||||
|
||||
public void "test extend GroovyTestCase"() {
|
||||
PsiTestUtil.addLibrary(myModule, "junit", GroovyFacetUtil.libDirectory, "junit.jar");
|
||||
|
||||
myFixture.addFileToProject("a.groovy", "class Foo extends GroovyTestCase {}")
|
||||
assertEmpty(make())
|
||||
}
|
||||
|
||||
static class GroovycTest extends GroovyCompilerTest {
|
||||
public void "test navigate from stub to source"() {
|
||||
GroovyFile groovyFile = (GroovyFile) myFixture.addFileToProject("a.groovy", "class Groovy3 { InvalidType type }")
|
||||
|
||||
+25
-30
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.compiler
|
||||
|
||||
import com.intellij.debugger.DebuggerManagerEx
|
||||
import com.intellij.debugger.SourcePosition
|
||||
import com.intellij.debugger.engine.ContextUtil
|
||||
@@ -33,7 +32,6 @@ import com.intellij.debugger.impl.DebuggerSession
|
||||
import com.intellij.debugger.impl.GenericDebuggerRunner
|
||||
import com.intellij.debugger.ui.impl.watch.WatchItemDescriptor
|
||||
import com.intellij.debugger.ui.tree.render.DescriptorLabelListener
|
||||
import com.intellij.execution.configurations.RunProfile
|
||||
import com.intellij.execution.executors.DefaultDebugExecutor
|
||||
import com.intellij.execution.process.OSProcessHandler
|
||||
import com.intellij.execution.process.OSProcessManager
|
||||
@@ -48,6 +46,7 @@ import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.impl.DebugUtil
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder
|
||||
@@ -55,7 +54,6 @@ import com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl
|
||||
import com.intellij.util.SystemProperties
|
||||
import com.intellij.util.concurrency.Semaphore
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -90,11 +88,8 @@ class GroovyDebuggerTest extends GroovyCompilerTestCase {
|
||||
moduleBuilder.addJdk(StringUtil.trimEnd(StringUtil.trimEnd(javaHome, '/'), '/jre'))
|
||||
}
|
||||
|
||||
private void runDebugger(String mainClass, Closure cl) {
|
||||
runDebugger(createApplicationConfiguration(mainClass, myModule), cl)
|
||||
}
|
||||
private void runDebugger(RunProfile configuration, Closure cl) {
|
||||
make()
|
||||
private void runDebugger(PsiFile script, Closure cl) {
|
||||
def configuration = createScriptConfiguration(script.virtualFile.path, myModule)
|
||||
edt {
|
||||
ProgramRunner runner = ProgramRunner.PROGRAM_RUNNER_EP.extensions.find { it.class == GenericDebuggerRunner }
|
||||
def listener = [onTextAvailable: { ProcessEvent evt, type -> /*println evt.text*/}] as ProcessAdapter
|
||||
@@ -118,10 +113,10 @@ class GroovyDebuggerTest extends GroovyCompilerTestCase {
|
||||
}
|
||||
|
||||
public void testVariableInScript() {
|
||||
myFixture.addFileToProject("Foo.groovy", """def a = 2
|
||||
def file = myFixture.addFileToProject("Foo.groovy", """def a = 2
|
||||
a""");
|
||||
addBreakpoint 'Foo.groovy', 1
|
||||
runDebugger 'Foo', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'a', '2'
|
||||
eval '2?:3', '2'
|
||||
@@ -130,7 +125,7 @@ a""");
|
||||
}
|
||||
|
||||
public void testVariableInsideClosure() {
|
||||
myFixture.addFileToProject("Foo.groovy", """def a = 2
|
||||
def file = myFixture.addFileToProject("Foo.groovy", """def a = 2
|
||||
Closure c = {
|
||||
a++;
|
||||
a //3
|
||||
@@ -138,7 +133,7 @@ Closure c = {
|
||||
c()
|
||||
a++""");
|
||||
addBreakpoint 'Foo.groovy', 3
|
||||
runDebugger 'Foo', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'a', '3'
|
||||
}
|
||||
@@ -162,7 +157,7 @@ class Foo {
|
||||
}""")
|
||||
|
||||
|
||||
myFixture.addFileToProject("com/Bar.groovy", """package com
|
||||
def file = myFixture.addFileToProject("com/Bar.groovy", """package com
|
||||
import static com.Goo.*
|
||||
|
||||
def lst = [new Foo()] as Set
|
||||
@@ -170,7 +165,8 @@ println 2 //4
|
||||
""")
|
||||
|
||||
addBreakpoint 'com/Bar.groovy', 4
|
||||
runDebugger 'com.Bar', {
|
||||
make()
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'Foo.bar', '2'
|
||||
eval 'mainConstant', '42'
|
||||
@@ -183,7 +179,7 @@ println 2 //4
|
||||
}
|
||||
|
||||
public void testCall() {
|
||||
myFixture.addFileToProject 'B.groovy', '''class B {
|
||||
def file = myFixture.addFileToProject 'B.groovy', '''class B {
|
||||
def getFoo() {2}
|
||||
|
||||
def call(Object... args){
|
||||
@@ -195,7 +191,7 @@ println 2 //4
|
||||
}
|
||||
}'''
|
||||
addBreakpoint 'B.groovy', 4
|
||||
runDebugger 'B', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'foo', '2'
|
||||
eval 'getFoo()', '2'
|
||||
@@ -209,7 +205,7 @@ println 2 //4
|
||||
}
|
||||
|
||||
public void testStaticContext() {
|
||||
myFixture.addFileToProject 'B.groovy', '''
|
||||
def file = myFixture.addFileToProject 'B.groovy', '''
|
||||
class B {
|
||||
public static void main(String[] args) {
|
||||
def cl = { a ->
|
||||
@@ -221,7 +217,7 @@ class B {
|
||||
}'''
|
||||
addBreakpoint 'B.groovy', 4
|
||||
addBreakpoint 'B.groovy', 7
|
||||
runDebugger 'B', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'args.size()', '0'
|
||||
eval 'cl.delegate.size()', '6'
|
||||
@@ -237,7 +233,7 @@ class B {
|
||||
}
|
||||
|
||||
public void "test closures in instance context with delegation"() {
|
||||
myFixture.addFileToProject 'B.groovy', '''
|
||||
def file = myFixture.addFileToProject 'B.groovy', '''
|
||||
def cl = { a ->
|
||||
hashCode() //2
|
||||
}
|
||||
@@ -247,7 +243,7 @@ cl(42) // 5
|
||||
def getFoo() { 13 }
|
||||
'''
|
||||
addBreakpoint 'B.groovy', 2
|
||||
runDebugger 'B', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'a', '42'
|
||||
eval 'size()', '6'
|
||||
@@ -286,13 +282,12 @@ static def foo(def a) {
|
||||
|
||||
addBreakpoint(myClass, 5)
|
||||
|
||||
myFixture.addFileToProject("Foo.groovy", """
|
||||
def file = myFixture.addFileToProject("Foo.groovy", """
|
||||
def cl = new GroovyClassLoader()
|
||||
cl.parseClass('''$mcText''', 'MyClass.groovy').foo(2)
|
||||
""")
|
||||
make()
|
||||
|
||||
runDebugger 'Foo', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
assert myClass == sourcePosition.file.virtualFile
|
||||
eval 'a', '2'
|
||||
@@ -308,7 +303,7 @@ cl.parseClass('''$mcText''', 'MyClass.groovy').foo(2)
|
||||
}
|
||||
|
||||
void testAnonymousClassInScript() {
|
||||
myFixture.addFileToProject('Foo.groovy', '''\
|
||||
def file = myFixture.addFileToProject('Foo.groovy', '''\
|
||||
new Runnable() {
|
||||
void run() {
|
||||
print 'foo'
|
||||
@@ -317,14 +312,14 @@ new Runnable() {
|
||||
|
||||
''')
|
||||
addBreakpoint 'Foo.groovy', 2
|
||||
runDebugger 'Foo', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval '1+1', '2'
|
||||
}
|
||||
}
|
||||
|
||||
void testEvalInStaticMethod() {
|
||||
myFixture.addFileToProject('Foo.groovy', '''\
|
||||
def file = myFixture.addFileToProject('Foo.groovy', '''\
|
||||
static def foo() {
|
||||
int x = 5
|
||||
print x
|
||||
@@ -334,7 +329,7 @@ foo()
|
||||
|
||||
''')
|
||||
addBreakpoint 'Foo.groovy', 2
|
||||
runDebugger 'Foo', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'x', '5'
|
||||
}
|
||||
@@ -353,14 +348,14 @@ foo()
|
||||
myFixture.addFileToProject('module2/Scr.groovy', 'println "hello"')
|
||||
|
||||
addBreakpoint('module1/Scr.groovy', 0)
|
||||
runDebugger(createScriptConfiguration(scr.virtualFile.path, myModule)) {
|
||||
runDebugger(scr) {
|
||||
waitForBreakpoint()
|
||||
assert scr == sourcePosition.file
|
||||
}
|
||||
}
|
||||
|
||||
public void "test in static inner class"() {
|
||||
myFixture.addFileToProject "Foo.groovy", """
|
||||
def file = myFixture.addFileToProject "Foo.groovy", """
|
||||
class Outer { //1
|
||||
static class Inner {
|
||||
def x = 1
|
||||
@@ -385,7 +380,7 @@ public static void main(String[] args) {
|
||||
}
|
||||
"""
|
||||
addBreakpoint('Foo.groovy', 6)
|
||||
runDebugger 'Foo', {
|
||||
runDebugger file, {
|
||||
waitForBreakpoint()
|
||||
eval 'x', '1'
|
||||
eval 'this', 'str'
|
||||
|
||||
Reference in New Issue
Block a user