本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
}
}
示例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()]);
}
示例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;
}
示例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;
}