public FrmCustomUpdateCreator() { InitializeComponent(); customUpdateElementViewer1.ElementDoubleClick += new CustomUpdateElementViewer.CustomUpdateElementViewer.ElementDoubleClickEventHandler(addElement); ExecutableElement executableElement = new ExecutableElement(); customUpdateElementViewer1.AddElement(executableElement); ScriptElement scriptElement = new ScriptElement(); customUpdateElementViewer1.AddElement(scriptElement); TextFileElement textFileElement = new TextFileElement(); customUpdateElementViewer1.AddElement(textFileElement); FileElement fileElement = new FileElement(); customUpdateElementViewer1.AddElement(fileElement); FolderElement folderElement = new FolderElement(); customUpdateElementViewer1.AddElement(folderElement); ServiceElement serviceElement = new ServiceElement(); customUpdateElementViewer1.AddElement(serviceElement); RegistryKeyElement RegKeyElement = new RegistryKeyElement(); customUpdateElementViewer1.AddElement(RegKeyElement); RegistryElement RegElement = new RegistryElement(); customUpdateElementViewer1.AddElement(RegElement); VariableElement variableElement = new VariableElement(); customUpdateElementViewer1.AddElement(variableElement); PowerManagementElement powerElement = new PowerManagementElement(); customUpdateElementViewer1.AddElement(powerElement); WaitElement waitElement = new WaitElement(); customUpdateElementViewer1.AddElement(waitElement); KillProcessElement killElement = new KillProcessElement(); customUpdateElementViewer1.AddElement(killElement); ReturnCodeElement returnCodeElement = new ReturnCodeElement(); customUpdateElementViewer1.AddElement(returnCodeElement); lnkLblHelp.Enabled = System.IO.File.Exists("Custom Updates.pdf"); }
private Stream <CompilationMessage> ValidateParameters(ExecutableElement resultMethod, Type annotation) { if (!IsValidAggregationSignature(resultMethod)) { return(Stream.of(new AggregationError(resultMethod, "@%s usage error: method should be public, non-static and without parameters.", annotation.Name))); } return(Stream.empty()); }
private Stream <CompilationMessage> ValidatePerformsWriteUsage(ExecutableElement executableElement) { if (executableElement.getAnnotation(typeof(PerformsWrites)) != null) { return(_performsWriteVisitor.visit(executableElement)); } return(Stream.empty()); }
public virtual Stream <CompilationMessage> ValidateReturnType(ExecutableElement method) { TypeMirror returnType = method.ReturnType; if (!_allowedTypesValidator.test(returnType)) { return(Stream.of(new ReturnTypeError(method, "Unsupported return type <%s> of function defined in <%s#%s>.", returnType, method.EnclosingElement, method.SimpleName))); } return(Stream.empty()); }
private Stream <CompilationMessage> ValidateAggregationResultMethod(ExecutableElement aggregationFunction, Element returnType, IList <ExecutableElement> resultMethods) { if (resultMethods.Count != 1) { return(Stream.of(MissingAnnotation(aggregationFunction, returnType, resultMethods, typeof(UserAggregationResult)))); } ExecutableElement resultMethod = resultMethods.GetEnumerator().next(); return(Stream.concat(ValidateParameters(resultMethod, typeof(UserAggregationUpdate)), _functionVisitor.validateReturnType(resultMethod))); }
private Stream <CompilationMessage> ValidateAggregationType(ExecutableElement aggregationFunction) { TypeMirror returnType = aggregationFunction.ReturnType; Element returnTypeElement = _types.asElement(returnType); if (returnTypeElement == null) { return(Stream.of(new AggregationError(aggregationFunction, "Unsupported return type <%s> of aggregation function.", returnType.ToString(), aggregationFunction.EnclosingElement))); } IList <ExecutableElement> updateMethods = MethodsAnnotatedWith(returnTypeElement, typeof(UserAggregationUpdate)); IList <ExecutableElement> resultMethods = MethodsAnnotatedWith(returnTypeElement, typeof(UserAggregationResult)); return(Stream.concat(ValidateAggregationUpdateMethod(aggregationFunction, returnTypeElement, updateMethods), ValidateAggregationResultMethod(aggregationFunction, returnTypeElement, resultMethods))); }
public override Stream <CompilationMessage> VisitExecutable(ExecutableElement method, Void ignored) { Procedure procedure = method.getAnnotation(typeof(Procedure)); if (procedure == null) { return(Stream.of(new PerformsWriteMisuseError(method, "@%s usage error: missing @%s annotation on method", typeof(PerformsWrites).Name, typeof(Procedure).Name))); } if (procedure.mode() != Mode.DEFAULT) { return(Stream.of(new PerformsWriteMisuseError(method, "@%s usage error: cannot use mode other than Mode.DEFAULT", typeof(PerformsWrites).Name))); } return(Stream.empty()); }
private Stream <CompilationMessage> ValidateAggregationUpdateMethod(ExecutableElement aggregationFunction, Element returnType, IList <ExecutableElement> updateMethods) { if (updateMethods.Count != 1) { return(Stream.of(MissingAnnotation(aggregationFunction, returnType, updateMethods, typeof(UserAggregationUpdate)))); } Stream <CompilationMessage> errors = Stream.empty(); ExecutableElement updateMethod = updateMethods.GetEnumerator().next(); if (!IsValidUpdateSignature(updateMethod)) { errors = Stream.of(new AggregationError(updateMethod, "@%s usage error: method should be public, non-static and define 'void' as return type.", typeof(UserAggregationUpdate).Name)); } return(Stream.concat(errors, _functionVisitor.validateParameters(updateMethod.Parameters))); }
public virtual Stream <CompilationMessage> ValidateName(ExecutableElement method) { Optional <string> customName = _customNameExtractor.apply(method.getAnnotation(_annotationType)); if (customName.Present) { if (IsInRootNamespace(customName.get())) { return(Stream.of(RootNamespaceError(method, customName.get()))); } return(Stream.empty()); } PackageElement @namespace = _elements.getPackageOf(method); if (@namespace == null) { return(Stream.of(RootNamespaceError(method))); } return(Stream.empty()); }
private Stream <CompilationMessage> ValidateReturnType(ExecutableElement method) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: string streamClassName = typeof(Stream).FullName; TypeMirror streamType = _typeUtils.erasure(_elementUtils.getTypeElement(streamClassName).asType()); TypeMirror returnType = method.ReturnType; TypeMirror erasedReturnType = _typeUtils.erasure(returnType); TypeMirror voidType = _typeUtils.getNoType(TypeKind.VOID); if (_typeUtils.isSameType(returnType, voidType)) { return(Stream.empty()); } if (!_typeUtils.isSubtype(erasedReturnType, streamType)) { return(Stream.of(new ReturnTypeError(method, "Return type of %s#%s must be %s", method.EnclosingElement.SimpleName, method.SimpleName, streamClassName))); } return(_recordVisitor.visit(returnType)); }
private FunctionInRootNamespaceError RootNamespaceError(ExecutableElement method, string name) { return(new FunctionInRootNamespaceError(method, "Function <%s> cannot be defined in the root namespace. Valid name example: com.acme.my_function", name)); }
public virtual Stream <CompilationMessage> ValidateEnclosingClass(ExecutableElement method) { return(_classVisitor.visit(method.EnclosingElement)); }
private FunctionInRootNamespaceError RootNamespaceError(ExecutableElement method) { return(new FunctionInRootNamespaceError(method, "Function defined in <%s#%s> cannot be defined in the root namespace. " + "Valid name example: com.acme.my_function", method.EnclosingElement.SimpleName, method.SimpleName)); }
public override Stream <CompilationMessage> VisitExecutable(ExecutableElement executableElement, Void ignored) { return(Stream.of <Stream <CompilationMessage> >(_functionVisitor.validateEnclosingClass(executableElement), _functionVisitor.validateParameters(executableElement.Parameters), _functionVisitor.validateName(executableElement), _functionVisitor.validateReturnType(executableElement)).flatMap(System.Func.identity())); }
private AggregationError MissingAnnotation(ExecutableElement aggregationFunction, Element returnType, IList <ExecutableElement> updateMethods, Type annotation) { return(new AggregationError(aggregationFunction, "@%s usage error: expected aggregation type <%s> to define exactly 1 method with this annotation. %s.", annotation.Name, _typeVisitor.visit(returnType), updateMethods.Count == 0 ? "Found none" : "Several methods found: " + MethodNames(updateMethods))); }
/// <summary> /// Validates method parameters and return type /// </summary> public override Stream <CompilationMessage> VisitExecutable(ExecutableElement executableElement, Void ignored) { return(Stream.of(_classVisitor.visit(executableElement.EnclosingElement), ValidateParameters(executableElement.Parameters), ValidateReturnType(executableElement), ValidatePerformsWriteUsage(executableElement)).flatMap(System.Func.identity())); }
public override Stream <CompilationMessage> VisitExecutable(ExecutableElement aggregationFunction, Void ignored) { return(Stream.of(_functionVisitor.validateEnclosingClass(aggregationFunction), ValidateParameters(aggregationFunction, typeof(UserAggregationFunction)), _functionVisitor.validateName(aggregationFunction), ValidateAggregationType(aggregationFunction)).flatMap(System.Func.identity())); }
private bool IsValidAggregationSignature(ExecutableElement resultMethod) { // note: return type is checked subsequently return(IsPublicNonStatic(resultMethod.Modifiers) && resultMethod.Parameters.Empty); }
private bool IsValidUpdateSignature(ExecutableElement updateMethod) { // note: parameters are checked subsequently return(IsPublicNonStatic(updateMethod.Modifiers) && updateMethod.ReturnType.Kind.Equals(VOID)); }