本文整理汇总了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;
}
示例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;
}
}
示例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()));
}
}
示例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;
}
示例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);
}
示例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;
}
示例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
}
}
}
示例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;
}
}
示例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()));
}
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
}
示例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);
}
示例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;
}
}