本文整理匯總了Java中org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment.getAssociatedExpression方法的典型用法代碼示例。如果您正苦於以下問題:Java IExpressionFragment.getAssociatedExpression方法的具體用法?Java IExpressionFragment.getAssociatedExpression怎麽用?Java IExpressionFragment.getAssociatedExpression使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment
的用法示例。
在下文中一共展示了IExpressionFragment.getAssociatedExpression方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isLiteralNodeSelected
import org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment; //導入方法依賴的package包/類
private boolean isLiteralNodeSelected() throws JavaModelException {
IExpressionFragment fragment = getSelectedExpression();
if (fragment == null) return false;
Expression expression = fragment.getAssociatedExpression();
if (expression == null) return false;
switch (expression.getNodeType()) {
case ASTNode.BOOLEAN_LITERAL:
case ASTNode.CHARACTER_LITERAL:
case ASTNode.NULL_LITERAL:
case ASTNode.NUMBER_LITERAL:
return true;
default:
return false;
}
}
示例2: isLiteralNodeSelected
import org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment; //導入方法依賴的package包/類
private boolean isLiteralNodeSelected() throws JavaModelException {
IExpressionFragment fragment= getSelectedExpression();
if (fragment == null)
return false;
Expression expression= fragment.getAssociatedExpression();
if (expression == null)
return false;
switch (expression.getNodeType()) {
case ASTNode.BOOLEAN_LITERAL:
case ASTNode.CHARACTER_LITERAL:
case ASTNode.NULL_LITERAL:
case ASTNode.NUMBER_LITERAL:
return true;
default:
return false;
}
}
示例3: isLiteralNodeSelected
import org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment; //導入方法依賴的package包/類
private boolean isLiteralNodeSelected() throws JavaModelException {
IExpressionFragment fragment= getSelectedExpression();
if (fragment == null)
return false;
Expression expression= fragment.getAssociatedExpression();
if (expression == null)
return false;
switch (expression.getNodeType()) {
case ASTNode.BOOLEAN_LITERAL :
case ASTNode.CHARACTER_LITERAL :
case ASTNode.NULL_LITERAL :
case ASTNode.NUMBER_LITERAL :
return true;
default :
return false;
}
}
示例4: checkExpression
import org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment; //導入方法依賴的package包/類
private RefactoringStatus checkExpression() throws JavaModelException {
RefactoringStatus result= new RefactoringStatus();
result.merge(checkExpressionBinding());
if(result.hasFatalError())
return result;
checkAllStaticFinal();
IExpressionFragment selectedExpression= getSelectedExpression();
Expression associatedExpression= selectedExpression.getAssociatedExpression();
if (associatedExpression instanceof NullLiteral)
result.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_null_literals));
else if (!ConstantChecks.isLoadTimeConstant(selectedExpression))
result.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_not_load_time_constant));
else if (associatedExpression instanceof SimpleName) {
if (associatedExpression.getParent() instanceof QualifiedName && associatedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY
|| associatedExpression.getParent() instanceof FieldAccess && associatedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.ExtractConstantRefactoring_select_expression);
}
return result;
}
示例5: checkExpression
import org.eclipse.jdt.internal.corext.dom.fragments.IExpressionFragment; //導入方法依賴的package包/類
private RefactoringStatus checkExpression() throws JavaModelException {
RefactoringStatus result = new RefactoringStatus();
result.merge(checkExpressionBinding());
if (result.hasFatalError()) return result;
checkAllStaticFinal();
IExpressionFragment selectedExpression = getSelectedExpression();
Expression associatedExpression = selectedExpression.getAssociatedExpression();
if (associatedExpression instanceof NullLiteral)
result.merge(
RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractConstantRefactoring_null_literals));
else if (!ConstantChecks.isLoadTimeConstant(selectedExpression))
result.merge(
RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractConstantRefactoring_not_load_time_constant));
else if (associatedExpression instanceof SimpleName) {
if (associatedExpression.getParent() instanceof QualifiedName
&& associatedExpression.getLocationInParent() == QualifiedName.NAME_PROPERTY
|| associatedExpression.getParent() instanceof FieldAccess
&& associatedExpression.getLocationInParent() == FieldAccess.NAME_PROPERTY)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.ExtractConstantRefactoring_select_expression);
}
return result;
}