private void maybeHandleFunction( IGosuProgram program ) { if( program.getMemberFunctions() != null ) { for( IDynamicFunctionSymbol function : program.getMemberFunctions() ) { if( function.getArgTypes().length != 1 || !JavaTypes.IEXTERNAL_SYMBOL_MAP().equals( function.getArgs().get( 0 ) ) || (!function.getDisplayName().equals( "evaluate" ) && !function.getDisplayName().equals( "evaluateRootExpr" )) ) { _interactiveSymbolTable.putSymbol( function ); } } } }
public static List<IGenericTypeVariable> getTypeVarsForDFS( IDynamicFunctionSymbol dfs ) { ArrayList<IGenericTypeVariable> typeVars = new ArrayList<IGenericTypeVariable>(); if( !dfs.isStatic() && isEnhancementType( dfs.getGosuClass() ) ) { typeVars.addAll( Arrays.asList( getTypeVarsForEnhancement( dfs ) ) ); } if( dfs.getType().isGenericType() ) { typeVars.addAll( Arrays.asList( dfs.getType().getGenericTypeVariables() ) ); } else if( dfs.isConstructor() ) { IType declaringType = TypeLord.getPureGenericType( dfs.getDeclaringTypeInfo().getOwnersType() ); if( declaringType.isGenericType() ) { typeVars.addAll( Arrays.asList( declaringType.getGenericTypeVariables() ) ); } } return typeVars; }
@Override public IConstructorStatement getConstructorStatement( IConstructorInfo ctor ) { for( IDynamicFunctionSymbol dfs : getConstructorFunctions() ) { if( dfs.getMethodOrConstructorInfo( true ) == ctor ) { return (IConstructorStatement)dfs.getDeclFunctionStmt(); } } return null; }
public IFunctionStatement getFunctionStatement(IMethodInfo method) { for (IDynamicFunctionSymbol dfs : getMemberFunctions()) { if (method.getName().equals(dfs.getName()) && equalArgs(method.getParameters(), dfs.getArgs())) { return dfs.getDeclFunctionStmt(); } } for (IDynamicFunctionSymbol dfs : getStaticFunctions()) { if (method.getName().equals(dfs.getName()) && equalArgs(method.getParameters(), dfs.getArgs())) { return dfs.getDeclFunctionStmt(); } } return null; }
IType containingType = dynamicFunctionSymbol.getScriptPart().getContainingType(); featureInfo = containingType.getTypeInfo().getMethod( dynamicFunctionSymbol.getDisplayName(), dynamicFunctionSymbol.getArgTypes() ); if( symbol != null ) featureInfo = symbol.getMethodOrConstructorInfo();
private List<IReducedSymbol> makeArgs(IDynamicFunctionSymbol dfs) { List<ISymbol> args = dfs.getArgs(); List<IReducedSymbol> newArgs = new ArrayList<IReducedSymbol>(args.size()); for (ISymbol arg : args) { newArgs.add( arg.createReducedSymbol() ); } return newArgs; }
private static String resolveCorrectGetterMethodPrefixForBooleanDFS( IDynamicFunctionSymbol dfs ) while( dfs.getBackingDfs() != null && dfs.getBackingDfs() != dfs ) dfs = dfs.getBackingDfs(); IType returnType = dfs.getReturnType(); if (returnType == JavaTypes.pBOOLEAN() || returnType == JavaTypes.BOOLEAN()) { IDynamicFunctionSymbol rootDFS = dfs; while (rootDFS.getSuperDfs() != null) { rootDFS = rootDFS.getSuperDfs(); while( rootDFS.getBackingDfs() != null && rootDFS.getBackingDfs() != rootDFS ) rootDFS = rootDFS.getBackingDfs(); if (rootDFS.getGosuClass() != null && IGosuClass.ProxyUtil.isProxy(rootDFS.getGosuClass())) { IType proxiedType = IGosuClass.ProxyUtil.getProxiedType(rootDFS.getGosuClass()); IPropertyInfo propertyInfo = proxiedType.getTypeInfo().getProperty(dfs.getDisplayName().substring(1)); if (propertyInfo instanceof IJavaPropertyInfo) { IJavaPropertyDescriptor propertyDescriptor = ((IJavaPropertyInfo) propertyInfo).getPropertyDescriptor();
public static boolean isTargetMethod(IFunctionStatement target) { if (target != null && target.getDynamicFunctionSymbol() != null && target.getDynamicFunctionSymbol().getModifierInfo() != null) { IDynamicFunctionSymbol dfs = target.getDynamicFunctionSymbol(); return isPublic(dfs.getModifiers()) && (findAnnotation(dfs.getModifierInfo().getAnnotations(), TypeSystem.get(gw.vark.annotations.Target.class)) || dfs.getArgs().size() == 0); } return false; }
private boolean staticRefToNonStaticFunc( String stFunction, Expression[] eArgs ) { if( isParsingStaticFeature() && getGosuClass() != null ) { List<? extends IDynamicFunctionSymbol> matchingDFSs = getGosuClass().getMemberFunctions( stFunction ); for( IDynamicFunctionSymbol dfs : matchingDFSs ) { if( !dfs.isStatic() && dfs.getArgs().size() == eArgs.length ) { return true; } } } return false; }
private IType maybeResolveFunctionTypeVars( IDynamicFunctionSymbol dfs, IType type ) { if (TypeSystem.isDeleted(type)) { return TypeSystem.getErrorType(); } FunctionType funcType = (FunctionType)dfs.getType(); ArrayList<IType> functionTypeVars = new ArrayList<>(); IType declaringType = dfs.getScriptPart() == null ? null : dfs.getScriptPart().getContainingType(); boolean bConstructor = declaringType != null && dfs.getDisplayName().equals( declaringType.getRelativeName() ); if( bConstructor ) { if( declaringType.isGenericType() && !declaringType.isParameterizedType() ) { for( IGenericTypeVariable tv: declaringType.getGenericTypeVariables() ) { functionTypeVars.add( tv.getTypeVariableDefinition().getType() ); } } } else { for( IGenericTypeVariable tv : funcType.getTypeVariables() ) { functionTypeVars.add( tv.getTypeVariableDefinition().getType() ); } } return TypeLord.boundTypes( type, functionTypeVars ); }
/** * Assign the super dfs in terms of the deriving class's type parameters */ private void assignSuperDfs( IDynamicFunctionSymbol dfsDelegate, IGosuClass owner ) { IDynamicFunctionSymbol rawSuperDfs = dfsDelegate.getSuperDfs(); if( rawSuperDfs instanceof DynamicFunctionSymbol ) { while( rawSuperDfs.getBackingDfs() instanceof DynamicFunctionSymbol && rawSuperDfs.getBackingDfs() != rawSuperDfs ) { rawSuperDfs = rawSuperDfs.getBackingDfs(); } IType ownersType = rawSuperDfs.getDeclaringTypeInfo().getOwnersType(); if( !IGosuClass.ProxyUtil.isProxy( ownersType ) ) { IType superOwner = TypeLord.findParameterizedType( owner, ownersType ); if( superOwner == null ) { superOwner = ownersType; } setSuperDfs( ((DynamicFunctionSymbol)rawSuperDfs).getParameterizedVersion( (IGosuClass)superOwner ) ); } } }
public ParameterizedDynamicFunctionSymbol( IDynamicFunctionSymbol dfsDelegate, IGosuClass owner ) { super( (DynamicFunctionSymbol)dfsDelegate ); _dfsDelegate = (DynamicFunctionSymbol)dfsDelegate; setType( new FunctionType( (FunctionType)dfsDelegate.getType(), owner ) ); // Use generic types name so that we can look this DFS up by name later on String strName = getType().getName() + getParameterDisplay( false ); if( _dfsDelegate.getName().charAt( 0 ) == '@' && strName.charAt( 0 ) != '@' ) { strName = '@' + strName; } setName( strName ); setDisplayName( dfsDelegate.getDisplayName() ); setScriptPart( new ScriptPartId( owner, null ) ); assignSuperDfs( dfsDelegate, owner ); }
if( dfs.getType().isGenericType() ) IGenericTypeVariable[] genTypeVars = dfs.getType().getGenericTypeVariables(); iCount += genTypeVars.length; IType type = funcStmt.getDynamicFunctionSymbol().getScriptPart().getContainingType(); if( type instanceof IGosuClass && ((IGosuClass)type).isAnonymous() )
private IFeatureInfo findMethodInfo( IParsedElement pe ) { if( pe == null ) { return null; } if( pe instanceof IFunctionStatement ) { return ((IFunctionStatement)pe).getDynamicFunctionSymbol().getMethodOrConstructorInfo(); } return findMethodInfo( pe.getParent() ); }
if( dfs.getType().isGenericType() && Modifier.isReified( dfs.getModifiers() ) ) IGenericTypeVariable[] genTypeVars = dfs.getType().getGenericTypeVariables(); for( int i = 0; i < genTypeVars.length; i++ ) IType type = funcStmt.getDynamicFunctionSymbol().getScriptPart().getContainingType(); if( type instanceof IGosuClass && ((IGosuClass)type).isAnonymous() )
public void putDfsDeclInSetByName( IDynamicFunctionSymbol dfs ) { String displayName = dfs.getDisplayName(); Set<IFunctionSymbol> dfsDecls = _dfsDeclByName.get( displayName ); if( dfsDecls == null ) { dfsDecls = new HashSet<IFunctionSymbol>(); try { _dfsDeclByName.put( displayName, dfsDecls ); } catch( Exception e ) { throw new RuntimeException( "Map type: " + _dfsDeclByName.getClass().getName(), e ); } } if( !dfsDecls.add(dfs) ) { // Replace old dfsDecls.remove( dfs ); boolean bAdd = dfsDecls.add(dfs); assert bAdd; } }
public void handleLineClick( MouseEvent e, int iLine, int iX, int iY ) { IFunctionStatement overrideFunction = getSuperFunction( iLine ); if( overrideFunction != null && iY < _iconOverrideAndImpl.getIconHeight() / 2 ) { IFunctionStatement funcStmt = overrideFunction.getDynamicFunctionSymbol().getSuperDfs().getDeclFunctionStmt(); ((GosuEditor)getEditor()).gotoDeclaration( funcStmt.getLocation().getDeepestLocation( funcStmt.getNameOffset( null ), true ).getParsedElement() ); } else { if( e.isPopupTrigger() ) { showContextMenu( e, iLine ); } else { getBreakpointManager().toggleLineBreakpoint( getEditor(), getEditor().getScriptPart().getContainingTypeName(), getEditor().getTypeAtLine( iLine ), iLine ); } } }
private void filterUnwantedSymbols( Collection<ISymbol> listSymbols ) { List<ISymbol> deleteSyms = new ArrayList<ISymbol>(); for( ISymbol s : listSymbols ) { if( s.getType() == GosuTypes.DEF_CTOR_TYPE() || (s instanceof IDynamicFunctionSymbol && ((IDynamicFunctionSymbol)s).isConstructor()) ) { // Filter constructor symbols (only applicable when editing a gs class) deleteSyms.add( s ); } else if( s instanceof IDynamicFunctionSymbol && s.getName().startsWith( "@" ) ) { // This is the getter or setter for a property, and the DPS will be in the list already deleteSyms.add( s ); } } listSymbols.removeAll( deleteSyms ); }
private void generateSuperCall() IType supertype = ((IFunctionStatement)_sourceOfIssue).getDynamicFunctionSymbol().getDeclaringTypeInfo().getOwnersType().getSupertype(); List<? extends IConstructorInfo> constructors = supertype.getTypeInfo().getConstructors(); if( constructors.size() == 1 )
private boolean isOverrideForSuperClass( DynamicFunctionSymbol dfs ) { IDynamicFunctionSymbol superDfs = dfs.getSuperDfs(); if( superDfs == null ) { return false; } return !superDfs.getScriptPart().equals( dfs.getScriptPart() ); }