本文整理汇总了Java中com.intellij.openapi.application.AccessToken.finish方法的典型用法代码示例。如果您正苦于以下问题:Java AccessToken.finish方法的具体用法?Java AccessToken.finish怎么用?Java AccessToken.finish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.application.AccessToken
的用法示例。
在下文中一共展示了AccessToken.finish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: moveMavenModulesToGroup
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
private void moveMavenModulesToGroup(
final Project project,
final List<Module> mavenModules,
final String[] rootGroup
) {
AccessToken token = null;
final ModifiableModuleModel modifiableModuleModel;
try {
token = ApplicationManager.getApplication().acquireReadActionLock();
modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : mavenModules) {
module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.MAVEN.name());
final String[] groupPath = modifiableModuleModel.getModuleGroupPath(module);
modifiableModuleModel.setModuleGroupPath(module, ArrayUtils.addAll(rootGroup, groupPath));
}
} finally {
if (token != null) {
token.finish();
}
}
ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(modifiableModuleModel::commit));
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:DefaultMavenConfigurator.java
示例2: moveGradleModulesToGroup
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
private void moveGradleModulesToGroup(
final Project project,
final List<Module> gradleModules,
final String[] gradleGroup
) {
final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : gradleModules) {
if (module == null) {
// https://youtrack.jetbrains.com/issue/IDEA-177512
continue;
}
module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.GRADLE.name());
modifiableModuleModel.setModuleGroupPath(module, gradleGroup);
}
AccessToken token = null;
try {
token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
modifiableModuleModel.commit();
} finally {
if (token != null) {
token.finish();
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:DefaultGradleConfigurator.java
示例3: moveEclipseModulesToGroup
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
private void moveEclipseModulesToGroup(
@NotNull final Project project,
@NotNull final List<Module> eclipseModules,
@Nullable final String[] eclipseGroup
) {
final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : eclipseModules) {
module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.ECLIPSE.name());
modifiableModuleModel.setModuleGroupPath(module, eclipseGroup);
}
AccessToken token = null;
try {
token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
modifiableModuleModel.commit();
} finally {
if (token != null) {
token.finish();
}
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:DefaultEclipseConfigurator.java
示例4: actionPerformed
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
if (editor == null || file == null) return;
final Project project = file.getProject();
CommandProcessorEx commandProcessor = (CommandProcessorEx)CommandProcessorEx.getInstance();
Object commandToken = commandProcessor.startCommand(project, e.getPresentation().getText(), e.getPresentation().getText(), UndoConfirmationPolicy.DEFAULT);
AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
shuffleIds(file, editor);
}
finally {
token.finish();
commandProcessor.finishCommand(project, commandToken, null);
}
}
示例5: actionPerformed
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
if (editor == null || file == null) return;
final Project project = file.getProject();
CommandProcessorEx commandProcessor = (CommandProcessorEx)CommandProcessorEx.getInstance();
Object commandToken = commandProcessor.startCommand(project, e.getPresentation().getText(), e.getPresentation().getText(), UndoConfirmationPolicy.DEFAULT);
AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
final SelectionModel selectionModel = editor.getSelectionModel();
int[] starts = selectionModel.getBlockSelectionStarts();
int[] ends = selectionModel.getBlockSelectionEnds();
int startOffset = starts.length == 0? 0 : starts[0];
int endOffset = ends.length == 0? editor.getDocument().getTextLength() : ends[ends.length - 1];
perform(project, editor.getDocument(), startOffset, endOffset);
}
finally {
token.finish();
commandProcessor.finishCommand(project, commandToken, null);
}
}
示例6: loadState
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Override
public void loadState(final Element element) {
try {
if (myFirstLoad) {
myModel.readExternal(element);
}
else {
LibraryModel model = new LibraryModel(myModel);
AccessToken token = WriteAction.start();
try {
model.readExternal(element);
commit(model);
}
finally {
token.finish();
}
}
myFirstLoad = false;
}
catch (InvalidDataException e) {
throw new RuntimeException(e);
}
}
示例7: findFile
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Override
public VirtualFile findFile(@NotNull RootType rootType, @NotNull String pathName, @NotNull Option option) throws IOException {
ApplicationManager.getApplication().assertReadAccessAllowed();
String fullPath = getRootPath(rootType) + "/" + pathName;
if (option != Option.create_new_always) {
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fullPath);
if (file != null && !file.isDirectory()) return file;
if (option == Option.existing_only) return null;
}
String ext = PathUtil.getFileExtension(pathName);
String fileNameExt = PathUtil.getFileName(pathName);
String fileName = StringUtil.trimEnd(fileNameExt, ext == null ? "" : "." + ext);
AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
try {
VirtualFile dir = VfsUtil.createDirectories(PathUtil.getParentPath(fullPath));
if (option == Option.create_new_always) {
return VfsUtil.createChildSequent(LocalFileSystem.getInstance(), dir, fileName, StringUtil.notNullize(ext));
}
else {
return dir.createChildData(LocalFileSystem.getInstance(), fileNameExt);
}
}
finally {
token.finish();
}
}
示例8: tearDown
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
try {
ModuleManager moduleManager = ModuleManager.getInstance(myProject);
List<Throwable> errors = null;
AccessToken token = WriteAction.start();
try {
for (Module module : myModulesToDispose) {
try {
String moduleName = module.getName();
if (moduleManager.findModuleByName(moduleName) != null) {
moduleManager.disposeModule(module);
}
}
catch (Throwable e) {
if (errors == null) {
errors = new SmartList<Throwable>();
}
errors.add(e);
}
}
}
finally {
token.finish();
}
CompoundRuntimeException.throwIfNotEmpty(errors);
}
finally {
myModulesToDispose.clear();
super.tearDown();
}
}
示例9: getTargetClass
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Nullable
private static PsiClass getTargetClass(String qualifiedName, PsiDirectory baseDirectory, Project project, Module module) {
GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
PsiClass targetClass = JavaPsiFacade.getInstance(project).findClass(qualifiedName, scope);
if (targetClass != null) return targetClass;
final String packageName = StringUtil.getPackageName(qualifiedName);
PsiPackage psiPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
final PsiDirectory psiDirectory;
if (psiPackage != null) {
final PsiDirectory[] directories = psiPackage.getDirectories(GlobalSearchScope.allScope(project));
psiDirectory = directories.length > 1 ? DirectoryChooserUtil
.chooseDirectory(directories, null, project, new HashMap<PsiDirectory, String>()) : directories[0];
}
else {
psiDirectory = PackageUtil.findOrCreateDirectoryForPackage(module, packageName, baseDirectory, false);
}
if (psiDirectory == null) return null;
final String shortName = StringUtil.getShortName(qualifiedName);
final String fileName = shortName + NewGroovyActionBase.GROOVY_EXTENSION;
final AccessToken lock = ApplicationManager.getApplication().acquireWriteActionLock(GrIntroduceConstantDialog.class);
try {
final GroovyFile file =
(GroovyFile)GroovyTemplatesFactory.createFromTemplate(psiDirectory, shortName, fileName, GroovyTemplates.GROOVY_CLASS, true);
return file.getTypeDefinitions()[0];
}
finally {
lock.finish();
}
}
示例10: fireEvents
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
public void fireEvents(final boolean hasWriteAction) {
AccessToken token = myStartTrace == null ? null : DumbServiceImpl.forceDumbModeStartTrace(myStartTrace);
try {
if (!iHaveEventsToFire || ApplicationManager.getApplication().isDisposed()) return;
Runnable runnable = new Runnable() {
public void run() {
if (hasWriteAction) {
fireEventsInWriteAction();
}
else {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
fireEventsInWriteAction();
}
});
}
}
};
if (myDumbModePermission != null) {
DumbService.allowStartingDumbModeInside(myDumbModePermission, runnable);
} else {
runnable.run();
}
}
finally {
if (token != null) {
token.finish();
}
mySemaphore.up();
}
}
示例11: inferClosureReturnType
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Nullable
private PsiType inferClosureReturnType() {
final ExtractClosureHelperImpl mockHelper =
new ExtractClosureHelperImpl(myInfo, "__test___n_", false, new TIntArrayList(), false, 0, false, false, false);
final PsiType returnType;
final AccessToken token = WriteAction.start();
try {
returnType = ExtractClosureProcessorBase.generateClosure(mockHelper).getReturnType();
}
finally {
token.finish();
}
return returnType;
}
示例12: getArgTypes
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Nullable
private static PsiType[] getArgTypes(GrReferenceElement refElement) {
final AccessToken accessToken = ReadAction.start();
try {
return PsiUtil.getArgumentTypes(refElement, false);
}
finally {
accessToken.finish();
}
}
示例13: isInheritor
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
private static boolean isInheritor(PsiClass clazz, PsiClass candidate) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
return candidate.isValid() && candidate.isInheritor(clazz, false);
}
finally {
accessToken.finish();
}
}
示例14: processIntention
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Override
protected void processIntention(@NotNull PsiElement element, 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);
}
},
new Function<GrExpression, String>() {
@Override
public String fun(GrExpression grExpression) {
return grExpression.getText();
}
}
);
}
}
示例15: findEnclosingName
import com.intellij.openapi.application.AccessToken; //导入方法依赖的package包/类
@Nullable
private static String findEnclosingName(final SourcePosition position) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
PsiClass typeDefinition = findEnclosingTypeDefinition(position);
if (typeDefinition != null) {
return getClassNameForJvm(typeDefinition);
}
return getScriptQualifiedName(position);
}
finally {
accessToken.finish();
}
}