本文整理匯總了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);
}
}
}
示例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));
}
}
示例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);
}
}
}
}
示例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();
}
示例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();
}
}
示例6: collectInformation
import com.intellij.psi.PsiFile; //導入方法依賴的package包/類
@Nullable
@Override
public MerlinInfo collectInformation(@NotNull PsiFile file) {
return new MerlinInfo(file, file.getText());
}