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


Java PsiFile.getText方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiFile.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiFile.getText方法的具體用法?Java PsiFile.getText怎麽用?Java PsiFile.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiFile的用法示例。


在下文中一共展示了PsiFile.getText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: apply

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
public void apply(@NotNull PsiFile file, Collection<BsbErrorAnnotation> annotationResult, @NotNull AnnotationHolder holder) {
    LineNumbering lineNumbering = new LineNumbering(file.getText());
    for (BsbErrorAnnotation annotation : annotationResult) {
        PsiElement elementAtOffset = null;
        /*
        if (annotation.m_element != null) {
            elementAtOffset = annotation.m_element;
        } else {
            int startOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_startOffset);
            elementAtOffset = findElementAtOffset(file, startOffset);
        }
        */

        if (elementAtOffset != null) {
            holder.createErrorAnnotation(elementAtOffset, annotation.m_message);
            BucklescriptProjectComponent.getInstance(file.getProject()).associatePsiElement(file.getVirtualFile(), elementAtOffset);
        } else {
            int startOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_startOffset);
            int endOffset = lineNumbering.positionToOffset(annotation.m_line, annotation.m_endOffset);
            holder.createErrorAnnotation(new TextRangeInterval(startOffset, endOffset), annotation.m_message);
        }
    }
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:25,代碼來源:BsErrorAnnotator.java

示例2: addCompletions

import com.intellij.psi.PsiFile; //導入方法依賴的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

示例3: apply

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Override
public void apply(@NotNull PsiFile file, List<MerlinError> annotationResult, @NotNull AnnotationHolder holder) {
    LineNumbering lineNumbering = new LineNumbering(file.getText());
    for (MerlinError error : annotationResult) {
        if (error.start != null) {
            int startOffset = lineNumbering.positionToOffset(error.start);
            int endOffset = lineNumbering.positionToOffset(error.end);
            if (0 < startOffset && 0 < endOffset && startOffset < endOffset) {
                holder.createAnnotation(severities.get(error.type), new TextRangeInterval(startOffset, endOffset), "[merlin] " + error.message);
            }
        }
    }
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:14,代碼來源:MerlinErrorAnnotator.java

示例4: format

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@NotNull
@CheckReturnValue
public String format(@Nonnull String text) {
    final String name = Extensions.append(NAME, fileType);
    final PsiFile file = fileFactory.createFileFromText(name, fileType, text);
    final CodeStyleManager styleManager = CodeStyleManager.getInstance(file.getProject());
    styleManager.reformat(file);
    return file.getText();
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:10,代碼來源:Formatter.java

示例5: findExistingSettings

import com.intellij.psi.PsiFile; //導入方法依賴的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

示例6: collectInformation

import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
@Override
public MerlinInfo collectInformation(@NotNull PsiFile file) {
    return new MerlinInfo(file, file.getText());
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:6,代碼來源:MerlinErrorAnnotator.java


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