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


Java CheckUtil类代码示例

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


CheckUtil类属于com.intellij.psi.impl包,在下文中一共展示了CheckUtil类的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: shortenClassReferences

import com.intellij.psi.impl.CheckUtil; //导入依赖的package包/类
@NotNull
@Override
public PsiElement shortenClassReferences(@NotNull PsiElement element, int flags) throws IncorrectOperationException {
  CheckUtil.checkWritable(element);
  if (!SourceTreeToPsiMap.hasTreeElement(element)) return element;

  final boolean addImports = (flags & DO_NOT_ADD_IMPORTS) == 0;
  final boolean incompleteCode = (flags & INCOMPLETE_CODE) != 0;

  final ReferenceAdjuster adjuster = ReferenceAdjuster.Extension.getReferenceAdjuster(element.getLanguage());
  if (adjuster != null) {
    final ASTNode reference = adjuster.process(element.getNode(), addImports, incompleteCode, myProject);
    return SourceTreeToPsiMap.treeToPsiNotNull(reference);
  }
  else {
    return element;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaCodeStyleManagerImpl.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: 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

示例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(), element.getLanguage());
  final PsiElement formatted = SourceTreeToPsiMap.treeElementToPsi(codeFormatter.processRange(treeElement, startOffset, endOffset));

  return canChangeWhiteSpacesOnly ? formatted : postProcessElement(formatted);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CodeStyleManagerImpl.java

示例6: updateText

import com.intellij.psi.impl.CheckUtil; //导入依赖的package包/类
@Override
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:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XmlAttributeValueImpl.java

示例7: 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

示例8: shortenClassReferences

import com.intellij.psi.impl.CheckUtil; //导入依赖的package包/类
@Override
public PsiElement shortenClassReferences(@NotNull PsiElement element, int flags) throws IncorrectOperationException {
  CheckUtil.checkWritable(element);
  if (!SourceTreeToPsiMap.hasTreeElement(element)) return element;

  final boolean addImports = (flags & DO_NOT_ADD_IMPORTS) == 0;
  final boolean incompleteCode = (flags & UNCOMPLETE_CODE) != 0;

  final ReferenceAdjuster adjuster = ReferenceAdjuster.Extension.getReferenceAdjuster(element.getLanguage());
  if (adjuster != null) {
    final ASTNode reference = adjuster.process(element.getNode(), addImports, incompleteCode, myProject);
    return SourceTreeToPsiMap.treeToPsiNotNull(reference);
  }
  else {
    return element;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:JavaCodeStyleManagerImpl.java

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: bindToElement

import com.intellij.psi.impl.CheckUtil; //导入依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException
{
	CheckUtil.checkWritable(this);

	if(isReferenceTo(element) || !isPhysical())
	{
		return this;
	}
	if(element instanceof PsiMethod)
	{
		return handleElementRename(((PsiMethod) element).getName());
	}
	else if(element instanceof PsiClass)
	{
		return this;
	}
	else
	{
		throw new IncorrectOperationException(element.toString());
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:PsiMethodReferenceExpressionImpl.java

示例14: 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

示例15: shortenClassReferences

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

	final boolean addImports = (flags & DO_NOT_ADD_IMPORTS) == 0;
	final boolean incompleteCode = (flags & INCOMPLETE_CODE) != 0;

	final ReferenceAdjuster adjuster = ReferenceAdjuster.Extension.getReferenceAdjuster(element.getLanguage());
	if(adjuster != null)
	{
		final ASTNode reference = adjuster.process(element.getNode(), addImports, incompleteCode, myProject);
		return SourceTreeToPsiMap.treeToPsiNotNull(reference);
	}
	else
	{
		return element;
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:JavaCodeStyleManagerImpl.java


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