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


Java CompletionParameters.getOriginalFile方法代碼示例

本文整理匯總了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));
    }
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:21,代碼來源:MerlinCompletionProvider.java

示例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);
        }
    }
}
 
開發者ID:machaval,項目名稱:mule-intellij-plugins,代碼行數:23,代碼來源:RamlCompletionContributor.java

示例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())));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:PostfixTemplatesCompletionProvider.java

示例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));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:MavenPropertyCompletionContributor.java

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

示例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));
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:26,代碼來源:MavenPropertyCompletionContributor.java

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

示例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);
              }
            }
          }
        }
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:CommitCompletionContributor.java

示例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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:32,代碼來源:CompletionContributorForTextField.java

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

示例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);
              }
            }
          }
        }
      }
    }
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:30,代碼來源:CommitCompletionContributor.java

示例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);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:31,代碼來源:CompletionContributorForTextField.java

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

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


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