当前位置: 首页>>代码示例>>Java>>正文


Java HashMap.put方法代码示例

本文整理汇总了Java中com.intellij.util.containers.HashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java HashMap.put方法的具体用法?Java HashMap.put怎么用?Java HashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.HashMap的用法示例。


在下文中一共展示了HashMap.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:alvaromarco,项目名称:CleanArchitecturePlugin,代码行数:19,代码来源:EntityPresenter.java

示例2: visitClassType

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
@Override
public SmartTypePointer visitClassType(PsiClassType classType) {
  final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
  final PsiClass aClass = resolveResult.getElement();
  if (aClass == null) {
    return createClassReferenceTypePointer(classType);
  }
  if (classType instanceof PsiClassReferenceType) {
    classType = ((PsiClassReferenceType)classType).createImmediateCopy();
  }
  final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
  final HashMap<SmartPsiElementPointer, SmartTypePointer> map = new HashMap<SmartPsiElementPointer, SmartTypePointer>();
  for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable(aClass)) {
    final PsiType substitutionResult = substitutor.substitute(typeParameter);
    if (substitutionResult != null) {
      final SmartPsiElementPointer pointer = myPsiPointerManager.createSmartPsiElementPointer(typeParameter);
      map.put(pointer, substitutionResult.accept(this));
    }
  }
  return new ClassTypePointer(classType, myPsiPointerManager.createSmartPsiElementPointer(aClass), map);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SmartTypePointerManagerImpl.java

示例3: calculateReplacementMap

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
@Nullable
private static Map<PsiTypeParameter, PsiTypeParameter> calculateReplacementMap(final PsiSubstitutor substitutor,
                                                                        final PsiClass targetClass,
                                                                        final PsiElement containingElement) {
  final HashMap<PsiTypeParameter, PsiTypeParameter> result = new HashMap<PsiTypeParameter, PsiTypeParameter>();
  for (PsiTypeParameter classTypeParameter : PsiUtil.typeParametersIterable(targetClass)) {
    final PsiType substitution = substitutor.substitute(classTypeParameter);
    if (!(substitution instanceof PsiClassType)) return null;
    final PsiClass aClass = ((PsiClassType)substitution).resolve();
    if (!(aClass instanceof PsiTypeParameter)) return null;
    final PsiTypeParameter methodTypeParameter = (PsiTypeParameter)aClass;
    if (methodTypeParameter.getOwner() != containingElement) return null;
    if (result.keySet().contains(methodTypeParameter)) return null;
    result.put(methodTypeParameter, classTypeParameter);
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConvertToInstanceMethodProcessor.java

示例4: buildReferenceMap

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
private static HashMap<PsiMethod, Collection<PsiReference>>
buildReferenceMap(Set<PsiMethod> privateMethods) {
  final HashMap<PsiMethod, Collection<PsiReference>> referenceMap =
    new HashMap<PsiMethod, Collection<PsiReference>>();
  for (PsiMethod method : privateMethods) {
    final SearchScope scope = method.getUseScope();
    final Collection<PsiReference> references =
      ReferencesSearch.search(method, scope).findAll();
    referenceMap.put(method, references);
  }
  return referenceMap;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:VariableAccessVisitor.java

示例5: create

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
/**
 * 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);

}
 
开发者ID:alvaromarco,项目名称:CleanArchitecturePlugin,代码行数:36,代码来源:EntityFragment.java

示例6: createVariableMap

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
public static Map<String, AbstractVariableData> createVariableMap(final AbstractVariableData[] data) {
  final HashMap<String, AbstractVariableData> map = new HashMap<String, AbstractVariableData>();
  for (AbstractVariableData variableData : data) {
    map.put(variableData.getOriginalName(), variableData);
  }
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AbstractExtractMethodDialog.java

示例7: groupSuites

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:CoverageSuiteChooserDialog.java

示例8: getInitialViewTagName2IconMap

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
@NotNull
private static Map<String, Icon> getInitialViewTagName2IconMap() {
  final HashMap<String, Icon> map = new HashMap<String, Icon>();
  map.put("fragment", AndroidIcons.Views.Fragment);
  map.put("include", AndroidIcons.Views.Include);
  map.put("view", AndroidIcons.Views.View);
  map.put("requestFocus", AndroidIcons.Views.RequestFocus);
  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AndroidDomElementDescriptorProvider.java

示例9: addComponentToContainer

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
public void addComponentToContainer(final RadContainer container, final RadComponent component, final int index) {
  final JTabbedPane tabbedPane = getTabbedPane();
  LwTabbedPane.Constraints constraints = null;
  if (component.getCustomLayoutConstraints() instanceof LwTabbedPane.Constraints) {
    constraints = ((LwTabbedPane.Constraints)component.getCustomLayoutConstraints());
  }
  component.setCustomLayoutConstraints(null);
  final HashMap<String, LwTabbedPane.Constraints> id2Constraints = getId2Constraints(RadTabbedPane.this);
  id2Constraints.put(component.getId(), constraints);
  final String tabName = calcTabName(constraints == null ? null : constraints.myTitle);
  String toolTip = null;
  Icon icon = null;
  if (constraints != null) {
    toolTip = getDescriptorText(constraints.myToolTip);
    if (constraints.myIcon != null) {
      IntroIconProperty.ensureIconLoaded(getModule(), constraints.myIcon);
      icon = constraints.myIcon.getIcon();
    }
  }
  tabbedPane.insertTab(tabName, icon, component.getDelegee(), toolTip, index);
  if (constraints != null) {
    if (constraints.myDisabledIcon != null) {
      IntroIconProperty.ensureIconLoaded(getModule(), constraints.myDisabledIcon);
      tabbedPane.setDisabledIconAt(index, constraints.myDisabledIcon.getIcon());
    }
    tabbedPane.setEnabledAt(index, constraints.myEnabled);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:RadTabbedPane.java

示例10: registerConflict

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
private static void registerConflict(PsiJavaCodeReferenceElement reference,
                                     PsiElement resolved,
                                     HashMap<PsiElement, HashSet<PsiElement>> reported, MultiMap<PsiElement, String> conflicts) {
  final PsiElement container = ConflictsUtil.getContainer(reference);
  HashSet<PsiElement> containerSet = reported.get(container);
  if (containerSet == null) {
    containerSet = new HashSet<PsiElement>();
    reported.put(container, containerSet);
  }
  if (!containerSet.contains(resolved)) {
    containerSet.add(resolved);
    String placesDescription;
    if (containerSet.size() == 1) {
      placesDescription = RefactoringUIUtil.getDescription(resolved, true);
    } else {
      placesDescription = "<ol><li>" + StringUtil.join(containerSet, new Function<PsiElement, String>() {
        @Override
        public String fun(PsiElement element) {
          return RefactoringUIUtil.getDescription(element, true);
        }
      }, "</li><li>") + "</li></ol>";
    }
    String message = RefactoringBundle.message("0.will.become.inaccessible.from.1",
                                               placesDescription,
                                               RefactoringUIUtil.getDescription(container, true));
    conflicts.put(container, Collections.singletonList(message));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:MoveInnerProcessor.java

示例11: sortUsages

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
/**
 * @param usages
 * @return Map from elements to UsageHolders
 */
private static HashMap<PsiElement,UsageHolder> sortUsages(@NotNull 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SafeDeleteProcessor.java

示例12: buildNameToFileMap

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
private static HashMap<String, VirtualFile> buildNameToFileMap(VirtualFile[] files, @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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PlatformTestUtil.java

示例13: create

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
/**
 * 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);

}
 
开发者ID:alvaromarco,项目名称:CleanArchitecturePlugin,代码行数:44,代码来源:EntityActivity.java

示例14: create

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
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);

    }
 
开发者ID:alvaromarco,项目名称:CleanArchitecturePlugin,代码行数:17,代码来源:EntityAPI.java

示例15: createEquals

import com.intellij.util.containers.HashMap; //导入方法依赖的package包/类
private PsiMethod createEquals() throws IncorrectOperationException {
  @NonNls StringBuilder buffer = new StringBuilder();
  CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(myProject);
  ArrayList<PsiField> equalsFields = new ArrayList<PsiField>();
  ContainerUtil.addAll(equalsFields, myEqualsFields);
  Collections.sort(equalsFields, EqualsFieldsComparator.INSTANCE);

  final HashMap<String, Object> contextMap = new HashMap<String, Object>();

  final PsiType classType = JavaPsiFacade.getElementFactory(myClass.getProject()).createType(myClass);
  final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(myClass.getProject());
  String[] nameSuggestions = codeStyleManager
    .suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, classType).names;
  String instanceBaseName = nameSuggestions.length > 0 && nameSuggestions[0].length() < 10 ? nameSuggestions[0] : "that";
  contextMap.put(INSTANCE_NAME, instanceBaseName);

  final PsiType objectType = PsiType.getJavaLangObject(myClass.getManager(), myClass.getResolveScope());
  nameSuggestions = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, objectType).names;
  final String objectBaseName = nameSuggestions.length > 0 ? nameSuggestions[0] : "object";
  contextMap.put(BASE_PARAM_NAME, objectBaseName);
  final MethodSignature equalsSignature = getEqualsSignature(myProject, myClass.getResolveScope());
  contextMap.put(SUPER_HAS_EQUALS, superMethodExists(equalsSignature));
  contextMap.put(CHECK_PARAMETER_WITH_INSTANCEOF, myCheckParameterWithInstanceof);

  final String methodText = GenerationUtil
    .velocityGenerateCode(myClass, equalsFields, myNonNullSet, new HashMap<String, String>(), contextMap,
                          EqualsHashCodeTemplatesManager.getInstance().getDefaultEqualsTemplate().getTemplate(), 0, false, myUseAccessors);
  buffer.append(methodText);
  PsiMethod result;
  try {
    result = myFactory.createMethodFromText(buffer.toString(), myClass);
  }
  catch (IncorrectOperationException e) {
    return null;
  }
  final PsiParameter[] parameters = result.getParameterList().getParameters();
  if (parameters.length != 1) return null;
  final PsiParameter parameter = parameters[0];
  PsiUtil.setModifierProperty(parameter, PsiModifier.FINAL, styleSettings.GENERATE_FINAL_PARAMETERS);

  PsiMethod method = (PsiMethod)myCodeStyleManager.reformat(result);
  final PsiMethod superEquals = MethodSignatureUtil.findMethodBySignature(myClass, equalsSignature, true);
  if (superEquals != null) {
    OverrideImplementUtil.annotateOnOverrideImplement(method, myClass, superEquals);
  }
  method = (PsiMethod)myJavaCodeStyleManager.shortenClassReferences(method);
  return method;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:GenerateEqualsHelper.java


注:本文中的com.intellij.util.containers.HashMap.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。