use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class ConvertConcatenationToGstringIntention method processIntention.
@Override
protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
final PsiFile file = element.getContainingFile();
final int offset = editor.getCaretModel().getOffset();
final AccessToken accessToken = ReadAction.start();
final List<GrExpression> expressions;
try {
expressions = collectExpressions(file, offset);
} finally {
accessToken.finish();
}
final Document document = editor.getDocument();
if (expressions.size() == 1) {
invokeImpl(expressions.get(0), document);
} else if (!expressions.isEmpty()) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
invokeImpl(expressions.get(expressions.size() - 1), document);
return;
}
IntroduceTargetChooser.showChooser(editor, expressions, new Pass<GrExpression>() {
@Override
public void pass(final GrExpression selectedValue) {
invokeImpl(selectedValue, document);
}
}, grExpression -> grExpression.getText());
}
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class MavenProjectsManager method initComponent.
@Override
public void initComponent() {
if (!isNormalProject())
return;
StartupManagerEx startupManager = StartupManagerEx.getInstanceEx(myProject);
startupManager.registerStartupActivity(() -> {
boolean wasMavenized = !myState.originalFiles.isEmpty();
if (!wasMavenized)
return;
initMavenized();
});
startupManager.registerPostStartupActivity(() -> {
if (!isMavenizedProject()) {
showNotificationOrphanMavenProject(myProject);
}
CompilerManager.getInstance(myProject).addBeforeTask(new CompileTask() {
@Override
public boolean execute(CompileContext context) {
AccessToken token = ReadAction.start();
try {
new MavenResourceCompilerConfigurationGenerator(myProject, myProjectsTree).generateBuildConfiguration(context.isRebuild());
} finally {
token.finish();
}
return true;
}
});
});
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class MavenArtifactDownloader method collectArtifactsToDownload.
private Map<MavenId, DownloadData> collectArtifactsToDownload(List<MavenExtraArtifactType> types) {
Map<MavenId, DownloadData> result = new THashMap<>();
THashSet<String> dependencyTypesFromSettings = new THashSet<>();
AccessToken accessToken = ReadAction.start();
try {
if (myProject.isDisposed())
return result;
dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myProject).getImportingSettings().getDependencyTypesAsSet());
} finally {
accessToken.finish();
}
for (MavenProject eachProject : myMavenProjects) {
List<MavenRemoteRepository> repositories = eachProject.getRemoteRepositories();
for (MavenArtifact eachDependency : eachProject.getDependencies()) {
if (myArtifacts != null && !myArtifacts.contains(eachDependency))
continue;
if (MavenConstants.SCOPE_SYSTEM.equalsIgnoreCase(eachDependency.getScope()))
continue;
if (myProjectsTree.findProject(eachDependency.getMavenId()) != null)
continue;
String dependencyType = eachDependency.getType();
if (!dependencyTypesFromSettings.contains(dependencyType) && !eachProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
continue;
}
MavenId id = eachDependency.getMavenId();
DownloadData data = result.get(id);
if (data == null) {
data = new DownloadData();
result.put(id, data);
}
data.repositories.addAll(repositories);
for (MavenExtraArtifactType eachType : types) {
Pair<String, String> classifierAndExtension = eachProject.getClassifierAndExtension(eachDependency, eachType);
String classifier = eachDependency.getFullClassifier(classifierAndExtension.first);
String extension = classifierAndExtension.second;
data.classifiersWithExtensions.add(new DownloadElement(classifier, extension, eachType));
}
}
}
return result;
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class SpringLoadedPositionManager method getOuterClassName.
@Nullable
private static String getOuterClassName(final SourcePosition position) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
PsiElement element = findElementAt(position);
if (element == null)
return null;
PsiElement sourceImage = PsiTreeUtil.getParentOfType(element, GrClosableBlock.class, GrTypeDefinition.class, PsiClassImpl.class);
if (sourceImage instanceof PsiClass) {
return getClassNameForJvm((PsiClass) sourceImage);
}
return null;
} finally {
accessToken.finish();
}
}
use of com.intellij.openapi.application.AccessToken in project intellij-community by JetBrains.
the class SpringLoadedPositionManager method getAllClasses.
@NotNull
@Override
public List<ReferenceType> getAllClasses(@NotNull final SourcePosition classPosition) throws NoDataException {
int line;
String className;
AccessToken accessToken = ReadAction.start();
try {
className = findEnclosingName(classPosition);
if (className == null)
throw NoDataException.INSTANCE;
line = classPosition.getLine();
} finally {
accessToken.finish();
}
List<ReferenceType> referenceTypes = myDebugProcess.getVirtualMachineProxy().classesByName(className);
if (referenceTypes.isEmpty())
throw NoDataException.INSTANCE;
Set<ReferenceType> res = new HashSet<>();
for (ReferenceType referenceType : referenceTypes) {
findNested(res, referenceType, line);
}
if (res.isEmpty()) {
throw NoDataException.INSTANCE;
}
return new ArrayList<>(res);
}
Aggregations