当前位置: 首页>>代码示例>>Java>>正文


Java PsiFileFactoryImpl类代码示例

本文整理汇总了Java中com.intellij.psi.impl.PsiFileFactoryImpl的典型用法代码示例。如果您正苦于以下问题:Java PsiFileFactoryImpl类的具体用法?Java PsiFileFactoryImpl怎么用?Java PsiFileFactoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiFileFactoryImpl类属于com.intellij.psi.impl包,在下文中一共展示了PsiFileFactoryImpl类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleContentChange

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
@Override
public FileReferenceNode handleContentChange(@NotNull FileReferenceNode fileReferenceNode,
        @NotNull TextRange range, String newContent) throws IncorrectOperationException {
    String oldText = fileReferenceNode.getText();
    String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText
            .substring(range.getEndOffset());
    Project project = fileReferenceNode.getProject();
    PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
    IElementType type = ProtoParserDefinition.rule(ProtoParser.RULE_fileReference);
    ScopeNode context = fileReferenceNode.getContext();
    PsiElement newNode = factory
            .createElementFromText(newText, ProtoLanguage.INSTANCE, type, context);
    if (newNode == null) {
        throw new IncorrectOperationException();
    }
    return (FileReferenceNode) fileReferenceNode.replace(newNode);
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:18,代码来源:FileReferenceNodeManipulator.java

示例2: handleContentChange

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
@Override
public FieldReferenceNode handleContentChange(@NotNull FieldReferenceNode node,
        @NotNull TextRange range, String newContent) throws IncorrectOperationException {
    String oldText = node.getText();
    String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText
            .substring(range.getEndOffset());
    Project project = node.getProject();
    PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
    IElementType type = ProtoParserDefinition.rule(ProtoParser.RULE_fieldRerefence);
    ScopeNode context = node.getContext();
    PsiElement newNode = factory
            .createElementFromText(newText, ProtoLanguage.INSTANCE, type, context);
    if (newNode == null) {
        throw new IncorrectOperationException();
    }
    return (FieldReferenceNode) node.replace(newNode);
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:18,代码来源:FieldReferenceNodeManipulator.java

示例3: handleContentChange

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
@Override
public TypeReferenceNode handleContentChange(@NotNull TypeReferenceNode node,
        @NotNull TextRange range, String newContent) throws IncorrectOperationException {
    String oldText = node.getText();
    String newText = oldText.substring(0, range.getStartOffset()) + newContent + oldText
            .substring(range.getEndOffset());
    Project project = node.getProject();
    PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
    IElementType type = ProtoParserDefinition.rule(ProtoParser.RULE_typeReference);
    ScopeNode context = node.getContext();
    PsiElement newNode = factory
            .createElementFromText(newText, ProtoLanguage.INSTANCE, type, context);
    if (newNode == null) {
        throw new IncorrectOperationException();
    }
    return (TypeReferenceNode) node.replace(newNode);
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:18,代码来源:TypeReferenceNodeManipulator.java

示例4: setName

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
/**
 * Set name.
 */
public PsiElement setName(@NotNull String name) throws IncorrectOperationException {
    ASTNode node = getNode();
    IElementType elementType = node.getElementType();
    if (elementType instanceof RuleIElementType) {
        RuleIElementType ruleElementType = (RuleIElementType) elementType;
        int ruleIndex = ruleElementType.getRuleIndex();
        Project project = getProject();
        PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
        IElementType type = ProtoParserDefinition.rule(ruleIndex);
        ScopeNode context = getContext();
        PsiElement newNode = factory.createElementFromText(name, ProtoLanguage.INSTANCE, type, context);
        if (newNode == null) {
            throw new IncorrectOperationException();
        }
        return replace(newNode);
    }
    throw new IncorrectOperationException(OPERATION_NOT_SUPPORTED);
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:22,代码来源:GenericNameNode.java

示例5: format

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
public static String format(final Project project, Language language, String text) {
    final PsiFile psiFile = PsiFileFactoryImpl.getInstance(project).createFileFromText("virtual", language, text);

    new WriteCommandAction.Simple<String>(project, psiFile) {
        @Override
        protected void run() throws Throwable {
            CodeStyleManager.getInstance(project).reformat(psiFile, false);
        }
    }.execute();

    String formatted = psiFile.getText();

    new WriteCommandAction.Simple<String>(project, psiFile) {
        @Override
        protected void run() throws Throwable {
            psiFile.delete();
        }
    }.execute();

    if (formatted == null) {
        return text;
    }
    return formatted;
}
 
开发者ID:itechbear,项目名称:CLion-MacroFormatter,代码行数:25,代码来源:CLionFormatter.java

示例6: createLeafFromText

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
public static PsiElement createLeafFromText(Project project, Language language, PsiElement context,
											String text, IElementType type)
{
	PsiFileFactoryImpl factory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
	PsiElement el = factory.createElementFromText(text, language, type, context);
	if ( el==null ) return null;
	return PsiTreeUtil.getDeepestFirst(el); // forces parsing of file!!
	// start rule depends on root passed in
}
 
开发者ID:antlr,项目名称:jetbrains,代码行数:10,代码来源:Trees.java

示例7: createFile

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
public static PsiFile createFile(Project project, Language language, String text) {
	LanguageFileType ftype = language.getAssociatedFileType();
	if ( ftype==null ) return null;
	String ext = ftype.getDefaultExtension();
	String fileName = "___fubar___."+ext; // random name but must have correct extension
	PsiFileFactoryImpl factory = (PsiFileFactoryImpl)PsiFileFactory.getInstance(project);
	return factory.createFileFromText(fileName, language, text, false, false);
}
 
开发者ID:antlr,项目名称:jetbrains,代码行数:9,代码来源:Trees.java

示例8: createLeafFromText

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
public static PsiElement createLeafFromText(Project project, PsiElement context,
											String text, IElementType type)
{
	PsiFileFactoryImpl factory = (PsiFileFactoryImpl)PsiFileFactory.getInstance(project);
	PsiElement el = factory.createElementFromText(text,
												  ANTLRv4Language.INSTANCE,
												  type,
												  context);
	return PsiTreeUtil.getDeepestFirst(el); // forces parsing of file!!
	// start rule depends on root passed in
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:12,代码来源:MyPsiUtils.java

示例9: createFile

import com.intellij.psi.impl.PsiFileFactoryImpl; //导入依赖的package包/类
public static PsiFile createFile(Project project, String text) {
	String fileName = "a.g4"; // random name but must be .g4
	PsiFileFactoryImpl factory = (PsiFileFactoryImpl)PsiFileFactory.getInstance(project);
	return factory.createFileFromText(fileName, ANTLRv4Language.INSTANCE,
									  text, false, false);
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:7,代码来源:MyPsiUtils.java


注:本文中的com.intellij.psi.impl.PsiFileFactoryImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。