本文整理汇总了Java中com.intellij.util.ProcessingContext类的典型用法代码示例。如果您正苦于以下问题:Java ProcessingContext类的具体用法?Java ProcessingContext怎么用?Java ProcessingContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessingContext类属于com.intellij.util包,在下文中一共展示了ProcessingContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement caller = parameters.getPosition().getPrevSibling().getPrevSibling();
String ns = TSUtil.getElementNamespace(caller);
//All global functions
Project project = parameters.getOriginalFile().getProject();
Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
for (TSFnDeclStmt function : functions) {
if (function.getFunctionType() == TSFunctionType.GLOBAL)
continue;
result.addElement(
LookupElementBuilder.create(function.getFunctionName())
.withCaseSensitivity(false)
.withPresentableText(function.getNamespace() + "." + function.getFunctionName())
.withBoldness(ns != null && function.getNamespace().equalsIgnoreCase(ns))
.withTailText(function.getArgList())
.withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
);
}
}
示例2: extendWithTemplateDefinitionLevelKeywords
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
/**
* Complete the "visibility" and "stricthtml" keywords in template definition open tags.
*/
private void extendWithTemplateDefinitionLevelKeywords() {
extend(
CompletionType.BASIC,
psiElement().andOr(psiElement().inside(SoyBeginTemplate.class)),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(
@NotNull CompletionParameters completionParameters,
ProcessingContext processingContext,
@NotNull CompletionResultSet completionResultSet) {
if (isPrecededBy(completionParameters.getPosition(),
elt -> elt instanceof SoyTemplateDefinitionIdentifier)) {
completionResultSet.addElement(
LookupElementBuilder.create("visibility=\"private\""));
completionResultSet.addElement(
LookupElementBuilder.create("stricthtml=\"true\""));
}
}
});
}
示例3: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
List<TSVarExpr> variables = new ArrayList<>();
for (PsiElement current = parameters.getPosition().getPrevSibling(); current != null; current = current.getPrevSibling()) {
if (current.getNode().getElementType().equals(TSTypes.FUNCTION))
break;
if (current.getNode().getElementType().equals(TSTypes.LOCALVAR)) {
String prefixless = current.getText().substring(1);
result.addElement(
LookupElementBuilder.create(prefixless)
.withPresentableText(current.getText())
.withCaseSensitivity(false)
);
}
}
}
示例4: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
String namespace = parameters.getPosition().getPrevSibling().getPrevSibling().getText();
Project project = parameters.getOriginalFile().getProject();
Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
for (TSFnDeclStmt function : functions) {
if (function.getFunctionType() == TSFunctionType.GLOBAL)
continue;
if (namespace != null && !function.getNamespace().equalsIgnoreCase(namespace))
continue;
result.addElement(
LookupElementBuilder.create(function.getFunctionName())
.withCaseSensitivity(false)
.withPresentableText(function.getNamespace() + "::" + function.getFunctionName())
.withTailText(function.getArgList())
.withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
);
}
}
示例5: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
//All global functions
Project project = parameters.getOriginalFile().getProject();
Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
for (TSFnDeclStmt function : functions) {
if (function.getFunctionType() != TSFunctionType.GLOBAL)
continue;
result.addElement(
LookupElementBuilder.create(function)
.withCaseSensitivity(false)
.withTailText(function.getArgList())
.withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE)
);
}
}
示例6: KeywordCompletionContributor
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
public KeywordCompletionContributor() {
extend(CompletionType.BASIC, psiElement().inFile(StandardPatterns.instanceOf(AppleScriptFile.class)),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters,
ProcessingContext processingContext,
@NotNull CompletionResultSet completionResultSet) {
PsiFile file = completionParameters.getOriginalFile();
if (!(file instanceof AppleScriptFile)) return;
PsiElement position = completionParameters.getPosition();
if (position instanceof PsiComment) return;
ASTNode node = position.getNode();
if (node.getElementType() == AppleScriptTypes.STRING_LITERAL) return;
for (IElementType kwElem : AppleScriptTokenTypesSets.KEYWORDS.getTypes()) {
completionResultSet.addElement(LookupElementBuilder
.create(kwElem.toString().toLowerCase().replaceAll("_", " ")).bold()
.withTypeText("keyword", true));
}
}
});
}
示例7: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
MerlinService merlin = ApplicationManager.getApplication().getComponent(MerlinService.class);
PsiFile originalFile = parameters.getOriginalFile();
String text = originalFile.getText();
LineNumbering lineNumbering = new LineNumbering(text);
String suitablePrefix = findSuitablePrefix(parameters, text);
MerlinPosition position = lineNumbering.offsetToPosition(parameters.getOffset());
MerlinCompletion completion = merlin.completions(originalFile.getName(), text, position, suitablePrefix);
for (MerlinCompletionEntry entry : completion.entries) {
resultSet.addElement(LookupElementBuilder.
create(entry.name).
withIcon(getIcon(entry)).
withTypeText(entry.desc));
}
}
示例8: registerReferenceProviders
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
// follow, redirect
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(StringLiteralExpression.class),
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!(element instanceof StringLiteralExpression)) {
return new PsiReference[0];
}
StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) element;
String methodName = PhpLangUtil.getMethodName(element);
int parameterPosition = PhpLangUtil.getParameterPosition(stringLiteralExpression);
if (methodName != null && isDirectingActionName(methodName) && parameterPosition == 0) {
return new PsiReference[]{new ControllerActionReference(stringLiteralExpression)};
}
return new PsiReference[0];
}
}
);
}
示例9: registerReferenceProviders
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(StringLiteralExpression.class),
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (isGenerator(element)) {
return new PsiReference[]{new RouteReference((StringLiteralExpression) element)};
}
return new PsiReference[0];
}
}
);
}
示例10: registerReferenceProviders
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
// "EXT:" strings
registrar.registerReferenceProvider(
PlatformPatterns.psiElement(StringLiteralExpression.class),
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
StringLiteralExpression stringLiteralExpression = (StringLiteralExpression)element;
if (!stringLiteralExpression.getContents().startsWith("EXT:")) {
return new PsiReference[0];
}
return new PsiReference[]{new ResourceReference(stringLiteralExpression)};
}
}
);
}
示例11: registerReferenceProviders
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(PlatformPatterns.psiElement(StringLiteralExpression.class), new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!(element instanceof StringLiteralExpression)) {
return new PsiReference[0];
}
StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) element;
if (!stringLiteralExpression.getContents().startsWith("LLL:")) {
return new PsiReference[0];
}
return new PsiReference[]{new TranslationReference(stringLiteralExpression)};
}
});
}
示例12: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null || !(position instanceof XmlElement)) {
return;
}
DiIndex diIndex = DiIndex.getInstance(position.getProject());
PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) position);
if (phpClass != null) {
Method constructor = phpClass.getConstructor();
if (constructor != null) {
for (Parameter parameter : constructor.getParameters()) {
result.addElement(
LookupElementBuilder
.create(parameter.getName())
.withIcon(parameter.getIcon())
);
}
}
}
}
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:26,代码来源:PhpConstructorArgumentCompletionProvider.java
示例13: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
Collection<String> keys = LayoutIndex.getAllKeys(ContainerNameIndex.KEY, position.getProject());
for (String key: keys) {
result.addElement(
LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
);
}
}
示例14: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
String prefix = result.getPrefixMatcher().getPrefix();
Collection<String> moduleNames
= FileBasedIndex.getInstance().getAllKeys(ModuleNameIndex.KEY, position.getProject());
moduleNames.removeIf(m -> !m.startsWith(prefix));
for (String moduleName : moduleNames) {
result.addElement(
LookupElementBuilder
.create(moduleName)
.withIcon(AllIcons.Modules.ModulesNode)
);
}
}
示例15: addCompletions
import com.intellij.util.ProcessingContext; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
Collection<String> keys = LayoutIndex.getAllKeys(BlockNameIndex.KEY, position.getProject());
for (String key: keys) {
result.addElement(
LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON)
);
}
}