use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class PyClassInheritorsSearchExecutor method processDirectInheritors.
private static boolean processDirectInheritors(final PyClass superClass, final Processor<PyClass> consumer, final boolean checkDeep, final Set<PyClass> processed) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
final String superClassName = superClass.getName();
// we don't want to look for inheritors of overly general classes
if (superClassName == null || IGNORED_BASES.contains(superClassName))
return true;
if (processed.contains(superClass))
return true;
processed.add(superClass);
Project project = superClass.getProject();
final Collection<PyClass> candidates = StubIndex.getElements(PySuperClassIndex.KEY, superClassName, project, ProjectScope.getAllScope(project), PyClass.class);
for (PyClass candidate : candidates) {
final PyClass[] classes = candidate.getSuperClasses(null);
for (PyClass superClassCandidate : classes) {
if (superClassCandidate.isEquivalentTo(superClass)) {
if (!consumer.process(candidate)) {
return false;
}
if (checkDeep && !processDirectInheritors(candidate, consumer, checkDeep, processed))
return false;
break;
}
}
}
} finally {
accessToken.finish();
}
return true;
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class StartBrowserPanel method virtualFileToUrl.
@Nullable
private static Url virtualFileToUrl(@NotNull VirtualFile file, @NotNull Project project) {
PsiFile psiFile;
AccessToken token = ReadAction.start();
try {
psiFile = PsiManager.getInstance(project).findFile(file);
} finally {
token.finish();
}
return WebBrowserServiceImpl.getDebuggableUrl(psiFile);
}
use of com.intellij.openapi.application.AccessToken in project kotlin by JetBrains.
the class VfsTestUtil method createFileOrDir.
private static VirtualFile createFileOrDir(VirtualFile root, String relativePath, String text, boolean dir) {
try {
AccessToken token = WriteAction.start();
try {
VirtualFile parent = root;
Assert.assertNotNull(parent);
StringTokenizer parents = new StringTokenizer(PathUtil.getParentPath(relativePath), "/");
while (parents.hasMoreTokens()) {
String name = parents.nextToken();
VirtualFile child = parent.findChild(name);
if (child == null || !child.isValid()) {
child = parent.createChildDirectory(VfsTestUtil.class, name);
}
parent = child;
}
VirtualFile file;
//need this to ensure that fileCreated event is fired
parent.getChildren();
if (dir) {
file = parent.createChildDirectory(VfsTestUtil.class, PathUtil.getFileName(relativePath));
} else {
file = parent.findFileByRelativePath(relativePath);
if (file == null) {
file = parent.createChildData(VfsTestUtil.class, PathUtil.getFileName(relativePath));
}
VfsUtil.saveText(file, text);
}
return file;
} finally {
token.finish();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.intellij.openapi.application.AccessToken in project kotlin by JetBrains.
the class ExternalSystemImportingTestCase method getModule.
@Override
protected Module getModule(String name) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
Module m = ModuleManager.getInstance(myProject).findModuleByName(name);
assertNotNull("Module " + name + " not found", m);
return m;
} finally {
accessToken.finish();
}
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class PyDebugProcess method runToPosition.
@Override
public void runToPosition(@NotNull final XSourcePosition position, @Nullable XSuspendContext context) {
dropFrameCaches();
if (isConnected() && !mySuspendedThreads.isEmpty()) {
final PySourcePosition pyPosition = myPositionConverter.convertToPython(position);
String type = PyLineBreakpointType.ID;
AccessToken lock = ApplicationManager.getApplication().acquireReadActionLock();
try {
final Document document = FileDocumentManager.getInstance().getDocument(position.getFile());
if (document != null) {
for (XBreakpointType breakpointType : Extensions.getExtensions(XBreakpointType.EXTENSION_POINT_NAME)) {
if (breakpointType instanceof PyBreakpointType && ((PyBreakpointType) breakpointType).canPutInDocument(getSession().getProject(), document)) {
type = breakpointType.getId();
break;
}
}
}
} finally {
lock.finish();
}
myDebugger.setTempBreakpoint(type, pyPosition.getFile(), pyPosition.getLine());
passToCurrentThread(context, ResumeOrStepCommand.Mode.RESUME);
}
}
Aggregations