當前位置: 首頁>>代碼示例>>Java>>正文


Java CompletionParameters.getPosition方法代碼示例

本文整理匯總了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);
		}
	}
}
 
開發者ID:kayler-renslow,項目名稱:arma-intellij-plugin,代碼行數:24,代碼來源:SQFVariableCompletionProvider.java

示例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);
    }
}
 
開發者ID:durkiewicz,項目名稱:elm-plugin,代碼行數:23,代碼來源:ElmMainCompletionProvider.java

示例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));
    }
}
 
開發者ID:whitefire,項目名稱:eZ-completion,代碼行數:22,代碼來源:TranslationCompletionProvider.java

示例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();
}
 
開發者ID:getgauge,項目名稱:Intellij-Plugin,代碼行數:21,代碼來源:StepCompletionContributor.java

示例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);
	}
}
 
開發者ID:consulo,項目名稱:consulo-csharp,代碼行數:21,代碼來源:CSharpNoVariantsDelegator.java

示例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);
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:20,代碼來源:MagicCompletionContributor.java

示例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);
	}
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:19,代碼來源:JavaMethodHandleCompletionContributor.java

示例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));
	}
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:25,代碼來源:JavaReflectionCompletionContributor.java

示例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);
                            }
                        }
                    }

                }
            }
        }
    }
 
開發者ID:nvlad,項目名稱:yii2support,代碼行數:31,代碼來源:FieldAttributesCompletionProvider.java

示例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));
            }
        }
    }
}
 
開發者ID:rentalhost,項目名稱:laravel-insight,代碼行數:28,代碼來源:ScopeCompletionContributor.java

示例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));
}
 
開發者ID:whitefire,項目名稱:roc-completion,代碼行數:31,代碼來源:SettingCompletionBuilder.java

示例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();
    }
}
 
開發者ID:whitefire,項目名稱:roc-completion,代碼行數:34,代碼來源:SettingCompletionBuilder.java


注:本文中的com.intellij.codeInsight.completion.CompletionParameters.getPosition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。