本文整理汇总了Java中com.intellij.codeInsight.completion.CompletionParameters.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java CompletionParameters.getPosition方法的具体用法?Java CompletionParameters.getPosition怎么用?Java CompletionParameters.getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.completion.CompletionParameters
的用法示例。
在下文中一共展示了CompletionParameters.getPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
public void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
Validate.notNull(parameters);
Validate.notNull(result);
final Project project = this.getProject(parameters);
if (null == project) {
return;
}
final PsiElement psiElementUnderCaret = parameters.getPosition();
final ImpexHeaderTypeName headerTypeName = this.getHeaderTypeNamePsiElementOfAttribute(psiElementUnderCaret);
if (headerTypeName != null) {
fillDomAttributesCompletions(project, headerTypeName, result);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:ImpexHeaderItemTypeAttributeNameCompletionProvider.java
示例2: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
PsiElement cursor = parameters.getOriginalPosition(); //cursor is on a word
Project project = parameters.getOriginalFile().getProject();
boolean originalPositionNull = cursor == null;
if (originalPositionNull) {
cursor = parameters.getPosition(); //cursor is after a word
}
if (forLocalVars) {
if (cursor.getText().startsWith("_fnc")) {
CompletionAdders.addFunctions(parameters, result);
}
addVariables(parameters, result, cursor);
} else {
if (cursor.getText().startsWith("BIS_")) {
CompletionAdders.addBISFunctions(project, result);
} else {
addVariables(parameters, result, cursor);
CompletionAdders.addCommands(project, result);
}
}
}
示例3: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet resultSet) {
PsiElement position = parameters.getPosition();
PsiElement parent = position.getParent();
PsiElement grandParent = Optional.ofNullable(parent)
.map(PsiElement::getParent)
.orElse(null);
if (parent instanceof ElmFile || parent instanceof GeneratedParserUtilBase.DummyBlock) {
addCompletionsInInvalidExpression(position, resultSet);
} else if (grandParent instanceof ElmLowerCasePath) {
this.addValueOrFieldCompletions((ElmLowerCaseId) parent, resultSet);
} else if (grandParent instanceof ElmMixedCasePath
|| grandParent instanceof ElmUpperCasePath) {
addTypeOrModuleCompletions(parent, resultSet);
} else if (grandParent instanceof ElmExposingClause) {
this.addExposedValuesCompletion((ElmExposingClause)grandParent, resultSet);
} else if (parent instanceof ElmUpperCaseId) {
this.addExposedValuesCompletion((ElmUpperCaseId)parent, resultSet);
} else if (parent instanceof ElmLowerCaseId && grandParent instanceof ElmModuleDeclaration) {
this.singleModuleValueProvider.addCompletions((ElmFile)grandParent.getContainingFile(), resultSet);
}
}
示例4: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
{
PsiElement psiElement = parameters.getPosition();
String contentClass = getClassName(psiElement);
if (contentClass == null) {
return;
}
CompletionPreloader preloader = CompletionPreloader.getInstance(psiElement.getProject());
CompletionContainer completions = preloader.getCurrentCompletions();
Set<String> fieldIdentifiers = completions.getFieldIdentifiers(contentClass);
if (fieldIdentifiers == null) {
return;
}
for (final String fieldIdentifier : fieldIdentifiers) {
result.addElement(new Completion().initalizeSimpleCompletion(fieldIdentifier));
}
}
示例5: getPrefix
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
public static String getPrefix(CompletionParameters parameters) {
PsiElement insertedElement = parameters.getPosition();
int offsetInFile = parameters.getOffset();
PsiReference ref = insertedElement.getContainingFile().findReferenceAt(offsetInFile);
if (isStep(insertedElement) && ref != null) {
List<TextRange> ranges = ReferenceRange.getRanges(ref);
PsiElement element = ref.getElement();
int startOffset = element.getTextRange().getStartOffset();
for (TextRange range : ranges) {
if (range.contains(offsetInFile - startOffset)) {
int endIndex = offsetInFile - startOffset;
int startIndex = range.getStartOffset();
return StringUtil.trimStart(element.getText().substring(startIndex + 1, endIndex), " ");
}
}
}
return parameters.getPosition().getText().replace("IntellijIdeaRulezzz ", "").trim();
}
示例6: delegate
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@RequiredReadAction
private static void delegate(CompletionParameters parameters, final CompletionResultSet result, final InheritorsHolder inheritorsHolder)
{
if(parameters.getCompletionType() == CompletionType.BASIC)
{
PsiElement position = parameters.getPosition();
if(parameters.getInvocationCount() <= 1 && CSharpCompletionUtil.mayStartClassName(result) && CSharpCompletionUtil.isClassNamePossible(parameters))
{
addTypesForUsing(parameters, result, inheritorsHolder);
return;
}
//suggestChainedCalls(parameters, result, position);
}
if(parameters.getCompletionType() == CompletionType.SMART && parameters.getInvocationCount() == 2)
{
result.runRemainingContributors(parameters.withInvocationCount(3), true);
}
}
示例7: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public void fillCompletionVariants(@NotNull final CompletionParameters parameters, @NotNull final CompletionResultSet result)
{
//if (parameters.getCompletionType() != CompletionType.SMART) return;
PsiElement pos = parameters.getPosition();
if(JavaKeywordCompletion.AFTER_DOT.accepts(pos))
{
return;
}
MagicConstantInspection.AllowedValues allowedValues = getAllowedValues(pos);
if(allowedValues == null)
{
return;
}
addCompletionVariants(parameters, result, pos, allowedValues);
}
示例8: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result)
{
final PsiElement position = parameters.getPosition();
if(!isInJavaContext(position))
{
return;
}
if(METHOD_TYPE_ARGUMENT_PATTERN.accepts(position))
{
addMethodHandleVariants(position, result);
}
else if(FIELD_TYPE_ARGUMENT_PATTERN.accepts(position))
{
addFieldHandleVariants(position, result);
}
}
示例9: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result)
{
if(parameters.getCompletionType() != CompletionType.BASIC)
{
return;
}
final PsiElement position = parameters.getPosition();
if(!isInJavaContext(position))
{
return;
}
if(BEGINNING_OF_ANNOTATION_ARGUMENTS.accepts(position))
{
addVariants(position, (psiClass, isDeclared) -> addAnnotationClasses(psiClass, isDeclared, result));
//TODO handle annotations on fields and methods
}
else if(BEGINNING_OF_CONSTRUCTOR_ARGUMENTS.accepts(position))
{
addVariants(position, (psiClass, isDeclared) -> addConstructorParameterTypes(psiClass, isDeclared, result));
}
}
示例10: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
MethodReference methodRef = ClassUtils.getMethodRef(completionParameters.getPosition(), 10);
PsiElement position = completionParameters.getPosition();
if (methodRef != null) {
Method method = (Method) methodRef.resolve();
int paramPosition = ClassUtils.indexForElementInParameterList(completionParameters.getPosition());
// attribute plus model parameters
if (method != null && paramPosition > 0 && method.getParameters().length > paramPosition) {
if (method.getParameters()[paramPosition].getName().equals("attribute") &&
method.getParameters()[paramPosition - 1].getName().equals("model")) {
PsiElement element = methodRef.getParameters()[paramPosition - 1];
if (element instanceof Variable) {
PhpClass classByVariable = ClassUtils.getClassByVariable((Variable) element);
if (classByVariable != null &&
ClassUtils.isClassInherit(classByVariable, "yii\\base\\Model", PhpIndex.getInstance(position.getProject()) )) {
Collection<Field> classFields = ClassUtils.getClassFields(classByVariable);
PhpExpression position2 = (PhpExpression) completionParameters.getPosition().getParent();
for (Field field : classFields) {
LookupElementBuilder lookupBuilder = buildLookup(field, position2);
completionResultSet.addElement(lookupBuilder);
}
}
}
}
}
}
}
示例11: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
public void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
final PsiElement element = parameters.getPosition();
final List<PhpClass> elementClasses = PhpClassUtil.resolve(element.getParent());
if (elementClasses.isEmpty()) {
return;
}
for (final PhpClass elementClass : elementClasses) {
if (PhpClassUtil.findSuperOfType(elementClass, LaravelClasses.ELOQUENT_MODEL.toString()) == null) {
return;
}
for (final Method method : elementClass.getMethods()) {
if (method.getName().startsWith("scope")) {
final String methodSliced = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, method.getName().substring(5));
result.addElement(new CompletionContributorLookupElement(element, method, methodSliced));
}
}
}
}
示例12: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
public void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
Validate.notNull(parameters);
Validate.notNull(result);
final PsiElement psiElementUnderCaret = parameters.getPosition();
final ImpexAttribute impexAttribute = PsiTreeUtil.getParentOfType(
psiElementUnderCaret, ImpexAttribute.class
);
if (impexAttribute == null) {
return;
}
final String modifierName = impexAttribute.getAnyAttributeName().getText();
final ImpexModifier impexModifier = AttributeModifier.getByModifierName(modifierName);
if (null != impexModifier) {
for (String possibleValue : impexModifier.getModifierValues()) {
result.addElement(LookupElementBuilder.create(possibleValue));
}
} else {
// show error message when not defined within hybris API
Notifications.Bus.notify(new Notification(
ImpexLanguage.getInstance().getDisplayName(),
"possible error in your impex",
"You typed an unknown hybris-ATTRIBUTE-modifier with name '" + modifierName + "'.",
NotificationType.WARNING
));
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:39,代码来源:ImpexHeaderAttributeModifierValueCompletionProvider.java
示例13: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
@Override
public void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
Validate.notNull(parameters);
Validate.notNull(result);
final PsiElement psiElementUnderCaret = parameters.getPosition();
final ImpexAttribute impexAttribute = PsiTreeUtil.getParentOfType(
psiElementUnderCaret, ImpexAttribute.class
);
if (impexAttribute == null) {
return;
}
final String modifierName = impexAttribute.getAnyAttributeName().getText();
final ImpexModifier impexModifier = TypeModifier.getByModifierName(modifierName);
if (null != impexModifier) {
for (String possibleValue : impexModifier.getModifierValues()) {
result.addElement(LookupElementBuilder.create(possibleValue));
}
} else {
// show error message when not defined within hybris API
Notifications.Bus.notify(new Notification(
ImpexLanguage.getInstance().getDisplayName(),
"possible error in your impex",
"You typed an unknown hybris-TYPE-modifier with name '" + modifierName + "'.",
NotificationType.WARNING
));
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:40,代码来源:ImpexHeaderTypeModifierValueCompletionProvider.java
示例14: buildCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
static List<SettingLookupElement> buildCompletions(CompletionParameters parameters, String prefix)
{
PsiElement position = parameters.getPosition();
JSProperty property = PsiTreeUtil.getParentOfType(position, JSProperty.class);
// Unable to determine where in roc.settings.js we are.
if (property == null)
{
return Collections.emptyList();
}
String namespace = property
.getJSNamespace()
.toString();
// Wrong file, or wrong structure.
if (!namespace.startsWith(SettingContainer.ROOT_NAMESPACE)) {
return Collections.emptyList();
}
SettingContainer settingContainer = CompletionPreloader.getCompletions();
Map<String, JSProperty> existingSettings = findExistingSettings(parameters, prefix);
List<Setting> settings = settingContainer.getSettings(namespace, existingSettings);
return settings
.stream()
.map(setting -> new SettingLookupElement(setting, namespace))
.collect(Collectors.toCollection(ArrayList::new));
}
示例15: findExistingSettings
import com.intellij.codeInsight.completion.CompletionParameters; //导入方法依赖的package包/类
static private Map<String, JSProperty> findExistingSettings(CompletionParameters parameters, String prefix)
{
PsiFile file = parameters.getOriginalFile();
StringBuffer buffer;
// User was typing and probably screwed up the syntax in the process :-/
if (parameters.isAutoPopup())
{
PsiElement position = parameters.getPosition();
Integer startOffset = position.getTextOffset();
Integer endOffset = startOffset + prefix.length();
buffer = new StringBuffer(file.getText());
buffer = buffer.replace(startOffset, endOffset, "");
file = PsiFileFactory
.getInstance(position.getProject())
.createFileFromText(position.getLanguage(), buffer.toString());
}
try
{
RecursivePropertyWalker walker = new RecursivePropertyWalker();
walker.visitFile(file);
return walker.getExistingProperties();
}
catch (Exception e)
{
return Collections.emptyMap();
}
}