• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ChangeUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addPropertyAfter

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
@NotNull
public PsiElement addPropertyAfter(@NotNull final IProperty property, @Nullable final IProperty anchor) throws IncorrectOperationException {
  final TreeElement copy = ChangeUtil.copyToElement(property.getPsiElement());
  List<IProperty> properties = getProperties();
  ASTNode anchorBefore = anchor == null ? properties.isEmpty() ? null : properties.get(0).getPsiElement().getNode()
                         : anchor.getPsiElement().getNode().getTreeNext();
  if (anchorBefore != null) {
    if (anchorBefore.getElementType() == TokenType.WHITE_SPACE) {
      anchorBefore = anchorBefore.getTreeNext();
    }
  }
  if (anchorBefore == null && haveToAddNewLine()) {
    insertLineBreakBefore(null);
  }
  getPropertiesList().addChild(copy, anchorBefore);
  if (anchorBefore != null) {
    insertLineBreakBefore(anchorBefore);
  }
  return copy.getPsi();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PropertiesFileImpl.java


示例2: addPropertyAfter

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
@NotNull
public PsiElement addPropertyAfter(@NotNull final Property property, @Nullable final Property anchor) throws IncorrectOperationException {
  final TreeElement copy = ChangeUtil.copyToElement(property);
  List<IProperty> properties = getProperties();
  ASTNode anchorBefore = anchor == null ? properties.isEmpty() ? null : properties.get(0).getPsiElement().getNode()
                         : anchor.getNode().getTreeNext();
  if (anchorBefore != null) {
    if (anchorBefore.getElementType() == TokenType.WHITE_SPACE) {
      anchorBefore = anchorBefore.getTreeNext();
    }
  }
  if (anchorBefore == null && haveToAddNewLine()) {
    insertLineBreakBefore(null);
  }
  getPropertiesList().addChild(copy, anchorBefore);
  if (anchorBefore != null) {
    insertLineBreakBefore(anchorBefore);
  }
  return copy.getPsi();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:PropertiesFileImpl.java


示例3: add

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(element);
  calcTreeElement().addInternal(elementCopy, elementCopy, null, null);
  elementCopy = ChangeUtil.decodeInformation(elementCopy);
  return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaStubPsiElement.java


示例4: addBefore

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement addBefore(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(element);
  calcTreeElement().addInternal(elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.TRUE);
  elementCopy = ChangeUtil.decodeInformation(elementCopy);
  return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaStubPsiElement.java


示例5: addAfter

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement addAfter(@NotNull PsiElement element, @Nullable PsiElement anchor) throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(element);
  calcTreeElement().addInternal(elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.FALSE);
  elementCopy = ChangeUtil.decodeInformation(elementCopy);
  return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:JavaStubPsiElement.java


示例6: addInnerBefore

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
private PsiElement addInnerBefore(final PsiElement element, final PsiElement anchor) throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(element);
  ASTNode treeElement = addInternal(elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.TRUE);
  if (treeElement != null) {
    if (treeElement instanceof TreeElement) {
      return ChangeUtil.decodeInformation((TreeElement) treeElement).getPsi();
    }
    return treeElement.getPsi();
  }
  throw new IncorrectOperationException("Element cannot be added");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ASTDelegatePsiElement.java


示例7: addAfter

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement addAfter(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(element);
  ASTNode treeElement = addInternal(elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.FALSE);
  if (treeElement instanceof TreeElement) {
    return ChangeUtil.decodeInformation((TreeElement) treeElement).getPsi();
  }
  return treeElement.getPsi();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ASTDelegatePsiElement.java


示例8: replace

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement replace(@NotNull final PsiElement newElement) throws IncorrectOperationException {
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(newElement);
  if (getParent() instanceof ASTDelegatePsiElement) {
    final ASTDelegatePsiElement parentElement = (ASTDelegatePsiElement)getParent();
    parentElement.replaceChildInternal(this, elementCopy);
  }
  else {
    CodeEditUtil.replaceChild(getParent().getNode(), getNode(), elementCopy);
  }
  elementCopy = ChangeUtil.decodeInformation(elementCopy);
  return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ASTDelegatePsiElement.java


示例9: updateAddedFile

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
private static void updateAddedFile(@NotNull PsiFile copyPsi) throws IncorrectOperationException {
  final UpdateAddedFileProcessor processor = UpdateAddedFileProcessor.forElement(copyPsi);
  if (processor != null) {
    final TreeElement tree = (TreeElement)SourceTreeToPsiMap.psiElementToTree(copyPsi);
    if (tree != null) {
      ChangeUtil.encodeInformation(tree);
    }
    processor.update(copyPsi, null);
    if (tree != null) {
      ChangeUtil.decodeInformation(tree);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:PsiDirectoryImpl.java


示例10: generateTreeFor

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Nullable
@Override
public TreeElement generateTreeFor(PsiElement original, CharTable table, PsiManager manager) {
  TreeElement result = null;
  if (original instanceof SqliteMagicLightMethodBuilder) {
    result = ChangeUtil.copyElement((TreeElement) SourceTreeToPsiMap.psiElementToTree(original), table);
  }
  return result;
}
 
开发者ID:SiimKinks,项目名称:sqlitemagic,代码行数:10,代码来源:SqliteMagicLightMethodGenerator.java


示例11: updateAddedFile

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
private static void updateAddedFile(PsiFile copyPsi) throws IncorrectOperationException {
  final UpdateAddedFileProcessor processor = UpdateAddedFileProcessor.forElement(copyPsi);
  if (processor != null) {
    final TreeElement tree = (TreeElement)SourceTreeToPsiMap.psiElementToTree(copyPsi);
    if (tree != null) {
      ChangeUtil.encodeInformation(tree);
    }
    processor.update(copyPsi, null);
    if (tree != null) {
      ChangeUtil.decodeInformation(tree);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:PsiDirectoryImpl.java


示例12: addProperty

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
@NotNull
public PsiElement addProperty(@NotNull IProperty property) throws IncorrectOperationException {
  if (haveToAddNewLine()) {
    insertLineBreakBefore(null);
  }
  final TreeElement copy = ChangeUtil.copyToElement(property.getPsiElement());
  getPropertiesList().addChild(copy);
  return copy.getPsi();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:PropertiesFileImpl.java


示例13: generateTreeFor

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Nullable
public TreeElement generateTreeFor(PsiElement original, CharTable table, PsiManager manager) {
  TreeElement result = null;
  if (original instanceof LombokLightMethodBuilder) {
    result = ChangeUtil.copyElement((TreeElement) SourceTreeToPsiMap.psiElementToTree(original), table);
  }
  return result;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:9,代码来源:LombokLightMethodTreeGenerator.java


示例14: setName

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement setName(@NotNull final String name) throws IncorrectOperationException
{
	final PomModel model = PomManager.getModel(getProject());
	final XmlAspect aspect = model.getModelAspect(XmlAspect.class);
	model.runTransaction(new PomTransactionBase(this, aspect)
	{
		@Override
		public PomModelEvent runInner() throws IncorrectOperationException
		{
			final String oldName = getName();
			final XmlTagImpl dummyTag = (XmlTagImpl) XmlElementFactory.getInstance(getProject()).createTagFromText(XmlTagUtil.composeTagText(name, "aa"));
			final XmlTagImpl tag = XmlTagImpl.this;
			final CharTable charTableByTree = SharedImplUtil.findCharTableByTree(tag);
			ASTNode child = XmlChildRole.START_TAG_NAME_FINDER.findChild(tag);
			LOG.assertTrue(child != null, "It seems '" + name + "' is not a valid tag name");
			TreeElement tagElement = (TreeElement) XmlChildRole.START_TAG_NAME_FINDER.findChild(dummyTag);
			LOG.assertTrue(tagElement != null, "What's wrong with it? '" + name + "'");
			tag.replaceChild(child, ChangeUtil.copyElement(tagElement, charTableByTree));
			final ASTNode childByRole = XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(tag);
			if(childByRole != null)
			{
				final TreeElement treeElement = (TreeElement) XmlChildRole.CLOSING_TAG_NAME_FINDER.findChild(dummyTag);
				if(treeElement != null)
				{
					tag.replaceChild(childByRole, ChangeUtil.copyElement(treeElement, charTableByTree));
				}
			}

			return XmlTagNameChangedImpl.createXmlTagNameChanged(model, tag, oldName);
		}
	});
	return this;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:35,代码来源:XmlTagImpl.java


示例15: add

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException
{
	CheckUtil.checkWritable(this);
	TreeElement elementCopy = ChangeUtil.copyToElement(element);
	calcTreeElement().addInternal(elementCopy, elementCopy, null, null);
	elementCopy = ChangeUtil.decodeInformation(elementCopy);
	return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:10,代码来源:JavaStubPsiElement.java


示例16: addBefore

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement addBefore(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException
{
	CheckUtil.checkWritable(this);
	TreeElement elementCopy = ChangeUtil.copyToElement(element);
	calcTreeElement().addInternal(elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.TRUE);
	elementCopy = ChangeUtil.decodeInformation(elementCopy);
	return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:10,代码来源:JavaStubPsiElement.java


示例17: addAfter

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public PsiElement addAfter(@NotNull PsiElement element, @Nullable PsiElement anchor) throws IncorrectOperationException
{
	CheckUtil.checkWritable(this);
	TreeElement elementCopy = ChangeUtil.copyToElement(element);
	calcTreeElement().addInternal(elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.FALSE);
	elementCopy = ChangeUtil.decodeInformation(elementCopy);
	return SourceTreeToPsiMap.treeElementToPsi(elementCopy);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:10,代码来源:JavaStubPsiElement.java


示例18: deleteChildInternal

import com.intellij.psi.impl.source.tree.ChangeUtil; //导入依赖的package包/类
@Override
public void deleteChildInternal(@NotNull final ASTNode child)
{
	final PomModel model = PomManager.getModel(getProject());
	final XmlAspect aspect = model.getModelAspect(XmlAspect.class);

	if(child.getElementType() == XmlElementType.XML_ATTRIBUTE)
	{
		try
		{
			model.runTransaction(new PomTransactionBase(this, aspect)
			{
				@Override
				public PomModelEvent runInner()
				{
					final String name = ((XmlAttribute) child).getName();
					XmlTagImpl.super.deleteChildInternal(child);
					return XmlAttributeSetImpl.createXmlAttributeSet(model, XmlTagImpl.this, name, null);
				}
			});
		}
		catch(IncorrectOperationException e)
		{
			LOG.error(e);
		}
	}
	else
	{
		final ASTNode treePrev = child.getTreePrev();
		final ASTNode treeNext = child.getTreeNext();
		super.deleteChildInternal(child);
		if(treePrev != null && treeNext != null && treePrev.getElementType() == XmlElementType.XML_TEXT && treeNext.getElementType() == XmlElementType.XML_TEXT)
		{
			final XmlText prevText = (XmlText) treePrev.getPsi();
			final XmlText nextText = (XmlText) treeNext.getPsi();

			final String newValue = prevText.getValue() + nextText.getValue();

			// merging two XmlText-s should be done in one transaction to preserve smart pointers
			ChangeUtil.prepareAndRunChangeAction(new ChangeUtil.ChangeAction()
			{
				@Override
				public void makeChange(TreeChangeEvent destinationTreeChange)
				{
					PsiElement anchor = prevText.getPrevSibling();
					prevText.delete();
					nextText.delete();
					XmlText text = (XmlText) addAfter(XmlElementFactory.getInstance(getProject()).createDisplayText("x"), anchor);
					text.setValue(newValue);
				}
			}, this);

		}
	}
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:56,代码来源:XmlTagImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Filter类代码示例发布时间:2022-05-22
下一篇:
Java MarkdownProcessor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap