本文整理汇总了Java中com.intellij.util.ProcessingContext.put方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessingContext.put方法的具体用法?Java ProcessingContext.put怎么用?Java ProcessingContext.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ProcessingContext
的用法示例。
在下文中一共展示了ProcessingContext.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accepts
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
@Override
public boolean accepts(@NotNull PyReferenceExpression pyReferenceExpression, ProcessingContext context) {
PsiElement referencedElement = pyReferenceExpression.getReference().resolve();
if (!(referencedElement instanceof PyClass)) {
return false;
}
PyClass pyClass = (PyClass)referencedElement;
SyntheticTypeInfo sti = new SyntheticTypeInfoReader(pyClass).read();
if (sti.hasSyntheticConstructor() && pyClass.findInitOrNew(false, null) == null) {
// Need to put the SyntheticTypeInfo inside the ProcessingContext,
// because reference.resolve() cannot be done in addCompletions.
context.put(SYNTHETIC_TYPE_INFO_KEY, sti);
return true;
}
return false;
}
示例2: getProximity
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
@Nullable
public static WeighingComparable<PsiElement, ProximityLocation> getProximity(final Computable<PsiElement> elementComputable, final PsiElement context, ProcessingContext processingContext) {
PsiElement element = elementComputable.compute();
if (element == null) return null;
if (element instanceof MetadataPsiElementBase) return null;
if (context == null) return null;
Module contextModule = processingContext.get(MODULE_BY_LOCATION);
if (contextModule == null) {
contextModule = ModuleUtilCore.findModuleForPsiElement(context);
processingContext.put(MODULE_BY_LOCATION, contextModule);
}
if (contextModule == null) return null;
return new WeighingComparable<PsiElement,ProximityLocation>(elementComputable,
new ProximityLocation(context, contextModule, processingContext),
PROXIMITY_WEIGHERS);
}
示例3: fillFromDir
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
/**
* Adds variants found under given dir.
*/
private void fillFromDir(PsiDirectory targetDir, @Nullable InsertHandler<LookupElement> insertHandler) {
if (targetDir != null) {
PsiFile initPy = targetDir.findFile(PyNames.INIT_DOT_PY);
if (initPy instanceof PyFile) {
PyModuleType moduleType = new PyModuleType((PyFile)initPy);
ProcessingContext context = new ProcessingContext();
context.put(PyType.CTX_NAMES, myNamesAlready);
Object[] completionVariants = moduleType.getCompletionVariants("", getElement(), context);
if (insertHandler != null) {
replaceInsertHandler(completionVariants, insertHandler);
}
myObjects.addAll(Arrays.asList(completionVariants));
}
else {
myObjects.addAll(PyModuleType.getSubModuleVariants(targetDir, myElement, myNamesAlready));
}
}
}
示例4: getVariants
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
@Override
@NotNull
public Object[] getVariants() {
final ProcessingContext context = new ProcessingContext();
context.put(VARIANTS, new HashSet<XmlAttributeValue>());
final ResolvingVisitor visitor = new ResolvingVisitor(PATTERN.with(AddValueCondition.create(VARIANTS)), context) {
@Override
public void visitXmlTag(XmlTag tag) {
super.visitXmlTag(tag);
visitSubTags(tag);
}
};
process(visitor);
return AttributeValueFunction.toStrings(context.get(VARIANTS));
}
示例5: save
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
public static <T> ElementPattern save(final Key<T> key) {
return new ObjectPattern.Capture<T>(new InitialPatternCondition(Object.class) {
@Override
public boolean accepts(@Nullable final Object o, final ProcessingContext context) {
context.put(key, (T)o);
return true;
}
@Override
public void append(@NotNull @NonNls final StringBuilder builder, final String indent) {
builder.append("save(").append(key).append(")");
}
});
}
示例6: addMatchingProviders
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
static void addMatchingProviders(@NotNull PsiElement position,
@Nullable final List<ProviderInfo<ElementPattern>> providerList,
@NotNull Collection<ProviderInfo<ProcessingContext>> output,
@NotNull PsiReferenceService.Hints hints) {
if (providerList == null) return;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < providerList.size(); i++) {
ProviderInfo<ElementPattern> info = providerList.get(i);
if (hints != PsiReferenceService.Hints.NO_HINTS && !info.provider.acceptsHints(position, hints)) {
continue;
}
final ProcessingContext context = new ProcessingContext();
if (hints != PsiReferenceService.Hints.NO_HINTS) {
context.put(PsiReferenceService.HINTS, hints);
}
boolean suitable = false;
try {
suitable = info.processingContext.accepts(position, context);
}
catch (IndexNotReadyException ignored) {
}
if (suitable) {
output.add(new ProviderInfo<ProcessingContext>(info.provider, context, info.priority));
}
}
}
示例7: createContext
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
private ProcessingContext createContext(boolean pureRelevance) {
ProcessingContext context = new ProcessingContext();
context.put(PREFIX_CHANGES, myPrefixChanges);
context.put(WEIGHING_CONTEXT, myProcess.getLookup());
if (pureRelevance) {
context.put(PURE_RELEVANCE, Boolean.TRUE);
}
return context;
}
示例8: findPsiType
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
@NotNull
public static PsiType findPsiType(GroovyClassDescriptor descriptor, ProcessingContext ctx) {
String typeText = descriptor.getTypeText();
final String key = getClassKey(typeText);
final Object cached = ctx.get(key);
if (cached instanceof PsiType) {
return (PsiType)cached;
}
final PsiType found = JavaPsiFacade.getElementFactory(descriptor.getProject()).createTypeFromText(typeText, descriptor.getPlaceFile());
ctx.put(key, found);
return found;
}
示例9: getCompletionVariants
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
public Object[] getCompletionVariants(String prefix, PsiElement location, ProcessingContext context) {
Set<PyClassType> visited = context.get(CTX_VISITED);
if (visited == null) {
visited = new HashSet<PyClassType>();
context.put(CTX_VISITED, visited);
}
if (visited.contains(this)) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
visited.add(this);
Set<String> namesAlready = context.get(CTX_NAMES);
if (namesAlready == null) {
namesAlready = new HashSet<String>();
}
List<Object> ret = new ArrayList<Object>();
boolean suppressParentheses = context.get(CTX_SUPPRESS_PARENTHESES) != null;
addOwnClassMembers(location, namesAlready, suppressParentheses, ret);
PsiFile origin = (location != null) ?
CompletionUtil.getOriginalOrSelf(location)
.getContainingFile() :
null;
final TypeEvalContext typeEvalContext = TypeEvalContext.codeCompletion(myClass.getProject(), origin);
addInheritedMembers(prefix, location, namesAlready, context, ret, typeEvalContext);
// from providers
for (final PyClassMembersProvider provider : Extensions.getExtensions(PyClassMembersProvider.EP_NAME)) {
for (final PyCustomMember member : provider.getMembers(this, location)) {
final String name = member.getName();
if (!namesAlready.contains(name)) {
ret.add(PyCustomMemberUtils.toLookUpElement(member, getName()));
}
}
}
if (!myClass.isNewStyleClass(null)) {
final PyBuiltinCache cache = PyBuiltinCache.getInstance(myClass);
final PyClassType classobjType = cache.getOldstyleClassobjType();
if (classobjType != null) {
ret.addAll(Arrays.asList(classobjType.getCompletionVariants(prefix, location, context)));
}
}
if (isDefinition() && myClass.isNewStyleClass(null)) {
final PyClassLikeType typeType = getMetaClassType(typeEvalContext, true);
if (typeType != null) {
Collections.addAll(ret, typeType.getCompletionVariants(prefix, location, context));
}
}
return ret.toArray();
}
示例10: getTypeCompletionVariants
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
protected static Object[] getTypeCompletionVariants(PyExpression pyExpression, PyType type) {
ProcessingContext context = new ProcessingContext();
context.put(PyType.CTX_NAMES, new HashSet<String>());
return type.getCompletionVariants(pyExpression.getName(), pyExpression, context);
}
示例11: execute
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
public Object[] execute() {
int relativeLevel = -1;
InsertHandler<LookupElement> insertHandler = null;
// NOTE: could use getPointInImport()
// are we in "import _" or "from foo import _"?
PyFromImportStatement fromImport = PsiTreeUtil.getParentOfType(myElement, PyFromImportStatement.class);
if (fromImport != null && myElement.getParent() != fromImport) { // in "from foo import _"
PyReferenceExpression src = fromImport.getImportSource();
if (src != null) {
PsiElement modCandidate = src.getReference().resolve();
if (modCandidate instanceof PyExpression) {
addImportedNames(fromImport.getImportElements()); // don't propose already imported items
// try to collect submodules
PyExpression module = (PyExpression)modCandidate;
PyType qualifierType = myContext.getType(module);
if (qualifierType != null) {
ProcessingContext ctx = new ProcessingContext();
ctx.put(PyType.CTX_NAMES, myNamesAlready);
Collections.addAll(myObjects, qualifierType.getCompletionVariants(myElement.getName(), myElement, ctx));
}
return myObjects.toArray();
}
else if (modCandidate instanceof PsiDirectory) {
fillFromDir((PsiDirectory)modCandidate, ImportKeywordHandler.INSTANCE);
return myObjects.toArray();
}
}
else { // null source, must be a "from ... import"
relativeLevel = fromImport.getRelativeLevel();
if (relativeLevel > 0) {
PsiDirectory relativeDir = ResolveImportUtil.stepBackFrom(myCurrentFile, relativeLevel);
if (relativeDir != null) {
addImportedNames(fromImport.getImportElements());
fillFromDir(relativeDir, null);
}
}
}
}
else { // in "import _" or "from _ import"
PsiElement prevElem = PyPsiUtils.getPrevNonWhitespaceSibling(myElement);
while (prevElem != null && prevElem.getNode().getElementType() == PyTokenTypes.DOT) {
relativeLevel += 1;
prevElem = PyPsiUtils.getPrevNonWhitespaceSibling(prevElem);
}
if (fromImport != null) {
addImportedNames(fromImport.getImportElements());
if (!alreadyHasImportKeyword()) {
insertHandler = ImportKeywordHandler.INSTANCE;
}
}
else {
myNamesAlready.add(PyNames.FUTURE_MODULE); // never add it to "import ..."
PyImportStatement importStatement = PsiTreeUtil.getParentOfType(myElement, PyImportStatement.class);
if (importStatement != null) {
addImportedNames(importStatement.getImportElements());
}
}
// look at dir by level
if ((relativeLevel >= 0 || !ResolveImportUtil.isAbsoluteImportEnabledFor(myCurrentFile))) {
final PsiDirectory containingDirectory = myCurrentFile.getContainingDirectory();
if (containingDirectory != null) {
QualifiedName thisQName = QualifiedNameFinder.findShortestImportableQName(containingDirectory);
if (thisQName == null || thisQName.getComponentCount() == relativeLevel) {
fillFromDir(ResolveImportUtil.stepBackFrom(myCurrentFile, relativeLevel), insertHandler);
}
else if (thisQName.getComponentCount() > relativeLevel) {
thisQName = thisQName.removeTail(relativeLevel);
fillFromQName(thisQName, insertHandler);
}
}
}
}
if (relativeLevel == -1) {
fillFromQName(QualifiedName.fromComponents(), insertHandler);
}
return ArrayUtil.toObjectArray(myObjects);
}
示例12: getReferencesByElement
import com.intellij.util.ProcessingContext; //导入方法依赖的package包/类
@Override
@NotNull
public final PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull final ProcessingContext context) {
final DomManagerImpl domManager = DomManagerImpl.getDomManager(psiElement.getProject());
final DomInvocationHandler<?, ?> handler;
if (psiElement instanceof XmlTag) {
handler = domManager.getDomHandler((XmlTag)psiElement);
} else if (psiElement instanceof XmlAttributeValue && psiElement.getParent() instanceof XmlAttribute) {
handler = domManager.getDomHandler((XmlAttribute)psiElement.getParent());
} else {
return PsiReference.EMPTY_ARRAY;
}
if (handler == null || !GenericDomValue.class.isAssignableFrom(handler.getRawType())) {
return PsiReference.EMPTY_ARRAY;
}
if (psiElement instanceof XmlTag) {
for (XmlText text : ((XmlTag)psiElement).getValue().getTextElements()) {
if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)text)) return PsiReference.EMPTY_ARRAY;
}
} else {
if (InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost)psiElement)) return PsiReference.EMPTY_ARRAY;
}
final GenericDomValue domValue = (GenericDomValue)handler.getProxy();
final Referencing referencing = handler.getAnnotation(Referencing.class);
final Object converter;
if (referencing == null) {
converter = WrappingConverter.getDeepestConverter(domValue.getConverter(), domValue);
}
else {
Class<? extends CustomReferenceConverter> clazz = referencing.value();
converter = ((ConverterManagerImpl)domManager.getConverterManager()).getInstance(clazz);
}
PsiReference[] references = createReferences(domValue, (XmlElement)psiElement, converter, handler, domManager);
if (ApplicationManager.getApplication().isUnitTestMode()) {
for (PsiReference reference : references) {
if (!reference.isSoft()) {
LOG.error("dom reference should be soft: " + reference + " (created by " + converter + ")");
}
}
}
if (references.length > 0) {
if (converter instanceof EnumConverter && !((EnumConverter)converter).isExhaustive()) {
// will be handled by core XML
return PsiReference.EMPTY_ARRAY;
}
context.put(XmlEnumeratedValueReferenceProvider.SUPPRESS, Boolean.TRUE);
}
return references;
}