Java Code Examples for com.intellij.codeInsight.completion.CompletionParameters#getOriginalPosition()
The following examples show how to use
com.intellij.codeInsight.completion.CompletionParameters#getOriginalPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SQFVariableCompletionProvider.java From arma-intellij-plugin with MIT License | 6 votes |
@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); } CompletionAdders.addVariables(parameters, context, result, cursor, true); } else { if (cursor.getText().startsWith("BIS_")) { CompletionAdders.addBISFunctions(project, result); } else { CompletionAdders.addLiterals(cursor, result, false); CompletionAdders.addVariables(parameters, context, result, cursor, false); CompletionAdders.addCommands(project, result); } } }
Example 2
Source File: SQFVariableCompletionProvider.java From arma-intellij-plugin with MIT License | 6 votes |
@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); } CompletionAdders.addVariables(parameters, context, result, cursor, true); } else { if (cursor.getText().startsWith("BIS_")) { CompletionAdders.addBISFunctions(project, result); } else { CompletionAdders.addLiterals(cursor, result, false); CompletionAdders.addVariables(parameters, context, result, cursor, false); CompletionAdders.addCommands(project, result); } } }
Example 3
Source File: PhpClassAndParameterCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, final @NotNull CompletionResultSet resultSet) { PsiElement psiElement = parameters.getOriginalPosition(); if(psiElement == null || !Symfony2ProjectComponent.isEnabled(psiElement)) { return; } PhpClassCompletionProvider.addClassCompletion(parameters, resultSet, psiElement, false); for( Map.Entry<String, ContainerParameter> entry: ContainerCollectionResolver.getParameters(psiElement.getProject()).entrySet()) { resultSet.addElement( new ParameterLookupElement(entry.getValue(), ParameterPercentWrapInsertHandler.getInstance(), psiElement.getText()) ); } }
Example 4
Source File: FluidTypeCompletionProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement psiElement = parameters.getOriginalPosition(); if (psiElement == null) { return; } Collection<String> possibleTypes = FluidTypeResolver.formatPsiTypeName(psiElement, cutLastSegment); for (FluidTypeContainer fluidTypeContainer : FluidTypeResolver.resolveFluidMethodName(psiElement, possibleTypes)) { if (fluidTypeContainer.getPhpNamedElement() instanceof PhpClass) { for (Method method : ((PhpClass) fluidTypeContainer.getPhpNamedElement()).getMethods()) { if (!(!method.getModifier().isPublic() || method.getName().startsWith("set") || method.getName().startsWith("__"))) { result.addElement(new PhpFluidMethodLookupElement(method)); } } for (Field field : ((PhpClass) fluidTypeContainer.getPhpNamedElement()).getFields()) { if (field.getModifier().isPublic()) { result.addElement(new PhpFluidMethodLookupElement(field)); } } } if (fluidTypeContainer.getStringElement() != null) { result.addElement(LookupElementBuilder.create(fluidTypeContainer.getStringElement())); } } }
Example 5
Source File: ControllerVariableProvider.java From idea-php-typo3-plugin with MIT License | 5 votes |
@Override public void provide(@NotNull CompletionParameters parameters, ProcessingContext context, Map<String, FluidVariable> variableMap) { PsiElement originalPosition = parameters.getOriginalPosition(); if (originalPosition == null) { return; } PsiFile containingFile = originalPosition.getContainingFile(); if (!(containingFile instanceof FluidFile)) { return; } variableMap.putAll(FluidUtil.collectControllerVariables((FluidFile) containingFile)); }
Example 6
Source File: VariableNameCompletionProvider.java From BashSupport with Apache License 2.0 | 4 votes |
@Override protected void addBashCompletions(String currentText, CompletionParameters parameters, ProcessingContext context, CompletionResultSet result) { PsiElement element = parameters.getPosition(); BashVar varElement = PsiTreeUtil.getContextOfType(element, BashVar.class, false); boolean dollarPrefix = currentText != null && currentText.startsWith("$"); boolean insideExpansion = element.getParent() != null && element.getParent().getParent() instanceof BashParameterExpansion; if (varElement == null && !dollarPrefix && !insideExpansion) { return; } int invocationCount = parameters.getInvocationCount(); int resultLength = 0; PsiElement original = parameters.getOriginalPosition(); BashVar varElementOriginal = original != null ? PsiTreeUtil.getContextOfType(original, BashVar.class, false) : null; if (varElement != null) { // only keep vars of included files when starting in the original file PsiElement originalRef = varElementOriginal != null ? varElementOriginal : original; if (originalRef != null) { resultLength += addCollectedVariables(original, result, new BashVarVariantsProcessor(originalRef, false, true)); } // only keep vars of the dummy file when starting in the dummy file resultLength += addCollectedVariables(element, result, new BashVarVariantsProcessor(varElement, true, false)); } else { // not in a variable element, but collect all known variable names at this offset in the current file if (original != null) { resultLength += addCollectedVariables(original, result, new BashVarVariantsProcessor(original, false, true)); } resultLength += addCollectedVariables(element, result, new BashVarVariantsProcessor(element, false, true)); } if (currentText != null && (dollarPrefix || insideExpansion) && (invocationCount >= 2 || resultLength == 0)) { Project project = element.getProject(); addBuiltInVariables(result, project); addGlobalVariables(result, project); } else { result.addLookupAdvertisement("Press twice for global variables"); } }
Example 7
Source File: PhpClassCompletionProvider.java From idea-php-symfony2-plugin with MIT License | 3 votes |
public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, final @NotNull CompletionResultSet resultSet) { PsiElement psiElement = parameters.getOriginalPosition(); if(!Symfony2ProjectComponent.isEnabled(psiElement)) { return; } addClassCompletion(parameters, resultSet, psiElement, withInterface, withLeadingBackslash); }