本文整理汇总了Java中com.intellij.psi.PsiParserFacade类的典型用法代码示例。如果您正苦于以下问题:Java PsiParserFacade类的具体用法?Java PsiParserFacade怎么用?Java PsiParserFacade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiParserFacade类属于com.intellij.psi包,在下文中一共展示了PsiParserFacade类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerPageLanguage
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
public void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) {
new WriteCommandAction.Simple(project, getFamilyName()) {
@Override
protected void run() {
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", StdFileTypes.XML,
"<?language " + languageName + "?>");
final XmlDocument document = dummyFile.getDocument();
if (document != null) {
final XmlProlog prolog = document.getProlog();
final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
LOG.assertTrue(instructions.size() == 1);
final XmlDocument xmlDocument = containingFile.getDocument();
if (xmlDocument != null) {
final XmlProlog xmlProlog = xmlDocument.getProlog();
if (xmlProlog != null) {
final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild());
xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element);
}
}
}
}
}.execute();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JavaFxInjectPageLanguageIntention.java
示例2: modify
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
protected void modify(@NonNls @NotNull String qualifiedName) {
final PsiClass psiClass = findClassAndAssert(qualifiedName);
final PsiFile psiFile = psiClass.getContainingFile();
final PsiParserFacade parserFacade = PsiParserFacade.SERVICE.getInstance(myProject);
final PsiComment comment = parserFacade.createBlockCommentFromText(psiFile.getLanguage(), "Foo");
WriteCommandAction.runWriteCommandAction(
myProject,
new Runnable() {
@Override
public void run() {
psiFile.add(comment);
}
}
);
FileDocumentManager manager = FileDocumentManager.getInstance();
manager.saveAllDocuments();
}
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:18,代码来源:PantsIntegrationTestCase.java
示例3: registerPageLanguage
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
private void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) {
new WriteCommandAction.Simple(project, getFamilyName()) {
@Override
protected void run() {
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", StdFileTypes.XML,
"<?language " + languageName + "?>");
final XmlDocument document = dummyFile.getDocument();
if (document != null) {
final XmlProlog prolog = document.getProlog();
final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
LOG.assertTrue(instructions.size() == 1);
final XmlDocument xmlDocument = containingFile.getDocument();
if (xmlDocument != null) {
final XmlProlog xmlProlog = xmlDocument.getProlog();
if (xmlProlog != null) {
final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild());
xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element);
}
}
}
}
}.execute();
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:JavaFxInjectPageLanguageIntention.java
示例4: registerPageLanguage
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
private void registerPageLanguage(final Project project, final XmlFile containingFile, final String languageName) {
new WriteCommandAction.Simple(project, getFamilyName()) {
@Override
protected void run() {
final PsiFileFactory factory = PsiFileFactory.getInstance(project);
final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", XmlFileType.INSTANCE,
"<?language " + languageName + "?>");
final XmlDocument document = dummyFile.getDocument();
if (document != null) {
final XmlProlog prolog = document.getProlog();
final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class);
LOG.assertTrue(instructions.size() == 1);
final XmlDocument xmlDocument = containingFile.getDocument();
if (xmlDocument != null) {
final XmlProlog xmlProlog = xmlDocument.getProlog();
if (xmlProlog != null) {
final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild());
xmlProlog.addAfter(PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n"), element);
}
}
}
}
}.execute();
}
开发者ID:consulo,项目名称:consulo-javafx,代码行数:25,代码来源:JavaFxInjectPageLanguageIntention.java
示例5: insertWhitespaceIfNeeded
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
private static ASTNode insertWhitespaceIfNeeded(ASTNode anchorNode, final ASTNode elementNode, final ASTNode parentNode,
final ASTNode insertionPlaceNode) throws IncorrectOperationException
{
ParserDefinition parserDef = LanguageParserDefinitions.INSTANCE.forLanguage(parentNode.getPsi().getLanguage());
final TokenSet comments = parserDef.getCommentTokens(parentNode.getPsi().getLanguage().getVersions()[0]);
final TokenSet whitespaces = parserDef.getWhitespaceTokens(parentNode.getPsi().getLanguage().getVersions()[0]);
if(anchorNode != null && ((!whitespaces.contains(anchorNode.getElementType()) && !whitespaces.contains(elementNode.getElementType())) ||
comments.contains(anchorNode.getElementType()) ||
comments.contains(elementNode.getElementType()) ||
elementNode.getPsi() instanceof PsiComment))
{
String commentString = " ";
if(comments.contains(anchorNode.getElementType()) ||
comments.contains(elementNode.getElementType()) ||
elementNode.getPsi() instanceof PsiComment)
{
commentString = "\n";
}
final ASTNode wsNode = PsiParserFacade.SERVICE.getInstance(parentNode.getPsi().getProject()).createWhiteSpaceFromText(commentString).getNode();
parentNode.addChild(wsNode, insertionPlaceNode);
anchorNode = wsNode;
}
return anchorNode;
}
开发者ID:consulo,项目名称:consulo-javascript,代码行数:27,代码来源:JSChangeUtil.java
示例6: createComment
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
@NotNull
public static PsiComment createComment(@NotNull Project project,
@NotNull String commentText,
@NotNull Language language) {
final PsiParserFacade parserFacade = PsiParserFacade.SERVICE.getInstance(project);
return parserFacade.createLineOrBlockCommentFromText(language, commentText);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:SuppressionUtil.java
示例7: addModifier
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
@RequiredReadAction
public static void addModifier(@NotNull CSharpModifierList modifierList, @NotNull DotNetModifier modifier)
{
PsiElement anchor = modifierList.getLastChild();
CSharpFieldDeclaration field = CSharpFileFactory.createField(modifierList.getProject(), modifier.getPresentableText() + " int b");
PsiElement modifierElement = field.getModifierList().getModifierElement(modifier);
PsiElement psiElement = modifierList.addAfter(modifierElement, anchor);
modifierList.addAfter(PsiParserFacade.SERVICE.getInstance(modifierList.getProject()).createWhiteSpaceFromText(" "), psiElement);
}
开发者ID:consulo,项目名称:consulo-csharp,代码行数:12,代码来源:CSharpModifierListImplUtil.java
示例8: invoke
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
@Override
public void invoke(@NotNull final Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
ApplicationManager.getApplication().invokeLater(
new Runnable() {
@Override
public void run() {
if (classModel.getBodyPsi() == null) return;
final StringBuilder builder = new StringBuilder();
GetterSetterMethodBuilder.build(builder, field, generateGetter);
new WriteCommandAction.Simple(project) {
@Override
public void run() {
List<HaxeNamedComponent> elements =
HaxeElementGenerator.createNamedSubComponentsFromText(project, builder.toString());
PsiElement body = classModel.getBodyPsi();
PsiElement anchor = body.getLastChild();
for (PsiElement element : elements) {
PsiElement newLine = createNewLine();
anchor = body.addAfter(element, anchor);
anchor = body.addBefore(newLine, anchor);
}
}
private PsiElement createNewLine() {
return PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n\n");
}
}.execute();
}
}
);
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:36,代码来源:CreateGetterSetterQuickfix.java
示例9: doInsert
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
public void doInsert(
@NotNull PsiFile buildFile,
@NotNull final String targetName,
@NotNull PantsTargetAddress addressToAdd
) throws IncorrectOperationException {
final PyCallExpression targetDefinitionExpression = PantsPsiUtil.findTargets(buildFile).get(targetName);
if (targetDefinitionExpression == null) {
return;
}
final Project project = buildFile.getProject();
final PyElementGenerator generator = PyElementGenerator.getInstance(project);
final String targetAddressStringToAdd = addressToAdd.toString();
final PyExpression dependenciesArgument = targetDefinitionExpression.getKeywordArgument("dependencies");
if (dependenciesArgument == null) {
final PyKeywordArgument keywordArgument =
generator.createKeywordArgument(LanguageLevel.forElement(buildFile), "dependencies", "['"+ targetAddressStringToAdd + "']");
targetDefinitionExpression.addArgument(keywordArgument);
} else if (dependenciesArgument instanceof PyListLiteralExpression) {
PyExpression position = null;
// we assume all elements are sorted.
for (PyExpression expression : ((PyListLiteralExpression)dependenciesArgument).getElements()) {
if (expression instanceof PyStringLiteralExpression &&
targetAddressStringToAdd.compareTo(((PyStringLiteralExpression)expression).getStringValue()) < 0) {
// found a position to insert
break;
}
position = expression;
}
final PyStringLiteralExpression literalToAdd = generator.createStringLiteralAlreadyEscaped("'" + targetAddressStringToAdd + "'");
if (position != null) {
final PsiElement newLine = PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n");
final PsiElement addedLiteral = dependenciesArgument.addAfter(literalToAdd, position);
dependenciesArgument.getNode().addChild(newLine.getNode(), addedLiteral.getNode());
} else {
dependenciesArgument.add(literalToAdd);
}
CodeStyleManager.getInstance(project).reformat(dependenciesArgument);
}
FileDocumentManager.getInstance().saveAllDocuments(); // dump VFS to FS before refreshing
PantsUtil.refreshAllProjects(project);
}
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:44,代码来源:AddPantsTargetDependencyFix.java
示例10: modifyDeclaration
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
protected PsiElement modifyDeclaration(@NotNull PsiElement declaration)
{
PsiElement parent = declaration.getParent();
parent.addAfter(PsiParserFacade.SERVICE.getInstance(declaration.getProject()).createWhiteSpaceFromText("\n"), declaration);
return declaration;
}
开发者ID:consulo,项目名称:consulo-csharp,代码行数:7,代码来源:CSharpIntroduceHandler.java
示例11: addStatements
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
protected static void addStatements(HaxeBlockStatement block, PsiElement[] elements) throws IncorrectOperationException {
block.addRangeAfter(elements[0], elements[elements.length - 1], block.getFirstChild());
final PsiElement newLineNode =
PsiParserFacade.SERVICE.getInstance(block.getProject()).createWhiteSpaceFromText("\n");
block.addAfter(newLineNode, block.getFirstChild());
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:7,代码来源:HaxeManyStatementsSurrounder.java
示例12: afterAddHandler
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
protected PsiElement afterAddHandler(PsiElement element, PsiElement anchor) {
final PsiElement newLineNode =
PsiParserFacade.SERVICE.getInstance(element.getProject()).createWhiteSpaceFromText("\n\n");
anchor.getParent().addBefore(newLineNode, anchor);
return anchor;
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:7,代码来源:BaseCreateMethodsFix.java
示例13: createComment
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
@Nonnull
public static PsiComment createComment(@Nonnull Project project, @Nonnull String commentText, @Nonnull Language language) {
final PsiParserFacade parserFacade = PsiParserFacade.SERVICE.getInstance(project);
return parserFacade.createLineOrBlockCommentFromText(language, commentText);
}
开发者ID:consulo,项目名称:consulo,代码行数:6,代码来源:SuppressionUtil.java
示例14: addUsingStatementAfter
import com.intellij.psi.PsiParserFacade; //导入依赖的package包/类
@RequiredReadAction
private static void addUsingStatementAfter(@NotNull PsiElement afterElement, @NotNull CSharpUsingNamespaceStatement newStatement)
{
Project project = afterElement.getProject();
PsiElement parent = afterElement.getParent();
PsiElement whiteSpaceFromText = PsiParserFacade.SERVICE.getInstance(project).createWhiteSpaceFromText("\n");
parent.addAfter(whiteSpaceFromText, afterElement);
parent.addAfter(newStatement, afterElement.getNode().getTreeNext().getPsi());
}
开发者ID:consulo,项目名称:consulo-csharp,代码行数:14,代码来源:AddUsingAction.java
注:本文中的com.intellij.psi.PsiParserFacade类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论