本文整理匯總了Java中com.intellij.psi.PsiElement.getTextLength方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiElement.getTextLength方法的具體用法?Java PsiElement.getTextLength怎麽用?Java PsiElement.getTextLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiElement
的用法示例。
在下文中一共展示了PsiElement.getTextLength方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNameIdentifier
import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
/** returns name identifier, which is valid for reporting */
@Nullable
static public PsiElement getNameIdentifier(@Nullable PsiNameIdentifierOwner element) {
if (null != element) {
PsiElement id = element.getNameIdentifier();
boolean isIdReportable = null != id && id.getTextLength() > 0;
return isIdReportable ? id : null;
}
return null;
}
示例2: isJavaElementFor
import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
private static boolean isJavaElementFor( PsiModifierListOwner modifierListOwner, PsiElement element )
{
PsiAnnotation annotation = modifierListOwner.getModifierList().findAnnotation( SourcePosition.class.getName() );
if( annotation != null )
{
int textOffset = element.getTextOffset();
int textLength = element instanceof PsiNamedElement ? ((PsiNamedElement)element).getName().length() : element.getTextLength();
PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
int offset = -1;
for( PsiNameValuePair pair : attributes )
{
if( pair.getNameIdentifier().getText().equals( SourcePosition.OFFSET ) )
{
String literalValue = pair.getLiteralValue();
if( literalValue == null )
{
return false;
}
offset = Integer.parseInt( literalValue );
break;
}
}
if( offset >= textOffset && offset <= textOffset + textLength )
{
return true;
}
}
return false;
}
示例3: annotate
import com.intellij.psi.PsiElement; //導入方法依賴的package包/類
@Override
public void annotate( PsiElement element, AnnotationHolder holder )
{
PsiClass psiClass = ResourceToManifoldUtil.findPsiClass( element.getContainingFile() );
if( psiClass == null )
{
return;
}
if( PsiErrorClassUtil.isErrorClass( psiClass ) && element instanceof PsiFileSystemItem )
{
holder.createErrorAnnotation( new TextRange( 0, element.getContainingFile().getTextLength() ), PsiErrorClassUtil.getErrorFrom( psiClass ).getMessage() );
return;
}
if( !(psiClass instanceof ManifoldPsiClass) )
{
return;
}
DiagnosticCollector issues = ((ManifoldPsiClass)psiClass).getIssues();
if( issues == null )
{
return;
}
for( Object obj : issues.getDiagnostics() )
{
Diagnostic issue = (Diagnostic)obj;
if( element.getTextOffset() > issue.getStartPosition() ||
element.getTextOffset() + element.getTextLength() <= issue.getStartPosition() )
{
continue;
}
PsiElement deepestElement = element.getContainingFile().findElementAt( (int)issue.getStartPosition() );
if( deepestElement != element )
{
continue;
}
switch( issue.getKind() )
{
case ERROR:
holder.createErrorAnnotation( deepestElement, issue.getMessage( Locale.getDefault() ) );
break;
case WARNING:
case MANDATORY_WARNING:
holder.createWarningAnnotation( deepestElement, issue.getMessage( Locale.getDefault() ) );
break;
case NOTE:
case OTHER:
holder.createInfoAnnotation( deepestElement, issue.getMessage( Locale.getDefault() ) );
break;
}
}
}