use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class GroovyPositionManager method getAllClasses.
@Override
@NotNull
public List<ReferenceType> getAllClasses(@NotNull final SourcePosition position) throws NoDataException {
if (LOG.isDebugEnabled()) {
LOG.debug("getAllClasses: " + position);
}
checkGroovyFile(position);
List<ReferenceType> result = ApplicationManager.getApplication().runReadAction(new Computable<List<ReferenceType>>() {
@Override
public List<ReferenceType> compute() {
GroovyPsiElement sourceImage = findReferenceTypeSourceImage(position);
if (sourceImage instanceof GrTypeDefinition && !((GrTypeDefinition) sourceImage).isAnonymous()) {
String qName = getClassNameForJvm((GrTypeDefinition) sourceImage);
if (qName != null)
return myDebugProcess.getVirtualMachineProxy().classesByName(qName);
} else if (sourceImage == null) {
final String scriptName = getScriptQualifiedName(position);
if (scriptName != null)
return myDebugProcess.getVirtualMachineProxy().classesByName(scriptName);
} else {
String enclosingName = findEnclosingName(position);
if (enclosingName == null)
return null;
final List<ReferenceType> outers = myDebugProcess.getVirtualMachineProxy().classesByName(enclosingName);
final List<ReferenceType> result = new ArrayList<>(outers.size());
for (ReferenceType outer : outers) {
final ReferenceType nested = findNested(outer, sourceImage, position);
if (nested != null) {
result.add(nested);
}
}
return result;
}
return null;
}
});
if (LOG.isDebugEnabled()) {
LOG.debug("getAllClasses = " + result);
}
if (result == null)
throw NoDataException.INSTANCE;
return result;
}
use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class GroovyPositionManager method createPrepareRequest.
@Override
public ClassPrepareRequest createPrepareRequest(@NotNull final ClassPrepareRequestor requestor, @NotNull final SourcePosition position) throws NoDataException {
if (LOG.isDebugEnabled()) {
LOG.debug("createPrepareRequest: " + position);
}
checkGroovyFile(position);
String qName = getOuterClassName(position);
if (qName != null) {
return myDebugProcess.getRequestsManager().createClassPrepareRequest(requestor, qName);
}
qName = findEnclosingName(position);
if (qName == null)
throw NoDataException.INSTANCE;
ClassPrepareRequestor waitRequestor = new ClassPrepareRequestor() {
@Override
public void processClassPrepare(DebugProcess debuggerProcess, ReferenceType referenceType) {
final CompoundPositionManager positionManager = ((DebugProcessImpl) debuggerProcess).getPositionManager();
if (!positionManager.locationsOfLine(referenceType, position).isEmpty()) {
requestor.processClassPrepare(debuggerProcess, referenceType);
}
}
};
return myDebugProcess.getRequestsManager().createClassPrepareRequest(waitRequestor, qName + "$*");
}
use of com.sun.jdi.ReferenceType in project intellij-community by JetBrains.
the class GroovyPositionManager method getPsiFileByLocation.
@Nullable
private PsiFile getPsiFileByLocation(@NotNull final Project project, @Nullable final Location location) {
if (location == null)
return null;
final ReferenceType refType = location.declaringType();
if (refType == null)
return null;
final String originalQName = refType.name().replace('/', '.');
int dollar = originalQName.indexOf('$');
String runtimeName = dollar >= 0 ? originalQName.substring(0, dollar) : originalQName;
String qName = getOriginalQualifiedName(refType, runtimeName);
GlobalSearchScope searchScope = myDebugProcess.getSearchScope();
GroovyShortNamesCache cache = GroovyShortNamesCache.getGroovyShortNamesCache(project);
try {
List<PsiClass> classes = cache.getClassesByFQName(qName, searchScope, true);
if (classes.isEmpty()) {
classes = cache.getClassesByFQName(qName, searchScope, false);
}
if (classes.isEmpty()) {
classes = cache.getClassesByFQName(qName, GlobalSearchScope.projectScope(project), false);
}
if (classes.isEmpty()) {
classes = cache.getClassesByFQName(qName, addModuleContent(searchScope), false);
}
if (classes.isEmpty())
return null;
classes.sort(PsiClassUtil.createScopeComparator(searchScope));
PsiClass clazz = classes.get(0);
if (clazz != null)
return clazz.getContainingFile();
} catch (ProcessCanceledException | IndexNotReadyException e) {
return null;
}
return getExtraScriptIfNotFound(project, refType, runtimeName, searchScope);
}
use of com.sun.jdi.ReferenceType in project kotlin by JetBrains.
the class AbstractPositionManagerTest method getReferenceMap.
private static Map<String, ReferenceType> getReferenceMap(OutputFileCollection outputFiles) {
Map<String, ReferenceType> referencesByName = Maps.newHashMap();
for (OutputFile outputFile : outputFiles.asList()) {
String classFileName = outputFile.getRelativePath();
String name = classFileName.substring(0, classFileName.lastIndexOf('.'));
referencesByName.put(name, new MockReferenceType(name));
}
return referencesByName;
}
use of com.sun.jdi.ReferenceType in project kotlin by JetBrains.
the class AbstractPositionManagerTest method performTest.
private void performTest() {
Project project = getProject();
List<KtFile> files = new ArrayList<KtFile>(PluginJetFilesProvider.allFilesInProject(project));
if (files.isEmpty())
return;
final List<Breakpoint> breakpoints = Lists.newArrayList();
for (KtFile file : files) {
breakpoints.addAll(extractBreakpointsInfo(file, file.getText()));
}
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK);
// TODO: delete this once IDEVirtualFileFinder supports loading .kotlin_builtins files
configuration.put(JVMConfigurationKeys.ADD_BUILT_INS_FROM_COMPILER_TO_DEPENDENCIES, true);
GenerationState state = GenerationUtils.compileFiles(files, configuration, new Function1<GlobalSearchScope, PackagePartProvider>() {
@Override
public PackagePartProvider invoke(GlobalSearchScope scope) {
return PackagePartProvider.Empty.INSTANCE;
}
});
Map<String, ReferenceType> referencesByName = getReferenceMap(state.getFactory());
debugProcess = createDebugProcess(referencesByName);
final PositionManager positionManager = createPositionManager(debugProcess, files, state);
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
try {
for (Breakpoint breakpoint : breakpoints) {
assertBreakpointIsHandledCorrectly(breakpoint, positionManager);
}
} catch (NoDataException e) {
throw ExceptionUtilsKt.rethrow(e);
}
}
});
}
Aggregations