Java Code Examples for com.intellij.util.containers.HashMap#put()
The following examples show how to use
com.intellij.util.containers.HashMap#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityAdapter.java From CleanArchitecturePlugin with Apache License 2.0 | 6 votes |
/** * Create EntityAdapter.class */ public static void create() { PsiDirectory adapterDirectory = createDirectory(getViewPackage(), ADAPTER.toLowerCase()); String className = getEntityConfig().getEntityName() + ADAPTER; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_PROJECT", getPackageNameProject(getProjectDirectory())); varTemplate.put("LAYOUT_NAME", getEntityConfig().getEntityName().toLowerCase()); Runnable runnable = () -> { JavaDirectoryService.getInstance().createClass(adapterDirectory, className, ADAPTER_TEMPLATE, false, varTemplate); try { createLayout(getPackageNameProject(adapterDirectory), className, ADAPTER); } catch (Exception e) { e.printStackTrace(); } }; WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example 2
Source File: EntityPresenter.java From CleanArchitecturePlugin with Apache License 2.0 | 6 votes |
/** * Create EntityPresenter.class */ public static void create() { // Create presenter directory presenterDirectory = createDirectory(getViewPackage(), PRESENTER.toLowerCase()); // Create presenter class String className = getEntityConfig().getEntityName() + PRESENTER; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_PRESENTER_IMPL", getPackageNameProject(Presenter.getPresenterDirectory())); varTemplate.put("PRESENTER_IMPL", PRESENTER_IMPL); Runnable runnable = () -> JavaDirectoryService.getInstance().createClass(presenterDirectory, className, PRESENTER_TEMPLATE, false, varTemplate); WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example 3
Source File: EntityFragment.java From CleanArchitecturePlugin with Apache License 2.0 | 5 votes |
/** * Create package fragment and EntityFragment.class */ public static void create() { // Create fragment directory PsiDirectory fragmentDirectory = createDirectory(getViewPackage(), FRAGMENT.toLowerCase()); // Create fragment class String className = getEntityConfig().getEntityName() + FRAGMENT; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_PROJECT", getPackageNameProject(getProjectDirectory())); varTemplate.put("LAYOUT_NAME", getEntityConfig().getEntityName().toLowerCase()); varTemplate.put("PACKAGE_BASE_FRAGMENT", getPackageNameProject(ParentFragment.getFragmentDirectory())); varTemplate.put("BASE_FRAGMENT", PARENT_FRAGMENT); varTemplate.put("PACKAGE_BASE_PRESENTER", getPackageNameProject(Presenter.getPresenterDirectory())); varTemplate.put("BASE_PRESENTER", PRESENTER); if (EntityPresenter.getPresenterDirectory() != null && getEntityConfig().isContainsPresenter()) { // With presenter or not varTemplate.put("PACKAGE_PRESENTER", getPackageNameProject(EntityPresenter.getPresenterDirectory())); varTemplate.put("PRESENTER", getEntityConfig().getEntityName() + PRESENTER); } Runnable runnable = () -> { JavaDirectoryService.getInstance().createClass(fragmentDirectory, className, FRAGMENT_TEMPLATE, false, varTemplate); try { createLayout(getPackageNameProject(fragmentDirectory), className, FRAGMENT); } catch (Exception e) { e.printStackTrace(); } }; WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example 4
Source File: CoverageSuiteChooserDialog.java From consulo with Apache License 2.0 | 5 votes |
private static void groupSuites(final HashMap<CoverageRunner, Map<String, List<CoverageSuite>>> grouped, final CoverageSuite[] suites, final CoverageEngine engine) { for (CoverageSuite suite : suites) { if (engine != null && suite.getCoverageEngine() != engine) continue; final CoverageFileProvider provider = suite.getCoverageDataFileProvider(); if (provider instanceof DefaultCoverageFileProvider && Comparing.strEqual(((DefaultCoverageFileProvider)provider).getSourceProvider(), DefaultCoverageFileProvider.class.getName())) { if (!provider.ensureFileExists()) continue; } final CoverageRunner runner = suite.getRunner(); Map<String, List<CoverageSuite>> byProviders = grouped.get(runner); if (byProviders == null) { byProviders = new HashMap<String, List<CoverageSuite>>(); grouped.put(runner, byProviders); } final String sourceProvider = provider instanceof DefaultCoverageFileProvider ? ((DefaultCoverageFileProvider)provider).getSourceProvider() : provider.getClass().getName(); List<CoverageSuite> list = byProviders.get(sourceProvider); if (list == null) { list = new ArrayList<CoverageSuite>(); byProviders.put(sourceProvider, list); } list.add(suite); } }
Example 5
Source File: PlatformTestUtil.java From consulo with Apache License 2.0 | 5 votes |
private static HashMap<String, VirtualFile> buildNameToFileMap(VirtualFile[] files, @javax.annotation.Nullable VirtualFileFilter filter) { HashMap<String, VirtualFile> map = new HashMap<String, VirtualFile>(); for (VirtualFile file : files) { if (filter != null && !filter.accept(file)) continue; map.put(file.getName(), file); } return map; }
Example 6
Source File: AbstractExtractMethodDialog.java From consulo with Apache License 2.0 | 5 votes |
public static Map<String, AbstractVariableData> createVariableMap(final AbstractVariableData[] data) { final HashMap<String, AbstractVariableData> map = new HashMap<>(); for (AbstractVariableData variableData : data) { map.put(variableData.getOriginalName(), variableData); } return map; }
Example 7
Source File: SafeDeleteProcessor.java From consulo with Apache License 2.0 | 5 votes |
/** * @param usages * @return Map from elements to UsageHolders */ private static HashMap<PsiElement, UsageHolder> sortUsages(@Nonnull UsageInfo[] usages) { HashMap<PsiElement, UsageHolder> result = new HashMap<PsiElement, UsageHolder>(); for (final UsageInfo usage : usages) { if (usage instanceof SafeDeleteUsageInfo) { final PsiElement referencedElement = ((SafeDeleteUsageInfo)usage).getReferencedElement(); if (!result.containsKey(referencedElement)) { result.put(referencedElement, new UsageHolder(referencedElement, usages)); } } } return result; }
Example 8
Source File: EntityActivity.java From CleanArchitecturePlugin with Apache License 2.0 | 4 votes |
/** * Create package activity and EntityActivity.class */ public static void create() { // Create activity directory PsiDirectory activityDirectory = createDirectory(getViewPackage(), ACTIVITY.toLowerCase()); // Create activity class String className = getEntityConfig().getEntityName() + ACTIVITY; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_PROJECT", getPackageNameProject(getProjectDirectory())); varTemplate.put("LAYOUT_NAME", getEntityConfig().getEntityName().toLowerCase()); if (ParentActivity.getActivityDirectory() != null) { // With Parent Activity varTemplate.put("PACKAGE_BASE_ACTIVITY", getPackageNameProject(ParentActivity.getActivityDirectory())); varTemplate.put("BASE_ACTIVITY", PARENT_ACTIVITY); } if (Presenter.getPresenterDirectory() != null) { // With Parent Presenter varTemplate.put("PACKAGE_BASE_PRESENTER", getPackageNameProject(Presenter.getPresenterDirectory())); varTemplate.put("BASE_PRESENTER", PRESENTER); } if (EntityPresenter.getPresenterDirectory() != null && getEntityConfig().isContainsPresenter()) { // With presenter varTemplate.put("PACKAGE_PRESENTER", getPackageNameProject(EntityPresenter.getPresenterDirectory())); varTemplate.put("PRESENTER", getEntityConfig().getEntityName() + PRESENTER); } Runnable runnable = () -> { JavaDirectoryService.getInstance().createClass(activityDirectory, className, ACTIVITY_TEMPLATE, false, varTemplate); try { createLayout(getPackageNameProject(activityDirectory), className, ACTIVITY); } catch (Exception e) { e.printStackTrace(); } }; WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example 9
Source File: EntityAPI.java From CleanArchitecturePlugin with Apache License 2.0 | 4 votes |
public static void create() { // Create API package apiDirectory = createDirectory(getDataPackage(), API.toLowerCase()); // Create service class String className = getEntityConfig().getEntityName() + SERVICE; HashMap<String, String> varTemplate = new HashMap<>(); varTemplate.put("PACKAGE_BASE_SERVICE", getPackageNameProject(ParentAPI.getApiDirectory())); varTemplate.put("BASE_SERVICE", BASE_SERVICE); Runnable runnable = () -> JavaDirectoryService.getInstance().createClass(apiDirectory, className, SERVICE_TEMPLATE, false, varTemplate); WriteCommandAction.runWriteCommandAction(getProject(), runnable); }
Example 10
Source File: EntityRepository.java From CleanArchitecturePlugin with Apache License 2.0 | 4 votes |
public static void create() { // Create Repository package PsiDirectory repositoryDirectory = createDirectory(getDataPackage(), REPOSITORY.toLowerCase()); // Create DataSource package PsiDirectory dataSourceDirectory = createDirectory(repositoryDirectory, DATASOURCE.toLowerCase()); // Create Cloud Entity Data Source class String cloudEntityDataSourceName = CLOUD + getEntityConfig().getEntityName() + DATASOURCE; HashMap<String, String> cloudTemplate = new HashMap<>(); cloudTemplate.put("PACKAGE_SERVICE", getPackageNameProject(EntityAPI.getApiDirectory())); cloudTemplate.put("SERVICE", getEntityConfig().getEntityName() + SERVICE); // Create Disk Entity Data Source class String diskEntityDataSourceName = DISK + getEntityConfig().getEntityName() + DATASOURCE; HashMap<String, String> diskTemplate = new HashMap<>(); diskTemplate.put("PACKAGE_BASE_SERVICE", getPackageNameProject(ParentAPI.getApiDirectory())); diskTemplate.put("BASE_SERVICE", BASE_SERVICE); diskTemplate.put("PACKAGE_CACHE", getPackageNameProject(EntityCache.getCacheDirectory())); diskTemplate.put("CACHE", getEntityConfig().getEntityName() + CACHE); // Create Data Store Factory class String dataStoreFactoryName = getEntityConfig().getEntityName() + DATASTOREFACTORY; HashMap<String, String> dataStoreFactoryTemplate = new HashMap<>(); dataStoreFactoryTemplate.put("PACKAGE_ENTITY_SERVICE", getPackageNameProject(EntityAPI.getApiDirectory())); dataStoreFactoryTemplate.put("ENTITY_SERVICE", getEntityConfig().getEntityName() + SERVICE); dataStoreFactoryTemplate.put("PACKAGE_ENTITY_CACHE", getPackageNameProject(EntityCache.getCacheDirectory())); dataStoreFactoryTemplate.put("ENTITY_CACHE", getEntityConfig().getEntityName() + CACHE); dataStoreFactoryTemplate.put("PACKAGE_CLOUD_ENTITY_DATA_SOURCE", getPackageNameProject(dataSourceDirectory)); dataStoreFactoryTemplate.put("CLOUD_ENTITY_DATA_SOURCE", cloudEntityDataSourceName); dataStoreFactoryTemplate.put("PACKAGE_DISK_ENTITY_DATA_SOURCE", getPackageNameProject(dataSourceDirectory)); dataStoreFactoryTemplate.put("DISK_ENTITY_DATA_SOURCE", diskEntityDataSourceName); // Create Repository class String repositoryName = getEntityConfig().getEntityName() + REPOSITORY; HashMap<String, String> repositoryTemplate = new HashMap<>(); repositoryTemplate.put("DATA_STORE_FACTORY", getEntityConfig().getEntityName() + DATASTOREFACTORY); Runnable repositoryRunnable = () -> { JavaDirectoryService.getInstance().createClass(dataSourceDirectory, cloudEntityDataSourceName, CLOUD_ENTITY_DATA_SOURCE_TEMPLATE, false, cloudTemplate); JavaDirectoryService.getInstance().createClass(dataSourceDirectory, diskEntityDataSourceName, DISK_ENTITY_DATA_SOURCE_TEMPLATE, false, diskTemplate); JavaDirectoryService.getInstance().createClass(repositoryDirectory, dataStoreFactoryName, DATA_STORE_FACTORY_TEMPLATE, false, dataStoreFactoryTemplate); JavaDirectoryService.getInstance().createClass(repositoryDirectory, repositoryName, REPOSITORY_TEMPLATE, false, repositoryTemplate); }; WriteCommandAction.runWriteCommandAction(getProject(), repositoryRunnable); }
Example 11
Source File: HaxeCalleeMethodsTreeStructure.java From intellij-haxe with Apache License 2.0 | 4 votes |
@NotNull protected final Object[] buildChildren(@NotNull final HierarchyNodeDescriptor descriptor) { final HaxeHierarchyTimeoutHandler timeoutHandler = new HaxeHierarchyTimeoutHandler(); try { final PsiMember enclosingElement = ((CallHierarchyNodeDescriptor)descriptor).getEnclosingElement(); if (!(enclosingElement instanceof PsiMethod)) { return ArrayUtil.EMPTY_OBJECT_ARRAY; } final PsiMethod method = (PsiMethod)enclosingElement; final ArrayList<PsiMethod> methods = new ArrayList<PsiMethod>(); final PsiCodeBlock body = method.getBody(); if (body != null) { visitor(body, methods); } final PsiMethod baseMethod = (PsiMethod)((CallHierarchyNodeDescriptor)getBaseDescriptor()).getTargetElement(); final PsiClass baseClass = baseMethod.getContainingClass(); final HashMap<PsiMethod, CallHierarchyNodeDescriptor> methodToDescriptorMap = new HashMap<PsiMethod, CallHierarchyNodeDescriptor>(); final ArrayList<CallHierarchyNodeDescriptor> result = new ArrayList<CallHierarchyNodeDescriptor>(); for (final PsiMethod calledMethod : methods) { if (timeoutHandler.checkAndCancelIfNecessary()) { break; } if (!isInScope(baseClass, calledMethod, myScopeType)) continue; CallHierarchyNodeDescriptor d = methodToDescriptorMap.get(calledMethod); if (d == null) { d = new CallHierarchyNodeDescriptor(myProject, descriptor, calledMethod, false, false); methodToDescriptorMap.put(calledMethod, d); result.add(d); } else { d.incrementUsageCount(); } } // also add overriding methods as children if (!timeoutHandler.isCanceled()) { Query<PsiMethod> query = HaxeMethodsSearch.search(method, timeoutHandler); query.forEach(new Processor<PsiMethod>() { @Override public boolean process(PsiMethod overridingMethod) { if (isInScope(baseClass, overridingMethod, myScopeType)) { final CallHierarchyNodeDescriptor node = new CallHierarchyNodeDescriptor(myProject, descriptor, overridingMethod, false, false); if (!result.contains(node)) result.add(node); } return timeoutHandler.checkAndCancelIfNecessary(); } }); } return ArrayUtil.toObjectArray(result); } finally { // This is in a finally clause because a cancellation would otherwise throw // right past us. timeoutHandler.stop(); // Clean up. if (timeoutHandler.isCanceled()) { timeoutHandler.postCanceledDialog(myProject); } } }
Example 12
Source File: KeymapImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override public HashMap<String, ArrayList<KeyboardShortcut>> getConflicts(String actionId, KeyboardShortcut keyboardShortcut) { HashMap<String, ArrayList<KeyboardShortcut>> result = new HashMap<String, ArrayList<KeyboardShortcut>>(); String[] actionIds = getActionIds(keyboardShortcut.getFirstKeyStroke()); for (String id : actionIds) { if (id.equals(actionId)) { continue; } if (actionId.startsWith(EDITOR_ACTION_PREFIX) && id.equals("$" + actionId.substring(6))) { continue; } if (StringUtil.startsWithChar(actionId, '$') && id.equals(EDITOR_ACTION_PREFIX + actionId.substring(1))) { continue; } final String useShortcutOf = myKeymapManager.getActionBinding(id); if (useShortcutOf != null && useShortcutOf.equals(actionId)) { continue; } Shortcut[] shortcuts = getShortcuts(id); for (Shortcut shortcut1 : shortcuts) { if (!(shortcut1 instanceof KeyboardShortcut)) { continue; } KeyboardShortcut shortcut = (KeyboardShortcut)shortcut1; if (!shortcut.getFirstKeyStroke().equals(keyboardShortcut.getFirstKeyStroke())) { continue; } if (keyboardShortcut.getSecondKeyStroke() != null && shortcut.getSecondKeyStroke() != null && !keyboardShortcut.getSecondKeyStroke().equals(shortcut.getSecondKeyStroke())) { continue; } ArrayList<KeyboardShortcut> list = result.get(id); if (list == null) { list = new ArrayList<KeyboardShortcut>(); result.put(id, list); } list.add(shortcut); } } return result; }