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


Java HashMap类代码示例

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


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

示例1: scanForModifiedClasses

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
public Map<String, HotSwapFile> scanForModifiedClasses( DebuggerSession session, HotSwapProgress progress )
{
  DebuggerManagerThreadImpl.assertIsManagerThread();

  Map<String, HotSwapFile> modifiedClasses = new HashMap<>();

  List<File> outputRoots = new ArrayList<>();
  ApplicationManager.getApplication().runReadAction(
    () -> {
       VirtualFile[] allDirs = OrderEnumerator.orderEntries( getIjProject() ).getAllSourceRoots();
       for( VirtualFile dir : allDirs )
       {
         outputRoots.add( new File( dir.getPath() ) );
       }
     } );
  long timeStamp = getTimeStamp( session );
  for( File root : outputRoots )
  {
    String rootPath = FileUtil.toCanonicalPath( root.getPath() );
    collectModifiedClasses( root, rootPath, modifiedClasses, progress, timeStamp );
  }
  setTimeStamp( session, System.currentTimeMillis() );
  return modifiedClasses;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:25,代码来源:HotSwapComponent.java

示例2: findComponents

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@NotNull
public static Map<String, PsiFile> findComponents(@NotNull final Project project) {
  Map<String, PsiFile> result = new HashMap<String, PsiFile>();
  Collection<VirtualFile> virtualFiles =
      FileBasedIndex.getInstance().getContainingFiles(FilenameIndex.NAME, CatberryConstants.CAT_COMPONENT_JSON,
          GlobalSearchScope.allScope(project));
  for (VirtualFile virtualFile : virtualFiles) {
    JsonFile psiFile = (JsonFile) PsiManager.getInstance(project).findFile(virtualFile);
    if (psiFile != null) {
      JsonProperty[] properties = PsiTreeUtil.getChildrenOfType(psiFile.getTopLevelValue(), JsonProperty.class);
      if (properties != null) {
        for (JsonProperty property : properties) {
          if (!property.getName().equals("name"))
            continue;
          if (property.getValue() != null && property.getValue() instanceof JsonStringLiteral)
            result.put(((JsonStringLiteral) property.getValue()).getValue(), psiFile);
          break;
        }
      }
    }
  }
  return result;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:24,代码来源:CatberryComponentUtils.java

示例3: 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

示例4: calcType

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@Override
protected PsiClassType calcType() {
  final PsiElement classElement = myClass.getElement();
  if (!(classElement instanceof PsiClass)) return null;
  Map<PsiTypeParameter, PsiType> resurrected = new HashMap<PsiTypeParameter, PsiType>();
  final Set<Map.Entry<SmartPsiElementPointer, SmartTypePointer>> set = myMap.entrySet();
  for (Map.Entry<SmartPsiElementPointer, SmartTypePointer> entry : set) {
    PsiElement element = entry.getKey().getElement();
    if (element instanceof PsiTypeParameter) {
      SmartTypePointer typePointer = entry.getValue();
      resurrected.put((PsiTypeParameter)element, typePointer == null ? null : typePointer.getType());
    }
  }
  for (PsiTypeParameter typeParameter : PsiUtil.typeParametersIterable((PsiClass)classElement)) {
    if (!resurrected.containsKey(typeParameter)) {
      resurrected.put(typeParameter, null);
    }
  }
  final PsiSubstitutor resurrectedSubstitutor = PsiSubstitutorImpl.createSubstitutor(resurrected);
  return new PsiImmediateClassType((PsiClass)classElement, resurrectedSubstitutor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SmartTypePointerManagerImpl.java

示例5: searchForVarsToWrap

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
public static Result searchForVarsToWrap(GroovyPsiElement root, Result analyzedVars, ExpressionContext context) {
  LocalVarAnalyzer visitor = new LocalVarAnalyzer();
  root.accept(visitor);

  Map<PsiVariable, String> varToName = analyzedVars == null ? new HashMap<PsiVariable, String>() : analyzedVars.varToName;
  Set<PsiVariable> toWrap = analyzedVars == null ? new HashSet<PsiVariable>() : analyzedVars.toWrap;
  Set<PsiVariable> toMakeFinal = analyzedVars == null ? new HashSet<PsiVariable>() : analyzedVars.toMakeFinal;
  for (PsiVariable v : visitor.touched) {
    if (visitor.rewritten.contains(v)) {
      toWrap.add(v);
      if (v instanceof PsiParameter) {
        varToName.put(v, GenerationUtil.suggestVarName(v.getType(), root, context));
      }
      else {
        varToName.put(v, v.getName());
      }
    }
    else {
      toMakeFinal.add(v);
      varToName.put(v, v.getName());
    }
  }
  return analyzedVars == null ? new Result(toMakeFinal, toWrap, varToName) : analyzedVars;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:LocalVarAnalyzer.java

示例6: createElement

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@Nullable
protected DomElement createElement(final T context,
                                   final Editor editor,
                                   final PsiFile file,
                                   final Project project,
                                   PsiClass selectedClass) {
  final Map<String,String> map = new HashMap<String, String>();
  map.put("CLASS_NAME", selectedClass.getQualifiedName());
  new WriteCommandAction.Simple(project, file) {
    @Override
    protected void run() throws Throwable {
      DomTemplateRunner.getInstance(project).runTemplate(createElement(context), myTemplate, editor, map);
    }
  }.execute();
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CreateClassMappingAction.java

示例7: getDependent

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@Override
public Set<? extends T> getDependent() {
  if(myDependencies == null) {
    myDependencies = new HashSet<T>();
    myDependenciesToDependent = new HashMap<T, HashSet<T>>();
    for (T member : myMembers) {
      Set<T> dependent = myMemberDependenciesStorage.getMemberDependencies(member);
      if (dependent != null) {
        for (final T aDependent : dependent) {
          if (mySelectedNormal.contains(aDependent) && !mySelectedAbstract.contains(aDependent)) {
            myDependencies.add(member);
            HashSet<T> deps = myDependenciesToDependent.get(member);
            if (deps == null) {
              deps = new HashSet<T>();
              myDependenciesToDependent.put(member, deps);
            }
            deps.add(aDependent);
          }
        }
      }
    }
  }

  return myDependencies;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:UsedByMemberDependencyGraph.java

示例8: encodeOverloadTargets

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
static Map<PsiMethodCallExpression, PsiMethod> encodeOverloadTargets(final PsiClass targetClass,
                                                      final SearchScope processConflictsScope,
                                                      final String overloadName,
                                                      final PsiElement extractedFragment) {
  final Map<PsiMethodCallExpression, PsiMethod> ret = new HashMap<PsiMethodCallExpression, PsiMethod>();
  encodeInClass(targetClass, overloadName, extractedFragment, ret);

  ClassInheritorsSearch.search(targetClass, processConflictsScope, true).forEach(new Processor<PsiClass>() {
    public boolean process(PsiClass inheritor) {
      encodeInClass(inheritor, overloadName, extractedFragment, ret);
      return true;
    }
  });

  return ret;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExtractMethodUtil.java

示例9: substituteTypeParameters

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@NotNull
private static PsiSubstitutor substituteTypeParameters(@NotNull JVMElementFactory factory,
                                                       @Nullable PsiElement target,
                                                       @Nullable PsiTypeParameterList sourceTypeParameterList,
                                                       @Nullable PsiTypeParameterList targetTypeParameterList,
                                                       @NotNull PsiSubstitutor substitutor, 
                                                       @NotNull PsiMethod sourceMethod) {
  if (sourceTypeParameterList == null || targetTypeParameterList == null || PsiUtil.isRawSubstitutor(sourceMethod, substitutor)) {
    return substitutor;
  }

  final Map<PsiTypeParameter, PsiType> substitutionMap = new HashMap<PsiTypeParameter, PsiType>(substitutor.getSubstitutionMap());
  for (PsiTypeParameter typeParam : sourceTypeParameterList.getTypeParameters()) {
    final PsiTypeParameter substitutedTypeParam = substituteTypeParameter(factory, typeParam, substitutor, sourceMethod);

    final PsiTypeParameter resolvedTypeParam = resolveTypeParametersCollision(factory, sourceTypeParameterList, target,
                                                                              substitutedTypeParam, substitutor);
    targetTypeParameterList.add(resolvedTypeParam);
    if (substitutedTypeParam != resolvedTypeParam) {
      substitutionMap.put(typeParam, factory.createType(resolvedTypeParam));
    }
  }
  return substitutionMap.isEmpty() ? substitutor : factory.createSubstitutor(substitutionMap);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GenerateMembersUtil.java

示例10: substituteTypeParameter

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@NotNull
private static PsiTypeParameter substituteTypeParameter(final @NotNull JVMElementFactory factory,
                                                        @NotNull PsiTypeParameter typeParameter,
                                                        final @NotNull PsiSubstitutor substitutor, 
                                                        @NotNull final PsiMethod sourceMethod) {
  final PsiElement copy = typeParameter.copy();
  final Map<PsiElement, PsiElement> replacementMap = new HashMap<PsiElement, PsiElement>();
  copy.accept(new JavaRecursiveElementVisitor() {
    @Override
    public void visitReferenceElement(PsiJavaCodeReferenceElement reference) {
      super.visitReferenceElement(reference);
      final PsiElement resolve = reference.resolve();
      if (resolve instanceof PsiTypeParameter) {
        final PsiType type = factory.createType((PsiTypeParameter)resolve);
        replacementMap.put(reference, factory.createReferenceElementByType((PsiClassType)substituteType(substitutor, type, sourceMethod)));
      }
    }
  });
  return (PsiTypeParameter)RefactoringUtil.replaceElementsWithMap(copy, replacementMap);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GenerateMembersUtil.java

示例11: compute

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@Override
public Result<Map<String, XmlTag>> compute() {
  final Map<String,XmlTag> resultMap = new HashMap<String, XmlTag>();
  XmlDocument document = HtmlUtil.getRealXmlDocument(myFile.getDocument());
  final XmlTag rootTag = document != null ? document.getRootTag():null;

  if (rootTag != null) {
    processXmlElements(rootTag,
      new PsiElementProcessor<XmlTag>() {
        @Override
        public boolean execute(@NotNull final XmlTag element) {
          final String anchorValue = getAnchorValue(element);

          if (anchorValue!=null) {
            resultMap.put(anchorValue, element);
          }
          return true;
        }
      }
    );
  }
  return new Result<Map<String, XmlTag>>(resultMap, myFile);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AnchorReferenceImpl.java

示例12: visitForeachStatement

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@Override public void visitForeachStatement(@NotNull PsiForeachStatement statement) {
  if (myExpr.equals(statement.getIteratedValue())) {
    PsiType type = statement.getIterationParameter().getType();

    PsiType arrayType = type.createArrayType();
    myResult.add(createInfoImpl(arrayType, arrayType));

    PsiManager manager = statement.getManager();
    PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
    PsiClass iterableClass =
      JavaPsiFacade.getInstance(manager.getProject()).findClass("java.lang.Iterable", statement.getResolveScope());
    if (iterableClass != null && iterableClass.getTypeParameters().length == 1) {
      Map<PsiTypeParameter, PsiType> map = new HashMap<PsiTypeParameter, PsiType>();
      map.put(iterableClass.getTypeParameters()[0], PsiWildcardType.createExtends(manager, type));
      PsiType iterableType = factory.createType(iterableClass, factory.createSubstitutor(map));
      myResult.add(createInfoImpl(iterableType, iterableType));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ExpectedTypesProvider.java

示例13: getSubPackages

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
@NotNull
@Override
public PsiPackage[] getSubPackages(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
  final Map<String, PsiPackage> packagesMap = new HashMap<String, PsiPackage>();
  final String qualifiedName = psiPackage.getQualifiedName();

  for (final String prefix : myPackagePrefixIndex.getAllPackagePrefixes(scope)) {
    if (StringUtil.isEmpty(qualifiedName) || StringUtil.startsWithConcatenation(prefix, qualifiedName, ".")) {
      final int i = prefix.indexOf('.', qualifiedName.length() + 1);
      String childName = i >= 0 ? prefix.substring(0, i) : prefix;
      if (!packagesMap.containsKey(childName)) {
        packagesMap.put(childName, new PsiPackageImpl(psiPackage.getManager(), childName));
      }
    }
  }

  packagesMap.remove(qualifiedName);    // avoid SOE caused by returning a package as a subpackage of itself
  return packagesMap.values().toArray(new PsiPackage[packagesMap.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PackagePrefixElementFinder.java

示例14: addOrChangeAccessor

import com.intellij.util.containers.HashMap; //导入依赖的package包/类
private PsiMethod addOrChangeAccessor(PsiMethod prototype, HashMap<String,PsiMethod> nameToAncestor) {
  PsiMethod existing = myClass.findMethodBySignature(prototype, false);
  PsiMethod result = existing;
  try{
    if (existing == null){
      PsiUtil.setModifierProperty(prototype, myDescriptor.getAccessorsVisibility(), true);
      result = (PsiMethod) myClass.add(prototype);
    }
    else{
      //TODO : change visibility
    }
    nameToAncestor.put(prototype.getName(), result);
    return result;
  }
  catch(IncorrectOperationException e){
    LOG.error(e);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EncapsulateFieldsProcessor.java

示例15: 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


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