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


Java CheckUtil.checkWritable方法代码示例

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


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

示例1: replace

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
public PsiElement replace( PsiElement newElement ) throws IncorrectOperationException
{
  // just add new element to the containing class
  final PsiClass containingClass = getContainingClass();
  if( null != containingClass )
  {
    CheckUtil.checkWritable( containingClass );
    return containingClass.add( newElement );
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:13,代码来源:ManLightMethodImpl.java

示例2: reformat

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
@NotNull
public PsiElement reformat(@NotNull PsiElement element, boolean canChangeWhiteSpacesOnly) throws IncorrectOperationException {
  CheckUtil.checkWritable(element);
  if( !SourceTreeToPsiMap.hasTreeElement( element ) )
  {
    return element;
  }

  ASTNode treeElement = SourceTreeToPsiMap.psiElementToTree(element);
  final PsiElement formatted = SourceTreeToPsiMap.treeElementToPsi(new CodeFormatterFacade(getSettings(), element.getLanguage()).processElement(treeElement));
  if (!canChangeWhiteSpacesOnly) {
    return postProcessElement(formatted);
  }
  return formatted;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CodeStyleManagerImpl.java

示例3: delete

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
public void delete() throws IncorrectOperationException {
  PsiElement parent = getParent();
  if (parent instanceof ASTDelegatePsiElement) {
    CheckUtil.checkWritable(this);
    ((ASTDelegatePsiElement)parent).deleteChildInternal(getNode());
  }
  else if (parent instanceof CompositeElement) {
    CheckUtil.checkWritable(this);
    ((CompositeElement)parent).deleteChildInternal(getNode());
  }
  else if (parent instanceof PsiFile) {
    CheckUtil.checkWritable(this);
    parent.deleteChildRange(this, this);
  }
  else {
    throw new UnsupportedOperationException(getClass().getName() + " under " + (parent == null ? "null" : parent.getClass().getName()));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ASTDelegatePsiElement.java

示例4: formatInternal

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
private void formatInternal(Formatter formatter, PsiFile file, List<Range<Integer>> ranges)
    throws IncorrectOperationException {
  ApplicationManager.getApplication().assertWriteAccessAllowed();
  PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
  CheckUtil.checkWritable(file);

  Document document = PsiDocumentManager.getInstance(getProject()).getDocument(file);
  if (document != null) {
    try {
      List<Replacement> replacements =
          formatter
              .getFormatReplacements(document.getText(), ranges)
              .stream()
              .sorted(
                  comparing((Replacement r) -> r.getReplaceRange().lowerEndpoint()).reversed())
              .collect(Collectors.toList());
      performReplacements(document, replacements);
    } catch (FormatterException e) {
      // Do not format on errors
    }
  }
}
 
开发者ID:google,项目名称:google-java-format,代码行数:23,代码来源:GoogleJavaFormatCodeStyleManager.java

示例5: reformatRangeImpl

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
private PsiElement reformatRangeImpl(final PsiElement element,
                                     final int startOffset,
                                     final int endOffset,
                                     boolean canChangeWhiteSpacesOnly) throws IncorrectOperationException {
  LOG.assertTrue(element.isValid());
  CheckUtil.checkWritable(element);
  if( !SourceTreeToPsiMap.hasTreeElement( element ) )
  {
    return element;
  }

  ASTNode treeElement = SourceTreeToPsiMap.psiElementToTree(element);
  final CodeFormatterFacade codeFormatter = new CodeFormatterFacade(getSettings());
  final PsiElement formatted = SourceTreeToPsiMap.treeElementToPsi(codeFormatter.processRange(treeElement, startOffset, endOffset));

  return canChangeWhiteSpacesOnly ? formatted : postProcessElement(formatted);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:CodeStyleManagerImpl.java

示例6: updateText

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
public PsiLanguageInjectionHost updateText(@NotNull String text) {
  try {
    final String quoteChar = getTextLength() > 0 ? getText().substring(0, 1) : "";
    String contents = StringUtil.containsAnyChar(quoteChar, "'\"") ?
            StringUtil.trimEnd(StringUtil.trimStart(text, quoteChar), quoteChar) : text;
    XmlAttribute newAttribute = XmlElementFactory.getInstance(getProject()).createXmlAttribute("q", contents);
    XmlAttributeValue newValue = newAttribute.getValueElement();

    CheckUtil.checkWritable(this);
    replaceAllChildrenToChildrenOf(newValue.getNode());
  }
  catch (IncorrectOperationException e) {
    LOG.error(e);
  }
  return this;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:XmlAttributeValueImpl.java

示例7: reformat

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
@NotNull
public PsiElement reformat(@NotNull PsiElement element, boolean canChangeWhiteSpacesOnly) throws IncorrectOperationException {
  CheckUtil.checkWritable(element);
  if( !SourceTreeToPsiMap.hasTreeElement( element ) )
  {
    return element;
  }

  ASTNode treeElement = SourceTreeToPsiMap.psiElementToTree(element);
  final PsiElement formatted = SourceTreeToPsiMap.treeElementToPsi(new CodeFormatterFacade(getSettings()).processElement(treeElement));
  if (!canChangeWhiteSpacesOnly) {
    return postProcessElement(formatted);
  }
  return formatted;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:CodeStyleManagerImpl.java

示例8: delete

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
public void delete() throws IncorrectOperationException {
  PsiElement parent = getParent();
  if (parent instanceof ASTDelegatePsiElement) {
    CheckUtil.checkWritable(this);
    ((ASTDelegatePsiElement)parent).deleteChildInternal(getNode());
  }
  else if (parent instanceof CompositePsiElement) {
    CheckUtil.checkWritable(this);
    ((CompositePsiElement)parent).deleteChildInternal(getNode());
  }
  else if (parent instanceof PsiFile) {
    CheckUtil.checkWritable(this);
    parent.deleteChildRange(this, this);
  }
  else {
    throw new UnsupportedOperationException(getClass().getName() + " under " + (parent == null ? "null" : parent.getClass().getName()));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ASTDelegatePsiElement.java

示例9: delete

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
public static void delete(@NotNull FrogAttribute attribute) throws IncorrectOperationException {
    // see ASTDelegatePsiElement.delete
    PsiElement parent = attribute.getParent();
    if (parent instanceof ASTDelegatePsiElement) {
        CheckUtil.checkWritable(attribute);

        ASTNode node = attribute.getNode();
        ASTNode nextNode = node.getTreeNext();
        ((ASTDelegatePsiElement) parent).deleteChildInternal(node);
        if (nextNode != null && nextNode.getElementType() == FrogTypes.FROG_SEMICOLON) {
            parent.getNode().removeChild(nextNode);
        }
    } else {
        throw new UnsupportedOperationException(attribute.getClass().getName() + " under " + (parent == null ? "null" : parent.getClass().getName()));
    }
}
 
开发者ID:Ladicek,项目名称:IntelliFrog,代码行数:17,代码来源:FrogPsiImplUtil.java

示例10: deleteChildRange

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
public void deleteChildRange(PsiElement first, PsiElement last) throws IncorrectOperationException
{
	CheckUtil.checkWritable(this);
	if(first == null)
	{
		LOG.assertTrue(last == null);
		return;
	}
	ASTNode firstElement = SourceTreeToPsiMap.psiElementToTree(first);
	ASTNode lastElement = SourceTreeToPsiMap.psiElementToTree(last);
	CompositeElement treeElement = calcTreeElement();
	LOG.assertTrue(firstElement.getTreeParent() == treeElement);
	LOG.assertTrue(lastElement.getTreeParent() == treeElement);
	CodeEditUtil.removeChildren(treeElement, firstElement, lastElement);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:JavaStubPsiElement.java

示例11: replace

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException {
  LOG.assertTrue(getTreeParent() != null);
  CheckUtil.checkWritable(this);
  TreeElement elementCopy = ChangeUtil.copyToElement(newElement);
  getTreeParent().replaceChildInternal(this, elementCopy);
  elementCopy = ChangeUtil.decodeInformation(elementCopy);
  final PsiElement result = SourceTreeToPsiMap.treeElementToPsi(elementCopy);

  this.invalidate();
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:OwnBufferLeafPsiElement.java

示例12: addBefore

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的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

示例13: addAfter

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的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

示例14: checkCreateSubdirectory

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
@Override
public void checkCreateSubdirectory(@NotNull String name) throws IncorrectOperationException {
  // TODO : another check?
  //CheckUtil.checkIsIdentifier(name);
  VirtualFile existingFile = getVirtualFile().findChild(name);
  if (existingFile != null) {
    throw new IncorrectOperationException(VfsBundle.message("file.already.exists.error", existingFile.getPresentableUrl()));
  }
  CheckUtil.checkWritable(this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PsiDirectoryImpl.java

示例15: doReplace

import com.intellij.psi.impl.CheckUtil; //导入方法依赖的package包/类
public static PsiElement doReplace(PsiElement psiElement, TreeElement treeElement, PsiElement newElement) {
  CompositeElement treeParent = treeElement.getTreeParent();
  LOG.assertTrue(treeParent != null);
  CheckUtil.checkWritable(psiElement);
  TreeElement elementCopy = ChangeUtil.copyToElement(newElement);
  treeParent.replaceChildInternal(treeElement, elementCopy);
  elementCopy = ChangeUtil.decodeInformation(elementCopy);
  final PsiElement result = SourceTreeToPsiMap.treeElementToPsi(elementCopy);
  treeElement.invalidate();
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SharedImplUtil.java


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