use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class MavenModuleImporter method configDependencies.
private void configDependencies() {
THashSet<String> dependencyTypesFromSettings = new THashSet<>();
AccessToken accessToken = ReadAction.start();
try {
if (myModule.getProject().isDisposed())
return;
dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myModule.getProject()).getImportingSettings().getDependencyTypesAsSet());
} finally {
accessToken.finish();
}
for (MavenArtifact artifact : myMavenProject.getDependencies()) {
String dependencyType = artifact.getType();
if (!dependencyTypesFromSettings.contains(dependencyType) && !myMavenProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
continue;
}
DependencyScope scope = selectScope(artifact.getScope());
MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
if (depProject != null) {
if (depProject == myMavenProject)
continue;
String moduleName = myMavenProjectToModuleName.get(depProject);
if (moduleName == null || myMavenTree.isIgnored(depProject)) {
MavenArtifact projectsArtifactInRepository = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
myRootModelAdapter.addLibraryDependency(projectsArtifactInRepository, scope, myModifiableModelsProvider, myMavenProject);
} else {
boolean isTestJar = MavenConstants.TYPE_TEST_JAR.equals(dependencyType) || "tests".equals(artifact.getClassifier());
myRootModelAdapter.addModuleDependency(moduleName, scope, isTestJar);
Element buildHelperCfg = depProject.getPluginGoalConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "attach-artifact");
if (buildHelperCfg != null) {
addAttachArtifactDependency(buildHelperCfg, scope, depProject, artifact);
}
if (IMPORTED_CLASSIFIERS.contains(artifact.getClassifier()) && !isTestJar && !"system".equals(artifact.getScope()) && !"false".equals(System.getProperty("idea.maven.classifier.dep"))) {
MavenArtifact a = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
myRootModelAdapter.addLibraryDependency(a, scope, myModifiableModelsProvider, myMavenProject);
}
}
} else if ("system".equals(artifact.getScope())) {
myRootModelAdapter.addSystemDependency(artifact, scope);
} else {
myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
}
}
configSurefirePlugin();
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class MavenRootModelAdapter method addModuleDependency.
public void addModuleDependency(@NotNull String moduleName, @NotNull DependencyScope scope, boolean testJar) {
Module m = findModuleByName(moduleName);
ModuleOrderEntry e;
if (m != null) {
e = myRootModel.addModuleOrderEntry(m);
} else {
AccessToken accessToken = ReadAction.start();
try {
e = myRootModel.addInvalidModuleEntry(moduleName);
} finally {
accessToken.finish();
}
}
e.setScope(scope);
if (testJar) {
((ModuleOrderEntryImpl) e).setProductionOnTestDependency(true);
}
if (myOrderEntriesBeforeJdk.contains(moduleName)) {
moveLastOrderEntryBeforeJdk();
}
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class MavenJDOMUtil method read.
@Nullable
public static Element read(final VirtualFile file, @Nullable final ErrorHandler handler) {
String text;
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
if (!file.isValid())
return null;
try {
text = VfsUtilCore.loadText(file);
} catch (IOException e) {
if (handler != null)
handler.onReadError(e);
return null;
}
} finally {
accessToken.finish();
}
return doRead(text, handler);
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class PyInitReferenceSearchExecutor method processQuery.
public void processQuery(@NotNull ReferencesSearch.SearchParameters queryParameters, @NotNull final Processor<PsiReference> consumer) {
PsiElement element = queryParameters.getElementToSearch();
if (!(element instanceof PyFunction)) {
return;
}
final AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
String className;
SearchScope searchScope;
PyFunction function;
try {
function = (PyFunction) element;
if (!PyNames.INIT.equals(function.getName())) {
return;
}
final PyClass pyClass = function.getContainingClass();
if (pyClass == null) {
return;
}
className = pyClass.getName();
if (className == null) {
return;
}
searchScope = queryParameters.getEffectiveSearchScope();
if (searchScope instanceof GlobalSearchScope) {
searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes((GlobalSearchScope) searchScope, PythonFileType.INSTANCE);
}
} finally {
accessToken.finish();
}
queryParameters.getOptimizer().searchWord(className, searchScope, UsageSearchContext.IN_CODE, true, function);
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class PyOverridingMethodsSearchExecutor method execute.
public boolean execute(@NotNull final PyOverridingMethodsSearch.SearchParameters queryParameters, @NotNull final Processor<PyFunction> consumer) {
final PyFunction baseMethod = queryParameters.getFunction();
final PyClass containingClass = ApplicationManager.getApplication().runReadAction(new Computable<PyClass>() {
@Override
public PyClass compute() {
return baseMethod.getContainingClass();
}
});
return PyClassInheritorsSearch.search(containingClass, queryParameters.isCheckDeep()).forEach(pyClass -> {
final AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
PyFunction overridingMethod;
try {
overridingMethod = pyClass.findMethodByName(baseMethod.getName(), false, null);
if (overridingMethod != null) {
final Property baseProperty = baseMethod.getProperty();
final Property overridingProperty = overridingMethod.getProperty();
if (baseProperty != null && overridingProperty != null) {
final AccessDirection direction = PyUtil.getPropertyAccessDirection(baseMethod);
final PyCallable callable = overridingProperty.getByDirection(direction).valueOrNull();
overridingMethod = (callable instanceof PyFunction) ? (PyFunction) callable : null;
}
}
} finally {
accessToken.finish();
}
if (overridingMethod != null) {
return consumer.process(overridingMethod);
}
return true;
});
}
Aggregations