public IBlockType getBlockType() { return (IBlockType) _root.getType(); }
@Override public Object evaluate() { return _expr.evaluate(); }
private void removeAnnotationsFromLocationsList( ModifierInfo modifierInfo ) { List<ParseTree> locs = getLocationsList(); for( int i = locs.size()-1; i >= 0; i-- ) { ParseTree csr = locs.get( i ); for( IGosuAnnotation ann: modifierInfo.getAnnotations() ) { if( csr == ann.getExpression().getLocation() ) { locs.remove( i ); } } } }
@Override public IType getType() { if( _expr != null ) { if (_expr.getType() != null) { return _expr.getType(); } else if (_expr instanceof IProgram) { return _expr.getReturnType(); } else { return null; } } return _program.getReturnType(); }
public boolean isConditionLiteralTrue() { return getExpression() instanceof Literal && getExpression().isCompileTimeConstant() && CommonServices.getCoercionManager().makePrimitiveBooleanFrom( getExpression().evaluate() ); }
public boolean isCoveredEnumSwitch() IType switchType = switchExpression.getType(); if( !switchType.isEnum() ) for( ICaseClause caseClause : cases ) if( enumValues != null && caseClause.getExpression().isCompileTimeConstant() ) Object value = caseClause.getExpression().evaluate(); if( value != null )
protected IType getTypeExpected() { IParseTree deepest = getDeepestLocationToComplete(); if( deepest == null || !(deepest.getParsedElement() instanceof IExpression) ) { return null; } IExpression expression = (IExpression)deepest.getParsedElement(); IType typeExpected = expression.getContextType(); if( typeExpected == null ) { if( expression instanceof ILiteralExpression ) { return expression.getType(); } return resolvePossibleContextTypesFromEmptyMethodCalls( expression, getEditor() ); } return typeExpected; }
if( exprAtCaret instanceof ITypeLiteralExpression && exprAtCaret.getParent() instanceof INewExpression ) IParseTree location = exprAtCaret.getLocation(); if( location != null ) else if( exprAtCaret instanceof ITypeLiteralExpression && exprAtCaret.getParent() instanceof IUsesStatement )
void verifyAnnotations( ModifierInfo modInfo, UsageTarget targetType ) { List<IType> annotationTypes = new ArrayList<IType>(); for( IGosuAnnotation annotation : modInfo.getAnnotations() ) { if( annotation instanceof GosuAnnotation ) { IType annotationType = annotation.getType(); if( !(annotationType instanceof ErrorType) ) { UsageModifier modifer = UsageModifier.getUsageModifier( targetType, annotationType ); if( modifer.equals( UsageModifier.None ) ) { annotation.getExpression().addParseException( Res.MSG_ANNOTATION_WHEN_NONE_ALLOWED, annotation.getName(), targetType.toString().toLowerCase() ); } else if( modifer.equals( UsageModifier.One ) && annotationTypes.contains( annotationType ) ) { annotation.getExpression().addParseException( Res.MSG_TOO_MANY_ANNOTATIONS, annotation.getName(), targetType.toString().toLowerCase() ); } annotationTypes.add( annotationType ); } } } }
AssignedState state = null; IExpression switchExpression = ((ISwitchStatement)s).getSwitchExpression(); IType enumType = switchExpression != null && switchExpression.getType().isEnum() ? switchExpression.getType() : null; List<String> enumValues = enumType != null ? ((IEnumType)enumType).getEnumConstants() : null; for( ICaseClause caseClause : ((ISwitchStatement)s).getCases() ) { if( enumValues != null && caseClause.getExpression().isCompileTimeConstant() ) { try { Object value = caseClause.getExpression().evaluate(); if( value != null ) { enumValues.remove( value.toString() );
@Override public IType getType() { if( _expr != null ) { if (_expr.getType() != null) { return _expr.getType(); } else if (_expr instanceof IProgram) { return _expr.getReturnType(); } else { return null; } } return _program.getReturnType(); }
if( exprAtCaret instanceof ITypeLiteralExpression && exprAtCaret.getParent() instanceof INewExpression ) IParseTree location = exprAtCaret.getLocation(); if( location != null ) else if( exprAtCaret instanceof ITypeLiteralExpression && exprAtCaret.getParent() instanceof IUsesStatement )
public boolean isConditionLiteralTrue() { return getExpression() instanceof Literal && getExpression().isCompileTimeConstant() && CommonServices.getCoercionManager().makePrimitiveBooleanFrom( getExpression().evaluate() ); }
if( target != null && !UsageModifier.targetAppliesToParsedElement( pe, target ) ) annotation.getExpression().addParseException( Res.MSG_ANNOTATION_USE_SITE_TARGET_NOT_ALLOWED_HERE, annotation.getName(), target.name() ); annotation.getExpression().addParseException( Res.MSG_ANNOTATION_WHEN_NONE_ALLOWED, annotation.getName(), targetType.toString().toLowerCase() ); annotation.getExpression().addParseException( Res.MSG_TOO_MANY_ANNOTATIONS, annotation.getName(), targetType.toString().toLowerCase() );
public IBlockType getBlockType() { return (IBlockType) _root.getType(); }
public Object getValue() { return _expr.evaluate(); }
AssignedState state = null; IExpression switchExpression = ((ISwitchStatement)s).getSwitchExpression(); IType enumType = switchExpression != null && switchExpression.getType().isEnum() ? switchExpression.getType() : null; List<String> enumValues = enumType != null ? ((IEnumType)enumType).getEnumConstants() : null; for( ICaseClause caseClause : ((ISwitchStatement)s).getCases() ) { if( enumValues != null && caseClause.getExpression().isCompileTimeConstant() ) { try { Object value = caseClause.getExpression().evaluate(); if( value != null ) { enumValues.remove( value.toString() );
private int getArgIndex() { IParsedElement function = _editor.getFunctionCallAtCaret(); if( function == null ) { return -1; } int iCaretPos = _editor.getEditor().getCaretPosition(); List args = function.getLocation().getChildren(); int iNonArgLocations = 0; for( int i = args.size() - 1; i >= 0; i-- ) { IParseTree location = (IParseTree)args.get( i ); if( (function instanceof IBeanMethodCallExpression && ((IBeanMethodCallExpression)function).getRootExpression().getLocation().contains( location )) || (function instanceof INewExpression && !Arrays.stream( ((INewExpression)function).getArgs() ).anyMatch( e -> e.equals( location.getParsedElement() ) )) ) { iNonArgLocations++; } else if( location.getExtent() + 1 >= iCaretPos ) { return (args.size() - 1) - i - iNonArgLocations; } } return Math.max( 0, args.size() - 1 - iNonArgLocations ); }