本文整理匯總了Java中com.intellij.codeInsight.completion.CompletionParameters.getOriginalFile方法的典型用法代碼示例。如果您正苦於以下問題:Java CompletionParameters.getOriginalFile方法的具體用法?Java CompletionParameters.getOriginalFile怎麽用?Java CompletionParameters.getOriginalFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.codeInsight.completion.CompletionParameters
的用法示例。
在下文中一共展示了CompletionParameters.getOriginalFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的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));
}
}
示例2: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
protected void addCompletions(
@NotNull final CompletionParameters parameters,
final ProcessingContext context,
@NotNull final CompletionResultSet result
) {
final PsiFile originalFile = parameters.getOriginalFile();
final Collection<ImpexMacroDeclaration> macroDeclarations = PsiTreeUtil.findChildrenOfType(
originalFile, ImpexMacroDeclaration.class
);
if (macroDeclarations.isEmpty()) {
return;
}
for (final ImpexMacroDeclaration macroDeclaration : macroDeclarations) {
final PsiElement declaration = macroDeclaration.getFirstChild();
result.addElement(LookupElementBuilder.create(declaration.getText())
.withIcon(HybrisIcons.MACROS));
}
}
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:23,代碼來源:ImpexMacrosCompletionProvider.java
示例3: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet)
{
final int offset = completionParameters.getOffset() - 1;
final PsiFile originalFile = completionParameters.getOriginalFile();
if (RamlUtils.isRamlFile(originalFile))
{
final String text = originalFile.getText();
System.out.println("text = " + text);
System.out.println("offset = " + offset);
final Suggestions suggestions = new RamlSuggester().suggestions(text, offset);
final List<Suggestion> suggestionList = suggestions.getSuggestions();
for (Suggestion suggestion : suggestionList)
{
final LookupElementBuilder map = LookupElementBuilder.create(suggestion.getValue())
.withPresentableText(suggestion.getLabel())
.withLookupString(suggestion.getLabel())
.withLookupString(suggestion.getValue());
completionResultSet.addElement(map);
}
}
}
示例4: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
Editor editor = parameters.getEditor();
if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
editor.getCaretModel().getCaretCount() != 1) {
/**
* disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
*/
return;
}
PsiFile originalFile = parameters.getOriginalFile();
PostfixLiveTemplate postfixLiveTemplate = getPostfixLiveTemplate(originalFile, editor);
if (postfixLiveTemplate != null) {
postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(new CustomTemplateCallback(editor, originalFile));
if (possibleKey != null) {
result = result.withPrefixMatcher(possibleKey);
result.restartCompletionOnPrefixChange(
StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(originalFile, parameters.getOffset())));
}
}
}
示例5: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiFile psiFile = parameters.getOriginalFile();
Project project = psiFile.getProject();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
if (!manager.isMavenizedProject()) return;
MavenProject projectFile = MavenDomUtil.findContainingProject(psiFile);
if (projectFile == null) return;
if (!MavenDomUtil.isMavenFile(psiFile) && !MavenDomUtil.isFilteredResourceFile(psiFile)) return;
String text = psiFile.getText();
int offset = parameters.getOffset();
int braceOffset = findOpenBrace(text, offset);
if (braceOffset == -1) return;
TextRange range = TextRange.create(braceOffset, offset);
String prefix = range.substring(text);
MavenFilteredPropertyPsiReference ref = new MavenFilteredPropertyPsiReference(projectFile, psiFile, prefix, range);
addVariants(Arrays.asList(ref.getVariants()), result.withPrefixMatcher(prefix));
}
示例6: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
String prefix = getPrefix(parameters);
resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
PsiFile specFile = parameters.getOriginalFile();
SpecDetail specDetail = PsiTreeUtil.getChildOfType(specFile, SpecDetail.class);
List<SpecStep> stepsInFile = new ArrayList<>();
addContextSteps(specDetail, stepsInFile);
addStepsInScenarios(specFile, stepsInFile);
Set<String> staticArgs = getArgsFromSteps(stepsInFile);
for (String arg : staticArgs) {
if (arg != null) {
LookupElementBuilder item = LookupElementBuilder.create(arg);
resultSet.addElement(item);
}
}
}
示例7: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
PsiFile psiFile = parameters.getOriginalFile();
Project project = psiFile.getProject();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
if (!manager.isMavenizedProject()) return;
MavenProject projectFile = MavenDomUtil.findContainingProject(psiFile);
if (projectFile == null) return;
if (!MavenDomUtil.isMavenFile(psiFile) && !MavenDomUtil.isFilteredResourceFile(psiFile)) return;
String text = psiFile.getText();
int offset = parameters.getOffset();
int braceOffset = findOpenBrace(text, offset);
if (braceOffset == -1) return;
TextRange range = TextRange.create(braceOffset, offset);
String prefix = range.substring(text);
MavenFilteredPropertyPsiReference ref = new MavenFilteredPropertyPsiReference(projectFile, psiFile, prefix, range);
addVariants(Arrays.asList(ref.getVariants()), result.withPrefixMatcher(prefix));
}
示例8: 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();
}
}
示例9: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiFile file = parameters.getOriginalFile();
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document != null) {
DataContext dataContext = document.getUserData(CommitMessage.DATA_CONTEXT_KEY);
if (dataContext != null) {
result.stopHere();
if (parameters.getInvocationCount() > 0) {
ChangeList[] lists = VcsDataKeys.CHANGE_LISTS.getData(dataContext);
if (lists != null) {
String prefix = TextFieldWithAutoCompletionListProvider.getCompletionPrefix(parameters);
CompletionResultSet insensitive = result.caseInsensitive().withPrefixMatcher(new CamelHumpMatcher(prefix));
for (ChangeList list : lists) {
for (Change change : list.getChanges()) {
ContentRevision revision = change.getAfterRevision() == null ? change.getBeforeRevision() : change.getAfterRevision();
if (revision != null) {
FilePath filePath = revision.getFile();
LookupElementBuilder element = LookupElementBuilder.create(filePath.getName()).
withIcon(filePath.getFileType().getIcon());
insensitive.addElement(element);
}
}
}
}
}
}
}
}
示例10: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiFile file = parameters.getOriginalFile();
if (!(file instanceof PsiPlainTextFile)) return;
TextFieldCompletionProvider field = file.getUserData(TextFieldCompletionProvider.COMPLETING_TEXT_FIELD_KEY);
if (field == null) return;
if (!(field instanceof DumbAware) && DumbService.isDumb(file.getProject())) return;
String text = file.getText();
int offset = Math.min(text.length(), parameters.getOffset());
String prefix = field.getPrefix(text.substring(0, offset));
CompletionResultSet activeResult;
if (!result.getPrefixMatcher().getPrefix().equals(prefix)) {
activeResult = result.withPrefixMatcher(prefix);
}
else {
activeResult = result;
}
if (field.isCaseInsensitivity()) {
activeResult = activeResult.caseInsensitive();
}
field.addCompletionVariants(text, offset, prefix, activeResult);
activeResult.stopHere();
}
示例11: addCompletions
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
protected void addCompletions(
@NotNull CompletionParameters completionParameters,
ProcessingContext processingContext,
@NotNull CompletionResultSet completionResultSet) {
PsiElement psiElement = completionParameters.getPosition();
PsiElement origPosition = completionParameters.getOriginalPosition();
if (origPosition == null) {
return;
}
JSRequireElementMatcher elementMatcher = new JSRequireElementMatcher(psiElement, origPosition);
String varName = elementMatcher.getVariableName();
if (varName == null) {
return;
}
PsiFile origFile = completionParameters.getOriginalFile();
Project currentProject = origFile.getProject();
JSRequirePathFinder pathFinder = new JSRequirePathFinder(origFile);
// Find all the corresponding require statement file paths
// given the var name
ArrayList<String> paths = pathFinder.findPathsForVarName(varName);
for (String path : paths) {
if (elementMatcher.isES6Import()) {
completionResultSet.addElement(ES6ImportLookupElemGenerator.generateLookupElement(varName, currentProject, path));
} else {
completionResultSet.addElement(JSRequireLookupElemGenerator.generateLookupElement(origFile.getLanguage(), currentProject, path));
}
}
}
示例12: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
PsiFile file = parameters.getOriginalFile();
Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
if (document != null) {
DataContext dataContext = document.getUserData(CommitMessage.DATA_CONTEXT_KEY);
if (dataContext != null) {
result.stopHere();
if (parameters.getInvocationCount() > 0) {
ChangeList[] lists = VcsDataKeys.CHANGE_LISTS.getData(dataContext);
if (lists != null) {
String prefix = TextFieldWithAutoCompletionListProvider.getCompletionPrefix(parameters);
CompletionResultSet insensitive = result.caseInsensitive().withPrefixMatcher(new CamelHumpMatcher(prefix));
for (ChangeList list : lists) {
for (Change change : list.getChanges()) {
ContentRevision revision = change.getAfterRevision() == null ? change.getBeforeRevision() : change.getAfterRevision();
if (revision != null) {
FilePath filePath = revision.getFile();
LookupElementBuilder element = LookupElementBuilder.create(filePath.getName()).
withIcon(filePath.getFileType().getIcon());
insensitive.addElement(element);
}
}
}
}
}
}
}
}
示例13: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result) {
PsiFile file = parameters.getOriginalFile();
if (!(file instanceof PsiPlainTextFile)) return;
TextFieldCompletionProvider field = file.getUserData(TextFieldCompletionProvider.COMPLETING_TEXT_FIELD_KEY);
if (field == null) return;
if (!(field instanceof DumbAware) && DumbService.isDumb(file.getProject())) return;
String text = file.getText();
int offset = Math.min(text.length(), parameters.getOffset());
String prefix = field.getPrefix(text.substring(0, offset));
CompletionResultSet activeResult;
if (!result.getPrefixMatcher().getPrefix().equals(prefix)) {
activeResult = result.withPrefixMatcher(prefix);
}
else {
activeResult = result;
}
if (field.isCaseInsensitivity()) {
activeResult = activeResult.caseInsensitive();
}
field.addCompletionVariants(text, offset, prefix, activeResult);
}
示例14: addUsedNeabyGlobals
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
private void addUsedNeabyGlobals(CompletionParameters parameters, ProcessingContext context, CompletionResultSet result)
{
if(!LuaApplicationSettings.getInstance().INCLUDE_ALL_FIELDS_IN_COMPLETIONS)
{
return;
}
if(context.get(USED_NEARBY_GLOBALS) != null)
{
return;
}
LuaPsiFile file = (LuaPsiFile) parameters.getOriginalFile();
globalUsageVisitor.reset();
context.put(USED_NEARBY_GLOBALS, globalUsageVisitor.getResult());
file.acceptChildren(globalUsageVisitor);
String prefix = result.getPrefixMatcher().getPrefix();
int prefixLen = prefix.length();
for(String key : globalUsageVisitor.getResult())
{
if(key.length() > prefixLen && key.startsWith(prefix))
{
result.addElement(LuaLookupElement.createNearbyUsageElement(key));
}
}
}
示例15: fillCompletionVariants
import com.intellij.codeInsight.completion.CompletionParameters; //導入方法依賴的package包/類
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet result)
{
final PsiFile file = parameters.getOriginalFile();
if(!(file instanceof LuaPsiFile))
{
return;
}
// final int offset = parameters.getOffset();
// final char c1 = file.getText().charAt(offset-1);
// if (c1 == ':' || c1 == '.') {
//
// final PsiReference e = file.findReferenceAt(offset - 2);
//
// if (e != null) {
// final PsiElement element = e.getElement();
// if (element instanceof LuaCompoundIdentifier) {
// LuaCompoundIdentifier c = (LuaCompoundIdentifier) element;
//
// LuaExpression s = c.getLeftSymbol();
// if (s != null) parameters = parameters.withPosition(s, offset);
// } else {
// if (element instanceof LuaIdentifier) parameters = parameters.withPosition(element, offset);
// }
// }
// }
result.restartCompletionWhenNothingMatches();
super.fillCompletionVariants(parameters, result); //To change body of overridden methods use File | Settings | File Templates.
}